Do the maths first
10 million people use your app each day and make 20 requests each. Work out the traffic before you build. A day has about 100,000 seconds, and the busiest hour runs at 3 times the average.
Play this levelPart of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
Back of the envelope estimation means rough sums, done quickly. You only need the right size: 6,000 req/s and 6,500 lead to the same design.
Round hard so the sums stay easy. A day is really 86,400 seconds, but 100,000 is close enough and you can do it in your head.
Design for the peak, not the average. Then add a spare, because a design with no room left falls over when one machine dies.
What you have to achieve
6,000 requests a second at the busiest hour, 10% of them writes.
- No broken or illegal connections
- Use an App Server with at least 4 instances
- No component is overloaded
- Fewer than 0.1% of requests fail
- p99 response time under 250 ms
What you learn
A few lines of rough maths told you how many servers to buy before you placed a single box. Interviewers look for this, and it stops real teams building far too much or far too little.
Check yourself
10 million people make 20 requests a day each. How many req/s is that on average?
- 200 req/s
- 2,000 req/s
- 20,000 req/s
Show the answer
2,000 req/s. 10 million × 20 = 200 million requests a day. Divide by 100,000 seconds and you get 2,000 req/s.
The busiest hour runs at 3 times the average. What must the design handle?
- 2,000 req/s
- 3,000 req/s
- 6,000 req/s
Show the answer
6,000 req/s. 2,000 × 3 = 6,000 req/s. If you only build for the average, you fall over every evening.
One server handles 2,000 req/s. How many should you run at the peak?
- 3 servers
- 4 servers
- 30 servers
Show the answer
4 servers. 6,000 ÷ 2,000 = 3 servers with no room left, so you add a spare and run 4.
1 million posts are written each day at 1 KB each. How much storage does a year take?
- About 365 MB
- About 365 GB
- About 365 TB
Show the answer
About 365 GB. 1 million × 1 KB = 1 GB a day, and 1 GB × 365 days = 365 GB.