Bugpit

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 level

Free, 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.

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?

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?

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?

Show the answer

Below about 70%. Near 100% requests queue up and p99 shoots up. Past it, retries add even more load.

Try it yourself

More in From one user to millions

← Separate the database Add a cache →