Update documentation and enhance system design resources

- Added new 'practice.md' file for system design interview questions with solutions, improving accessibility for candidates.
- Created 'reminder.md' to serve as a quick reference for system design solutions, guiding users through the problem-solving process.
- Updated 'design-glance.md' to clarify the design of the personal budget tracking app (Mint.com) and improved the structure of related content.
- Revised '.gitignore' to include 'site/' for mkdocs deployment and ensure proper file management.
- Made minor updates to 'mkdocs.yml' for better organization and clarity in documentation navigation.
pull/1081/head
Ido777 2025-05-11 19:21:06 +03:00 committed by Ido Ophir
parent f614af8bca
commit 1293486ac8
12 changed files with 331 additions and 128 deletions

5
.gitignore vendored
View File

@ -63,4 +63,7 @@ target/
scratch/ scratch/
# IPython Notebook templates # IPython Notebook templates
template.ipynb template.ipynb
# mkdocs
site/

View File

@ -137,7 +137,7 @@ Review the [Contributing Guidelines](CONTRIBUTING.md).
- [Design Pastebin.com (or Bit.ly)](#design-pastebincom-or-bitly) - [Design Pastebin.com (or Bit.ly)](#design-pastebincom-or-bitly)
- [Design the Twitter timeline and search (or Facebook feed and search)](#design-the-twitter-timeline-and-search-or-facebook-feed-and-search) - [Design the Twitter timeline and search (or Facebook feed and search)](#design-the-twitter-timeline-and-search-or-facebook-feed-and-search)
- [Design a web crawler](#design-a-web-crawler) - [Design a web crawler](#design-a-web-crawler)
- [Design Mint.com](#design-mintcom) - [Design personal budget tracking app (Mint.com)](#design-mintcom)
- [Design the data structures for a social network](#design-the-data-structures-for-a-social-network) - [Design the data structures for a social network](#design-the-data-structures-for-a-social-network)
- [Design a key-value store for a search engine](#design-a-key-value-store-for-a-search-engine) - [Design a key-value store for a search engine](#design-a-key-value-store-for-a-search-engine)
- [Design Amazon's sales ranking by category feature](#design-amazons-sales-ranking-by-category-feature) - [Design Amazon's sales ranking by category feature](#design-amazons-sales-ranking-by-category-feature)
@ -413,7 +413,7 @@ Check out the following links to get a better idea of what to expect:
| Design Pastebin.com (or Bit.ly) | [Solution](solutions/system_design/pastebin/README.md) | | Design Pastebin.com (or Bit.ly) | [Solution](solutions/system_design/pastebin/README.md) |
| Design the Twitter timeline and search (or Facebook feed and search) | [Solution](solutions/system_design/twitter/README.md) | | Design the Twitter timeline and search (or Facebook feed and search) | [Solution](solutions/system_design/twitter/README.md) |
| Design a web crawler | [Solution](solutions/system_design/web_crawler/README.md) | | Design a web crawler | [Solution](solutions/system_design/web_crawler/README.md) |
| Design Mint.com | [Solution](solutions/system_design/mint/README.md) | | Design personal budget tracking app (Mint.com) | [Solution](solutions/system_design/mint/README.md) |
| Design the data structures for a social network | [Solution](solutions/system_design/social_graph/README.md) | | Design the data structures for a social network | [Solution](solutions/system_design/social_graph/README.md) |
| Design a key-value store for a search engine | [Solution](solutions/system_design/query_cache/README.md) | | Design a key-value store for a search engine | [Solution](solutions/system_design/query_cache/README.md) |
| Design Amazon's sales ranking by category feature | [Solution](solutions/system_design/sales_rank/README.md) | | Design Amazon's sales ranking by category feature | [Solution](solutions/system_design/sales_rank/README.md) |
@ -440,7 +440,7 @@ You can practice a few sample questions and discuss solutions with the community
![Imgur](../../images/bWxPtQA.png) ![Imgur](../../images/bWxPtQA.png)
### Design Mint.com ### Design personal budget tracking app (Mint.com)
[View exercise and solution](solutions/system_design/mint/README.md) [View exercise and solution](solutions/system_design/mint/README.md)

View File

@ -36,7 +36,7 @@ See [CHANGELOG](https://github.com/ido777/system-design-primer-update/blob/main/
👉 Start here: [Study Guide](./study_guide.md) 👉 Start here: [Study Guide](./study_guide.md)
👉 Solve System Design Interview Questions [Questions & Solutions](./solutions.md) 👉 Solve System Design Interview Questions [Questions & Solutions](./practice.md)
👉 Identified Gaps while solving read the relevant sections in [System Design at a Glance](./design-glance.md) 👉 Identified Gaps while solving read the relevant sections in [System Design at a Glance](./design-glance.md)

25
docs/en/practice.md Normal file
View File

@ -0,0 +1,25 @@
## System design interview questions with solutions
> Common system design interview questions with sample discussions, code, and diagrams.
>
> Solutions linked to content in the `solutions/` folder.
| Question | |
|---|---|
| Design Text snippet sharer (e.g. GitHub Gist, Pastebin.com) | [Solution](../solutions/system_design/pastebin/README.md) |
| Design the Twitter timeline and search (or Facebook feed and search) | [Solution](../solutions/system_design/twitter/README.md) |
| Design a web crawler | [Solution](../solutions/system_design/web_crawler/README.md) |
| Design personal budget tracking app (Mint.com) | [Solution](../solutions/system_design/mint/README.md) |
| Design the data structures for a social network | [Solution](../solutions/system_design/social_graph/README.md) |
| Design a key-value store for a search engine | [Solution](../solutions/system_design/query_cache/README.md) |
| Design Amazon's sales ranking by category feature | [Solution](../solutions/system_design/sales_rank/README.md) |
| Design a system that scales to millions of users on AWS | [Solution](../solutions/system_design/scaling_aws/README.md) |
| Add a system design question | [Contribute](01_Introduction.md#contributing) |
if you want to review the final high level solutions, after you worked on the exercise
Go to [Review solutions](./reminder.md)

60
docs/en/reminder.md Normal file
View File

@ -0,0 +1,60 @@
## System design interview solutions reminder Page
The questions list can be found at [Practice solutions](./practice.md)
Don't start here, you should
1) first read the question and try to solve
2) See solutions
3) After you worked on the exercises, and you want to brief the final solution as a quick reminder
### Design Text snippet sharer (e.g. GitHub Gist, Pastebin.com)
[View exercise and solution](../solutions/system_design/pastebin/README.md)
![Imgur](../../images/4edXG0T.png)
### Design the Twitter timeline and search (or Facebook feed and search)
[View exercise and solution](../solutions/system_design/twitter/README.md)
![Imgur](../../images/jrUBAF7.png)
### Design a web crawler
[View exercise and solution](../solutions/system_design/web_crawler/README.md)
![Imgur](../../images/bWxPtQA.png)
### Design personal budget tracking app (Mint.com)
[View exercise and solution](../solutions/system_design/mint/README.md)
![Imgur](../../images/V5q57vU.png)
### Design the data structures for a social network
[View exercise and solution](../solutions/system_design/social_graph/README.md)
![Imgur](../../images/cdCv5g7.png)
### Design a key-value store for a search engine
[View exercise and solution](../solutions/system_design/query_cache/README.md)
![Imgur](../../images/4j99mhe.png)
### Design Amazon's sales ranking by category feature
[View exercise and solution](../solutions/system_design/sales_rank/README.md)
![Imgur](../../images/MzExP06.png)
### Design a system that scales to millions of users on AWS
[View exercise and solution](../solutions/system_design/scaling_aws/README.md)
![Imgur](../../images/jj3A5N8.png)

View File

@ -333,7 +333,7 @@ Ask clear, somewhat pre-defined open-ended questions that surface assumptions, c
**Interviewer**: Design Pastebin.com. **Interviewer**: Design Pastebin.com.
**Candidate**: Thanks. To clarify and understand the scope, may I start with a few quick questions? **Candidate**: To clarify and understand the scope, may I start with a few quick questions?
**Interviewer**: Yes, please. **Interviewer**: Yes, please.
@ -813,9 +813,7 @@ Try to test your memory about the system design guides.
After mapping your gaps prioritize your learning and learn and practice. After mapping your gaps prioritize your learning and learn and practice.
Learn / Refresh your knowledge by reading the system design topics and practice by solving the interview questions. Learn / Refresh your knowledge by reading the system design topics and practice by solving the interview questions.
---
> Comment: We are working on a tools to help you with this. > Comment: We are working on a tools to help you with this.
---
# Personal Learning Plan # Personal Learning Plan
@ -841,9 +839,6 @@ Let's us know if it worked for you or if you think we can improve it.
| Once you see that you missed something in your solution jump over to the [System design topics](index.md#index-of-system-design-topics) and refresh your knowledge | Few times | More times | Know by heart | | Once you see that you missed something in your solution jump over to the [System design topics](index.md#index-of-system-design-topics) and refresh your knowledge | Few times | More times | Know by heart |
### System design knowledge ### System design knowledge
### Timeline matters ### Timeline matters
@ -866,7 +861,6 @@ Other resources
- Read through a few articles in the [Company engineering blogs](16_real_world_architectures.md#company-engineering-blogs) for the companies you are interviewing with - Read through a few articles in the [Company engineering blogs](16_real_world_architectures.md#company-engineering-blogs) for the companies you are interviewing with
- Read through a few [Real world architectures](16_real_world_architectures.md#real-world-architectures) - Read through a few [Real world architectures](16_real_world_architectures.md#real-world-architectures)
--- ---
# Learning Loop # Learning Loop
@ -878,9 +872,6 @@ Time to practice.
--- ---
# FAQ # FAQ
**Q: For interviews, do I need to know everything here?** **Q: For interviews, do I need to know everything here?**
@ -908,6 +899,7 @@ Check out the following links to get a better idea of what to expect:
3. **Exponent**, ["Five common system design interview mistakes 😅"](https://www.youtube.com/watch?v=z_YuqLmGZuo&ab_channel=GauravSen). 3. **Exponent**, ["Five common system design interview mistakes 😅"](https://www.youtube.com/watch?v=z_YuqLmGZuo&ab_channel=GauravSen).
More (original repo) resources: More (original repo) resources:
* [How to ace a systems design interview](https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/) * [How to ace a systems design interview](https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/)
* [The system design interview](http://www.hiredintech.com/system-design) * [The system design interview](http://www.hiredintech.com/system-design)
* [Intro to Architecture and Systems Design Interviews](https://www.youtube.com/watch?v=ZgdS0EUmn70) * [Intro to Architecture and Systems Design Interviews](https://www.youtube.com/watch?v=ZgdS0EUmn70)

View File

@ -20,27 +20,51 @@ Here is an example of the dialog you could have with the interviewer:
**Example dialog with your interviewer:** **Example dialog with your interviewer:**
**Interviewer**: Design Mint.com. **Interviewer**: Design personal budget tracking app (Mint.com).
**Candidate**: Sure—could you remind me what the core value proposition of Mint.com is?
**Candidate**: To clarify and understand the scope, may I start with a few quick questions?
**Interviewer**: Yes, please.
**Candidate**: What are the **main features, users, and use cases** of the system?
**Interviewer**: It aggregates users financial accounts, categorizes transactions, and helps them budget. **Interviewer**: It aggregates users financial accounts, categorizes transactions, and helps them budget.
**Candidate**: Got it. How do we get the data from the financial accounts? **Candidate**: Got it. How do we get the data from the financial accounts?
**Interviewer**: connects to a financial account. **Interviewer**: connects to a financial account.
**Candidate**: Should we focus on real-time updates or would a daily refresh suffice? **Candidate**: Should we focus on real-time updates or would a daily refresh suffice?
**Interviewer**: Daily is fine. **Interviewer**: Daily is fine.
**Candidate**: How should categorization work? **Candidate**: How should categorization work?
**Interviewer**: Auto-categorize based on merchant, but allow manual overrides. No re-categorization once set. **Interviewer**: Auto-categorize based on merchant, but allow manual overrides. No re-categorization once set.
**Candidate**: Understood. What budget features are needed? **Candidate**: Understood. What budget features are needed?
**Interviewer**: Recommend budgets by category, allow manual budgets, and notify when users approach or exceed them. **Interviewer**: Recommend budgets by category, allow manual budgets, and notify when users approach or exceed them.
**Candidate**: Any non-functional requirements? **Candidate**: Any non-functional requirements?
**Interviewer**: High availability is a must; budget alerts dont need millisecond latency. **Interviewer**: High availability is a must; budget alerts dont need millisecond latency.
**Candidate**: Great. And scale? **Candidate**: Great. And scale?
**Interviewer**: Target ~10 M users, ~30 M linked accounts, ~5 B transactions/mo, with ~500 M reads/mo. **Interviewer**: Target ~10 M users, ~30 M linked accounts, ~5 B transactions/mo, with ~500 M reads/mo.
### Use cases **Candidate**: Thanks — that's clear and helps scope my design. Let's me summarize the scope as i understood it and the assumptions to make sure we are on the **same page**.
#### We'll scope the problem to handle only the following use cases **Interviewer**: Ok.
* **User** connects to one or more financial accounts (bank, credit card, investment). **Candidate**: ok, here a reflection of what I understood from the requirements, I will write it down here
> ### Use cases
> * **User** connects to one or more financial accounts (bank, credit card, investment).
>
> ### Background tasks
* **Service** extracts transactions from the account * **Service** extracts transactions from the account
* Daily batch updates for active users (last 30 days). * Daily batch updates for active users (last 30 days).
* Categorizes transactions * Categorizes transactions
@ -53,11 +77,21 @@ Here is an example of the dialog you could have with the interviewer:
* Recommend a budget per category. * Recommend a budget per category.
* Allow users to set or adjust budgets manually. * Allow users to set or adjust budgets manually.
* Send notifications when spending approaches/exceeds budget. * Send notifications when spending approaches/exceeds budget.
* **Service** has high availability
#### Out of scope >
> ### Non functional requirements
> * **Service** has high availability
>
> ### Out of scope
> * **Service** performs additional logging and analytics
> * All authenticated users features
> * Any other requirements
>
> ### Other considerations we need to think about (Later on)
> * System Quality Attributes (Reliability, Scalability, Security & Privacy, Operational Aspects, etc.)
> * System life cycle (Deployment, Monitoring, Logging, Automation, CI/CD, etc.)
* **Service** performs additional logging and analytics
### Constraints & assumptions ### Constraints & assumptions
@ -495,7 +529,7 @@ class SpendingByCategory(MRJob):
> Identify and address bottlenecks, given the constraints. > Identify and address bottlenecks, given the constraints.
![Imgur](http://i.imgur.com/V5q57vU.png) ![Imgur](../../../images/V5q57vU.png)
**Important: Do not simply jump right into the final design from the initial design!** **Important: Do not simply jump right into the final design from the initial design!**

View File

@ -7,23 +7,6 @@ We will focus only on the core functionality.
[Design A URL shortener](../url_shortener/README.md) - e.g. [TinyURL](https://tinyurl.com/), [bit.ly](https://bit.ly/) is a related question, since pastebin requires storing the paste contents instead of the original unshortened url. However, the URL shortener question is more focused on the shortlink generation and redirection, while the pastebin question is more focused on the storage and retrieval of the paste contents. [Design A URL shortener](../url_shortener/README.md) - e.g. [TinyURL](https://tinyurl.com/), [bit.ly](https://bit.ly/) is a related question, since pastebin requires storing the paste contents instead of the original unshortened url. However, the URL shortener question is more focused on the shortlink generation and redirection, while the pastebin question is more focused on the storage and retrieval of the paste contents.
## Step 1: Investigate the problem, use cases and constraints and establish design scope
> Gather main functional requirements and scope the problem.
> Ask questions to clarify use cases and constraints.
> Discuss assumptions.
Adding clarifying questions is the first step in the process.
Remember your goal is to understand the problem and establish the design scope.
### What questions should you ask to clarify the problem?
Here is an example of the dialog you could have with the **Interviewer**:
**Interviewer**: Design Pastebin.com.
**Candidate**: Could you please remind me what Pastebin.com does at a high level?
**Interviewer**: Do you happen to know GitHub Gist? It is similar to Pastebin.com.
## 📝 Pastebin.com Overview ## 📝 Pastebin.com Overview
@ -47,44 +30,110 @@ Here is an example of the dialog you could have with the **Interviewer**:
- Temporary storage of text for collaboration or troubleshooting. - Temporary storage of text for collaboration or troubleshooting.
- Situations where simplicity and speed are paramount. - Situations where simplicity and speed are paramount.
**Candidate**: Got it. Since Pastebin can be quite complex, can we focus on just the core features first?
**Interviewer**: Sure—what would you target?
**Candidate**: The main requirement is that the user pastes text and immediately receives a shareable link. Correct?
**Interviewer**: Can you elaborate on the link?
**Candidate**: A randomly generated, unique link.
**Interviewer**: Does it expire?
**Candidate**: No.
**Interviewer**: Never?
**Candidate**: (_Oops, she doesnt like that we dont have expiration._) We can add a timed expiration—user can set the expiration.
**Interviewer**: Sounds good.
**Candidate**: Cool. Let me summarize.
Conclusion: ## Step 1: Investigate the problem, use cases and constraints and establish design scope
- Use cases
• User enters a block of text and gets a randomly generated link
- Expiration
• Default setting does not expire
• Can optionally set a timed expiration
**Candidate**: Mobile or desktop client? > Gather main functional requirements and scope the problem.
**Interviewer**: Both. > Ask questions to clarify use cases and constraints.
**Candidate**: Is user authentication or account registration required to view or create pastes? > Discuss assumptions.
**Interviewer**: No registration is needed; its anonymous.
**Candidate**: Great. Do we need to track usage statistics or analytics for these pastes?
**Interviewer**: We will record monthly visit stats. Adding clarifying questions is the first step in the process.
**Candidate**: Should expired pastes be removed automatically? Remember your goal is to understand the problem and establish the design scope.
**Interviewer**: Yes, the service deletes expired pastes.
**Candidate**: What availability SLA do we expect?
**Interviewer**: High availability is a requirement. ### What questions should you ask to clarify the problem?
**Candidate**: For this exercise phase, I would like to suggest that we don't need user accounts, login, or custom shortlinks.
**Interviewer**: ok, Those are out of scope for now. Here is an example of the dialog you could have with the **Interviewer**:
**Candidate**: For capacity planning, can you confirm traffic patterns and volumes? ### 🔍 Example Dialogue (Pastebin)
**Interviewer**: Traffic is unevenly distributed; we target 10M users, 10M writes/month, and 100M reads/month.
**Candidate**: Understood. And are pastes text only, with low-latency URL resolution? **Interviewer**: Design Pastebin.com.
**Interviewer**: Correct.
**Candidate**: Finally, any rough numbers on storage and throughput? **Candidate**: To clarify and understand the scope, may I start with a few quick questions?
**Interviewer**: I'll leave that to you.
**Candidate**: ok. So here is the scope of the problem: **Interviewer**: Yes, please.
**Candidate**: What are the **main features, users, and use cases** of the system?
**Interviewer**: Pastebin is a simple site to share plain text. Users paste content and get a short link to share. Pastebin includes anonymous users as well as logged in users.
**Candidate**: Great. So **can we scope the problem to 2 main flows**:
1. User creates a paste and gets a link to share.
2. User accesses a paste using the link.
**Interviewer**: Yes, that's a good start.
**Candidate**: What are the **other** important topics we need to consider for the basic **MVP** functionality?
**Interviewer**: Pastebin supports two types of users:
* Anonymous users - who can create and share content without an account
* Authenticated users - who can create content and customize their sharing links (e.g., custom URLs, expiration dates, access controls).
**Candidate**: Understood. For this phase, can we **focus** on Anonymous users?
**Interviewer**: You mean that we should ignore the requirements for authenticated users?
**Candidate**: No, I want to **clarify**. I am suggesting and **asking** your confirmation - to be effective I think we can start dealing with the main flows of the system. We will bear in mind the authenticated requirement and **deal with them later on**.
**Interviewer**: Later on in the interview, or later on in the product life cycle?
**Candidate**: Both. Let me explain. Let's for now assume that we will use REST API to write and read the content. We can have 2 different api endpoints for anonymous and authenticated users, and we can have shared functions that can be used by both. This way we can **focus** on the main flows of the system. On the other hand we can talk about the authenticated requirements now, such as [OAuth 2.0](https://oauth.net/2/) of [JWT](https://jwt.io/).
**Interviewer**: Ok.
**Candidate**: So for now, is it ok to focus on the anonymous users?
**Interviewer**: Yes.
**Candidate**: What are the *other* important topics we need to consider? What about traffic assumptions / load?
**Interviewer**: 10M writes per month, 100M reads.
**Candidate**: Got it. High read-to-write ratio. Any *other* specific requirements, assumptions or constraints, data flows?
**Interviewer**: We do track monthly stats. Links can have optional expiration. Expired pastes are auto-deleted.
**Candidate**: Is there **anything more** we should discuss in terms of latency, availability, or other non-functional constraints?
**Interviewer**: Reads should be low-latency. High availability is expected.
**Candidate**: Cost efficiency, scaling and security matter, but I **suggest** to digest those in the next phases.
**Interviewer**: Ok.
**Candidate**: Thanks — that's clear and helps scope my design. Let's me summarize the scope as i understood it and the assumptions to make sure we are on the **same page**.
**Interviewer**: Ok.
### 🔍 Example Breakdown
**Candidate**: ok, here a reflection of what I understood from the requirements, I will write it down here
> ### Use cases
> * **User** enters a block of text and gets a randomly generated link
> * **User** enters a paste's url and views the contents
> * **User** is anonymous
>
> ### Background tasks
> * **Service** tracks analytics of pages
> * Monthly visit stats
> * **Service** deletes expired pastes
>
> ### Non functional requirements
> * **Service** has high availability
>
> ### Out of scope
> * All authenticated users features
> * Any other requirements
>
> ### Other considerations we need to think about (Later on)
> * System Quality Attributes (Reliability, Scalability, Security & Privacy, Operational Aspects, etc.)
> * System life cycle (Deployment, Monitoring, Logging, Automation, CI/CD, etc.)
Does it look good? Did I miss anything? Any thing else we should cover at this stage?
**Interviewer**: Yes, it looks good.
### Use cases ### Use cases
@ -379,6 +428,44 @@ While traditional MapReduce jobs are rarely written manually today, the underlyi
**Clarify with your interviewer the expected amount, style, and purpose of the code you should write**. **Clarify with your interviewer the expected amount, style, and purpose of the code you should write**.
#### Example of MapReduce Concept
For educational purposes and small local testing, we can simulate MapReduce logic using Python. This is **not how production systems work today**, but it is useful for **understanding the concepts** and explaining it to the interviewer.
```python
from collections import defaultdict
# Example raw log lines
logs = [
'2025-04-01 12:00:00 /home',
'2025-04-01 12:05:00 /about',
'2025-04-01 12:10:00 /home',
'2025-04-02 13:00:00 /contact',
]
# Map Step
mapped = []
for line in logs:
timestamp, url = line.split()
day = timestamp.split('T')[0] if 'T' in timestamp else timestamp.split()[0]
mapped.append(((day, url), 1))
# Shuffle & Group Step
grouped = defaultdict(list)
for key, value in mapped:
grouped[key].append(value)
# Reduce Step
reduced = {}
for key, values in grouped.items():
reduced[key] = sum(values)
# Output
for key, count in reduced.items():
print(f"{key}: {count}")
```
#### Modern "MapReduce" today looks like: #### Modern "MapReduce" today looks like:
1. If you have logs (e.g., nginx, access logs): 1. If you have logs (e.g., nginx, access logs):
@ -414,47 +501,6 @@ ORDER BY
But you dont manage the "mapping" and "reducing" manually — the cloud service **optimizes** and **parallelizes** it for you. But you dont manage the "mapping" and "reducing" manually — the cloud service **optimizes** and **parallelizes** it for you.
#### Example of Local MapReduce Simulation for Testing:
For educational purposes and small local testing, we can simulate MapReduce logic using Python. This is **not how production systems work today**, but it is useful for **understanding the concepts**.
```python
from collections import defaultdict
# Example raw log lines
logs = [
'2025-04-01 12:00:00 /home',
'2025-04-01 12:05:00 /about',
'2025-04-01 12:10:00 /home',
'2025-04-02 13:00:00 /contact',
]
# Map Step
mapped = []
for line in logs:
timestamp, url = line.split()
day = timestamp.split('T')[0] if 'T' in timestamp else timestamp.split()[0]
mapped.append(((day, url), 1))
# Shuffle & Group Step
grouped = defaultdict(list)
for key, value in mapped:
grouped[key].append(value)
# Reduce Step
reduced = {}
for key, values in grouped.items():
reduced[key] = sum(values)
# Output
for key, count in reduced.items():
print(f"{key}: {count}")
```
### Use case: Service deletes expired pastes ### Use case: Service deletes expired pastes
To delete expired pastes, we could just scan the **SQL Database** for all entries whose expiration timestamp are older than the current timestamp. All expired entries would then be deleted (or marked as expired) from the table. To delete expired pastes, we could just scan the **SQL Database** for all entries whose expiration timestamp are older than the current timestamp. All expired entries would then be deleted (or marked as expired) from the table.
@ -463,14 +509,19 @@ To delete expired pastes, we could just scan the **SQL Database** for all entrie
> Identify and address bottlenecks, given the constraints. > Identify and address bottlenecks, given the constraints.
![Imgur](http://i.imgur.com/4edXG0T.png) ![Imgur](../../../images/4edXG0T.png)
**Important: Do not simply jump right into the final design from the initial design!** **Important: Do not simply jump right into the final design from the initial design!**
State you would do this iteratively: State you would do this iteratively:
1) **Benchmark/Load Test**,
1) **Benchmark/Load Test**
2) **Profile** for bottlenecks 2) **Profile** for bottlenecks
3) address bottlenecks while evaluating alternatives and trade-offs, and 3) address bottlenecks while evaluating alternatives and trade-offs, and
4) repeat. 4) repeat.
See [Design a system that scales to millions of users on AWS](../scaling_aws/README.md) as a sample on how to iteratively scale the initial design. See [Design a system that scales to millions of users on AWS](../scaling_aws/README.md) as a sample on how to iteratively scale the initial design.

View File

@ -16,10 +16,19 @@ Remember your goal is to understand the problem and establish the design scope.
Here is an example of the dialog you could have with the **Interviewer**: Here is an example of the dialog you could have with the **Interviewer**:
**Interviewer**: Design a key-value cache to save the results of the most recent web server queries. **Interviewer**: Design a key-value cache to save the results of the most recent web server queries.
**Candidate**: ok, do you mean deploy Redis as docker or building Redis like? **Candidate**: ok, do you mean deploy Redis as docker or building Redis like?
**Interviewer**: I mean building Redis like. **Interviewer**: I mean building Redis like.
**Candidate**: ok, can you please explain the traffic assumptions?
**Candidate**: To clarify and understand the scope, may I start with a few quick questions?
**Interviewer**: Yes, please.
**Candidate**: What are the **main features, users, and use cases** of the system?
**Interviewer**: Yes, the cache should be able to handle 10 million users, 10 billion queries per month. **Interviewer**: Yes, the cache should be able to handle 10 million users, 10 billion queries per month.
**Candidate**: ok. So here is the scope of the problem: **Candidate**: ok. So here is the scope of the problem:
### Use cases ### Use cases
@ -73,7 +82,7 @@ Handy conversion guide:
<!-- Old image for reference ![Imgur](http://i.imgur.com/KqZ3dSx.png) --> <!-- Old image for reference ![Imgur](http://i.imgur.com/KqZ3dSx.png) -->
![Imgur](http://i.imgur.com/KqZ3dSx.png) ![Imgur](../../../images/KqZ3dSx.png)
```mermaid ```mermaid

View File

@ -2,13 +2,41 @@
*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* *Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.*
## Step 1: Outline use cases and constraints
> Gather requirements and scope the problem. Adding clarifying questions is the first step in the process.
> Ask questions to clarify use cases and constraints. Remember your goal is to understand the problem and establish the design scope.
> Discuss assumptions.
### What questions should you ask to clarify the problem?
Here is an example of the dialog you could have with the interviewer:
**Example dialog with your interviewer:**
**Interviewer**: Design Amazon's sales rank by category feature
**Candidate**: To clarify and understand the scope, may I start with a few quick questions?
**Interviewer**: Yes, please.
**Candidate**: What are the **main features, users, and use cases** of the system?
**Interviewer**: The system will calculate the sales rank of products by category. Users will be able to view the sales rank of products by category.
**Candidate**: What is the **expected traffic**?
**Interviewer**: The system will be able to handle 100 million requests per day.
**Candidate**: What is the **expected read/write ratio**?
**Interviewer**: The system will be able to handle 100:1 read/write ratio.
**Candidate**: What is the **expected data size**?
**Interviewer**: The system will be able to handle 100 million products.
Without an interviewer to address clarifying questions, we'll define some use cases and constraints.
### Use cases ### Use cases

View File

@ -2,4 +2,4 @@
*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update.git#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* *Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update.git#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.*
TBA TO BE ADDED

View File

@ -16,6 +16,7 @@ plugins:
default_language: en default_language: en
languages: languages:
en: English en: English
# - htmlproofer
markdown_extensions: markdown_extensions: