80,000 daily users, 18 requests each. How many servers?
Question
A concert ticket shop has 80,000 users a day, and each makes about 18 API requests. When a big sale opens, the shop must handle 180 requests a second.
In a load test, one server takes at most 100 requests a second. To keep responses fast, the team plans for 60 per server. The shop must keep working if one server fails.
A teammate says: "1,440,000 requests a day is about 17 a second. Two servers, one of them spare."
- How many servers do you need? Why is the teammate wrong?
- Each response is 12,000 bytes. What outgoing bandwidth is needed at peak, in megabits per second?
Show hints (3)
- "AVERAGE OR PEAK"
The day's average includes the night. Which number must the servers survive: the average, or the moment a sale opens?
- "ONE SERVER DOWN"
With N servers, one failure leaves
N - 1. Each of them takes 60 a second. What is the smallest N that still covers 180? - "BITS AND BYTES"
Network links are sold in bits per second. A byte is 8 bits, and a megabit is 1,000,000 bits.
Show checked explanation
Size for the peak, not the average. The day's average is about 17 requests a second, but a sale brings 180. If one server fails, the others must still carry 180 at 60 each. That takes 3, so you need 4 in total. At peak the shop sends 2.16 MB a second, which is 17.28 Mbit/s.
import math daily_requests = 80_000 * 18 average = daily_requests / 86_400 # seconds in a day peak = 180 # requests a second when a sale opens per_server = 60 # planned load, below the tested 100 spare = 1 # servers that may fail by_average = math.ceil(average / per_server) + spare by_peak = math.ceil(peak / per_server) + spare bytes_per_second = peak * 12_000 megabits = bytes_per_second * 8 / 1_000_000 print(f"average {average:.2f} req/s -> {by_average} servers") print(f"peak {peak} req/s -> {by_peak} servers") print(f"{bytes_per_second:,} bytes/s = {megabits} Mbit/s")
average 16.67 req/s -> 2 servers peak 180 req/s -> 4 servers 2,160,000 bytes/s = 17.28 Mbit/s
Code run on CPython 3.12 against the numbers above. Checked by an editor other than the author.
Walkthrough
The teammate's math is right: 80,000 × 18 = 1,440,000 requests a day. A day has 86,400 seconds, so the average is about 16.67 a second. But that number spreads the day evenly, nights included. When a sale opens, the shop gets 180 a second, nearly 11 times the average.
Size for the peak, then let one server fail:
| servers | left after 1 fails | capacity left | covers 180? |
|---|---|---|---|
| 2 (by the average) | 1 | 60 | no |
| 3 | 2 | 120 | no |
| 4 | 3 | 180 | yes |
So you need 4: three for the peak and one spare. This is often called N+1.
The table assumes two things. First, the load balancer spreads requests evenly. Three servers can carry 180 in total, but a split of 100, 40 and 40 overloads the first one. Second, the database and the network behind them can also take 180 a second.
So check the network next. 180 responses × 12,000 bytes = 2,160,000 bytes a second, or 2.16 MB/s. Links are sold in bits per second, so multiply by 8: 17,280,000 bits a second, which is 17.28 Mbit/s. That counts only the response bodies. Headers, retries and incoming traffic come on top.
Common mistakes
- Planning each server at its tested maximum of 100. Near it, requests queue up and responses get slow. Plan for the load that still meets your response-time goal.
- Forgetting the spare. Three servers carry exactly 180, but one failure leaves only 120.
- Reading 2.16 MB/s as 2.16 Mbit/s and ordering a 10 Mbit/s link. The shop needs 17.28 Mbit/s at peak, before headers.
Follow-up questions
- "Can a queue let you buy fewer servers?" Only for work whose result may wait, like e-mailing the tickets. The queue holds the burst, and workers drain it at a steady speed. The deadline still sets the worker count: 600 e-mails at 0.1 seconds each, all sent within 30 seconds, need 2 workers. One worker needs 60 seconds, queue or not. A purchase can't wait.
- "Can't autoscaling handle the sale?" Not for a sudden spike. A sale peaks in seconds, but a new server can take minutes to boot and warm up. For a known sale, add servers before it opens. Autoscaling suits slow changes, like the daily rise and fall.
- "Where does the 180 come from?" From a past sale's metrics, counted per second. A per-minute graph hides spikes. 6,000 requests in a minute average 100 a second, but if 1,000 came in the first 5 seconds, that was 200 a second. Add retries too: failed requests come back.
What a strong answer covers
Computes the average, then explains why it is the wrong number to size by. Sizes for the peak plus one spare, names the even-spread assumption, and converts bytes to bits without being asked.
Open in interactive practice deck →