Scaling from 1 server to millions of users
Grow the site from 10,000 users to 100 million. See which part runs out first at each size, and what the next design adds to fix it.
Step through one request at each stage
A user opens the profile of user:42. Pick a stage of the design, then press Next step. Each run ends on the limit that forces the next stage.
With this design: With one server, a single restart took the whole site down. There was no second machine to take over.
- Users — open profiles — healthy
- One server — app and database — healthy — NOW — GET /users/42
- Request
- Answer
Step 1 of 4 · One server
Done: A user opens the profile of user:42
- What happens
- The request goes straight to the one server.
- Why
- At the start, one server is the simplest design to build and run.
- What changes
- The server does all the work.
- Next
- The same machine runs the app and the database
Event log
3 more to go. Press a line to go back to that step.
Step 1 of 4: One server. A user opens the profile of user:42. The request goes straight to the one server.
What this simplifies. Real systems change when a measured limit forces it, not at a fixed number of users. The order here is one common path. The tiers below show the same path with example sizes.
Grow the users, watch the bottleneck
Pick how many users the site has and which design serves them. Each design is built for one size and fills up at the next. The bar in each part shows how full it is.
At 10,000 users the busiest hour brings about 29 requests a second, and each dot stands for about 5 of them. The busiest part, the one server, is at 19% of capacity.
- Users — 10,000 users — healthy
- One server — app and database — healthy — 19% of capacity
Numbers add up:arrived 17 = served 16 + refused 0 + in flight 1.The lab checks this sum as it runs, so a counting mistake would show here.
What design 1 adds
It is the cheapest and simplest design to build, run and change while you find out what users want.
- DNS (Route 53). Turns the site name into the server address.
- One server. Runs the web app and the database together.
What limits it next
One server is a single point of failure. A crash, a memory leak or a restart for an update takes the whole site down.
The next step
Move the database to its own server, and put two app servers behind a load balancer.
What it costs
No spare machine, and one machine can only grow so big.
Things to try
- Keep design 1 and move to 100K users. The one server needs about twice its capacity, so about half the requests are turned away.
- Now pick design 2. Every part is under its capacity again. Move to 1M users and the database becomes the busiest part.
- Keep going: design 3 at 1M, then 10M users, then design 4. Each design fixes one limit, and the next limit shows up at the next user count.
- Compare design 4 and design 5 at 10M users. Nothing is full in either, but with one region the slowest requests wait over 100 ms longer.
What this simplifies. The capacities are round examples, chosen so each design handles its own size and fills up at the next. Real limits depend on the code, the queries and the machines, and you find them by measuring. Each part stands for a group of machines. Users from 10,000 to 100,000,000 all make 100 requests a day, with the busiest hour 2.5 times the average.