Skip to content

Commit 213768b

Browse files
chore: sync content to repo (#9564)
Co-authored-by: kamranahmedse <4921183+kamranahmedse@users.noreply.github.com>
1 parent 3e1d74c commit 213768b

6 files changed

+18
-30
lines changed

src/data/roadmaps/system-design/content/cache-aside@bffJlvoLHFldS0CluWifP.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@
33
The application is responsible for reading and writing from storage. The cache does not interact with storage directly. The application does the following:
44

55
* Look for entry in cache, resulting in a cache miss
6+
67
* Load entry from the database
8+
79
* Add entry to cache
10+
811
* Return entry
9-
10-
def get_user(self, user_id):
11-
user = cache.get("user.{0}", user_id)
12-
if user is None:
13-
user = db.query("SELECT * FROM users WHERE user_id = {0}", user_id)
14-
if user is not None:
15-
key = "user.{0}".format(user_id)
16-
cache.set(key, json.dumps(user))
17-
return user
12+
13+
def get\_user(self, user\_id): user = cache.get("user.{0}", user\_id) if user is None: user = db.query("SELECT \* FROM users WHERE user\_id = {0}", user\_id) if user is not None: key = "user.{0}".format(user\_id) cache.set(key, json.dumps(user)) return user
1814

1915

2016
[Memcached](https://memcached.org/) is generally used in this manner. Subsequent reads of data added to cache are fast. Cache-aside is also referred to as lazy loading. Only requested data is cached, which avoids filling up the cache with data that isn't requested.
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
# Database Caching
22

3-
Your database usually includes some level of caching in a default configuration, optimized for a generic use case. Tweaking these settings for specific usage patterns can further boost performance. it's like having a quick-access memory for frequently used data in applications. Here's a simplified explanation:
3+
Database caching involves storing frequently accessed data from a database in a temporary storage location (the cache) to reduce the load on the database and improve application performance. Instead of repeatedly querying the database for the same data, the application first checks the cache. If the data is present (a cache hit), it's retrieved from the cache, which is much faster than a database query. If the data is not in the cache (a cache miss), the application queries the database, retrieves the data, stores it in the cache for future use, and then returns it to the application.
44

5-
1. **Quick Access**: Imagine you're looking up information in a big library (the database). Instead of going to the library every time you need the same book (data), you keep a copy of it on your desk (cache).
6-
7-
2. **Faster Retrieval**: When you need that book again, you first check your desk (cache). If it's there, great! You get it right away without going to the library (database) again.
8-
9-
3. **Saving Time**: If the book isn't on your desk (cache miss), you go to the library (database) to get it. But you make sure to put a copy on your desk for next time, so you won't have to go to the library again if you need it soon.
10-
11-
4. **Different Types**: There are different ways to do this caching. You can cache the results of searches (like bookmarking), whole pieces of information (like keeping a paper copy), or even entire web pages (like saving a snapshot).
12-
13-
5. **Benefits**: By keeping frequently used data close by, you save time and reduce the strain on the library (database). It's like having your most-used books right at your fingertips, making your work faster and more efficient.
14-
5+
Visit the following resources to learn more:
156

16-
However, it's important to keep the cached data up to date. Otherwise, you might end up with outdated information, like using an old edition of a book instead of the latest one. So, managing this cache properly is key to keeping things running smoothly.
7+
- [@article@Database Caching](https://aws.amazon.com/caching/database-caching/)
8+
- [@article@Introduction to database caching](https://www.prisma.io/dataguide/managing-databases/introduction-database-caching)
9+
- [@article@Database Caching Strategies](https://medium.com/@sesmiat/database-caching-strategies-f5e40c3c9b74)

src/data/roadmaps/system-design/content/databases@5FXwwRMNBhG7LT5ub6t2L.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Picking the right database for a system is an important decision, as it can have
1010

1111
Visit the following resources to learn more:
1212

13-
- [@video@Scaling up to your first 10 million users (DB related material begins at 10:33)](https://youtu.be/kKjm4ehYiMs?si=knWdkA2Y5QHM5ZJw&t=633)
14-
- [@feed@Explore top posts about Backend Development](https://app.daily.dev/tags/backend?ref=roadmapsh)
13+
- [@video@Scaling up to your first 10 million users](https://www.youtube.com/watch?v=kKjm4ehYiMs)
14+
- [@feed@Explore top posts about Backend Development](https://app.daily.dev/tags/backend?ref=roadmapsh)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Queue Based Load Leveling
1+
# Queue-Based Load Leveling
22

33
Use a queue that acts as a buffer between a task and a service it invokes in order to smooth intermittent heavy loads that can cause the service to fail or the task to time out. This can help to minimize the impact of peaks in demand on availability and responsiveness for both the task and the service.
44

5-
Learn more from the following links:
5+
Visit the following resources to learn more:
66

7-
- [@article@Queue-Based Load Leveling pattern](https://learn.microsoft.com/en-us/azure/architecture/patterns/queue-based-load-leveling)
7+
- [@article@Queue-Based Load Leveling pattern](https://learn.microsoft.com/en-us/azure/architecture/patterns/queue-based-load-leveling)

src/data/roadmaps/system-design/content/sql-tuning@fY8zgbB13wxZ1CFtMSdZZ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Visit the following resources to learn more:
1111

1212
- [@official@Introduction to SQL Tuning - Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/23/tgsql/introduction-to-sql-tuning.html#GUID-B653E5F3-F078-4BBC-9516-B892960046A2)
1313
- [@article@Query Optimization for Mere Humans in PostgreSQL](https://towardsdatascience.com/query-optimization-for-mere-humans-in-postgresql-875ab864390a/)
14-
- [@feed@Explore top posts about SQL](https://app.daily.dev/tags/sql?ref=roadmapsh)
14+
- [@feed@Explore top posts about SQL](https://app.daily.dev/tags/sql?ref=roadmapsh)

src/data/roadmaps/system-design/content/what-is-system-design@idLHBxhvcIqZTqmh_E8Az.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ It involves taking a problem statement, breaking it down into smaller components
66

77
In software engineering, system design is a phase in the software development process that focuses on the high-level design of a software system, including the architecture and components.
88

9-
It is also one of the important aspects of the interview process for software engineers. Most of the companies have a dedicated system design interview round, where they ask the candidates to design a system for a given problem statement. The candidates are expected to come up with a detailed design of the system, including the architecture, components, and their interactions. They are also expected to discuss the trade-offs involved in their design and the alternatives that they considered.
10-
9+
Visit the following resources to learn more:
1110

1211
- [@article@System Design: Complete Guide with Patterns, Examples, and Techniques](https://swimm.io/learn/system-design/system-design-complete-guide-with-patterns-examples-and-techniques)
13-
- [@article@A comprehensive guide to system design](https://www.crio.do/blog/a-comprehensive-guide-to-system-design/)
12+
- [@article@A comprehensive guide to system design](https://www.crio.do/blog/a-comprehensive-guide-to-system-design/)

0 commit comments

Comments
 (0)