Lessons › From one user to millions
Go worldwide
Half your users are now outside the US: 30% in Europe and 20% in Asia. A read from Mumbai to Virginia takes about 190 ms longer before your servers do any work.
Play this levelFree with an account. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
Nothing beats distance: the round trip from Mumbai to Virginia is fixed by the speed of light through fibre. The only fix is to run your servers closer to your users, in more regions.
Reads can stay local with a cache and a read replica in each region. Writes are harder: there's only one primary, so a write from Mumbai still crosses the world, unless it goes into a local queue and the user gets their answer straight away.
A region can also fail as a whole. Standbys live in the same region as the primary, so they go with it. What saves you is a replica somewhere else that can be promoted, and that takes minutes, by hand, and can lose the latest writes.
What you have to achieve
6,000 requests a second at the busiest hour, 10% of them writes and 20% static files.
- No broken or illegal connections
- No component is overloaded
- Fewer than 0.1% of requests fail
- p99 response time under 150 ms
- Workers clear the queue within the day
- After the home region goes dark and a replica takes over, under 0.1% of requests fail
- Machines cost at most $2,600 / month
What you learn
You made a design that's fast everywhere and outlives a whole region. Notice what it cost: reads may be slightly stale, and queued writes finish later than the user thinks.
Check yourself
How do you make reads fast for users in Mumbai?
- A bigger primary in Virginia
- A faster network
- A cache and read replica in a nearby region
Show the answer
A cache and read replica in a nearby region. Nothing beats distance. Run copies close to users so reads stay local.
What saves you if the primary's whole region fails?
- A replica in another region that can be promoted
- A standby in the same region
- More app servers
Show the answer
A replica in another region that can be promoted. Standbys live in the same region and go down with it. A replica elsewhere can take over, though it may lose the latest writes.