Lessons › From one user to millions
Scale out
You hit the news. 6,000 req/s arrive and one app server handles about 2,000. Press Run traffic to watch it fall over.
Play this levelFree, no account needed. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
Vertical scaling (a bigger machine) has a ceiling. Horizontal scaling adds more machines behind a Load Balancer that spreads requests across them (§6).
Then the database becomes the bottleneck. 90% of requests are reads, so add Read Replicas: copies of the database that answer reads. Writes still go to the primary, and each write costs about 10 reads, so the primary needs a bigger machine.
Run things below ~70% busy. Near 100%, requests queue up and response time shoots up, especially the slowest 1% (p99). Past 100% it gets worse: failed requests are retried, so even more load arrives.
What you have to achieve
6,000 requests a second at the busiest hour, 10% of them writes.
- No broken or illegal connections
- Use a Load Balancer
- No component is overloaded
- Fewer than 0.1% of requests fail
- p99 response time under 300 ms
What you learn
Each fix moves the bottleneck somewhere else. Finding the next bottleneck is the core skill of system design.
Check yourself
You added app servers, and then the database fell over. What is that called?
- A retry storm
- The bottleneck moving
- A cold start
Show the answer
The bottleneck moving. Each fix moves the bottleneck to the next part. Finding the next one is the core skill of system design.
90% of requests were reads. What took that load off the primary?
- A bigger load balancer
- More app servers
- Read replicas
Show the answer
Read replicas. Replicas are copies that answer reads. Writes still go to the primary, which is why it needed a bigger machine.
How busy should a machine run in normal traffic?
- Below about 70%
- Right at 100%
- Around 90%
Show the answer
Below about 70%. Near 100% requests queue up and p99 shoots up. Past it, retries add even more load.