Lessons › From one user to millions
Separate the database
Traffic grew to 1,500 req/s, and your data lives on the same machine as your code. You want to be able to replace or add servers.
Play this levelFree, no account needed. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
If data lives on the app server, you can't add a second server: each would have different data. You also lose everything if it dies.
Move the data to its own Database. Then app servers become stateless: any server can handle any request (§5.2).
What you have to achieve
1,500 requests a second at the busiest hour, 10% of them writes.
- No broken or illegal connections
- Use a Primary DB
- No failed requests
- p99 response time under 300 ms
What you learn
Your app server holds no data now, so you can copy it freely. That's what makes the next level possible.
Check yourself
Why did moving the data to its own database matter?
- It made each request faster
- App servers became stateless, so you can add more
- It made the bill smaller
Show the answer
App servers became stateless, so you can add more. With no data on it, any app server can answer any request. That's what lets you copy servers freely.
What goes wrong if two app servers each keep their own data?
- Users see different data depending on which server answers
- Nothing, it doubles capacity
- Writes get faster
Show the answer
Users see different data depending on which server answers. Each server would hold a different copy, so users would get different answers. Shared data needs one shared home.