How to solve any System Design Question…
Welcome back peeps! Hope all’s well.
This is one of the most important post wrt System Design where we will discuss how to solve any System Design Question (approach that you should take).
Day 1 of System Design Case Studies can be found below —
But before moving forward, first understand why companies have System design interview round at all?
To put it simply, there are 5 reasons —
1. To check problem solving skills — how you can spot the most important pieces of the problem, make pragmatic assumptions.
2. To check if you can identify a complex or simplify a vague problem — do you discuss the different ideas that you get with others, evaluate the tradeoffs and optimize the solution.
3. To check if you can clearly communicate your solutions with other people. Discussion is an important part of software engineering.
4. To check if you can follow the clues and develop the idea further with your own understanding of the most important system design concepts.
5. To understand if you are the person who over engineers a problem which can be abstracted in simple steps.
Once you understand the objective behind the system design interview round, you whole strategy should be aligned towards above 5 points.
Alright! So, let’s talk about the approach to any System Design Questions that you can follow.
Build a framework + Think objectively + Discuss Strategically
For every step, 4 most important points —
1. Understand the problem and Define Design Scope ( 11- 15 minutes)
Specific Features ( max 4 features)
Practical Estimates (numerical)( Users, resources etc)
Scaling requirements ( say for x months)
2. Discuss High level Design, trade offs and take feedback from interviewer ( 15 minutes)
Key Resources and services
Feedback from the interviewer
3. Go in depth of the proposed solution — high level coding( 15 minutes)
Identify important components in the proposed architecture
Resources and scaling estimations ( calculations to meet the scaling requirements)
4. Discuss the bottle necks, refinements, improvements etc ( 7–10 minutes)
System Bottlenecks and failure/error points
Operational metrics and issues
Future of your proposed solution
Know your numbers
In one of the presentations at Stanford, Dr. Jeff Dean from Google gave these numbers that you should know before designing a system —
To evaluate design options, you should have a good sense of how long typical operations will take:
- Read 1 MB sequentially from memory: 250,000 ns
- Round trip within same datacenter: 500,000 ns
- Disk seek 10,000,000: ns
- Read 1 MB sequentially from network: 10,000,000 ns
- Read 1 MB sequentially from disk : 30,000,000 ns
- Send packet CA->Netherlands->CA : 150,000,000 ns
- L1 cache reference: 0.5 ns
- Branch mispredict: 5 ns
- L2 cache reference : 7 ns
- Mutex lock/unlock : 100 ns
- Main memory reference: 100 ns
- Compress 1K bytes with Zippy: 10,000 ns
- Send 2K bytes over 1 Gbps network : 20,000 ns