Part 4 of 9 · 2 min read
From users to requests per second
The standard chain: monthly users, daily users, requests a day, requests a second, peak.
Think of a train station. The station manager does not need the yearly total of passengers. The manager needs the number of passengers per minute at 8 a.m., because that is when the platform is crowded.
Queries per second
Queries per second, written QPS, is the number of requests that arrive at a system each second. It is the main number for sizing servers.
Example: if 8,640,000 requests arrive in a day, QPS is 8,640,000 ÷ 86,400, which is 100.
Peak QPS
Peak QPS is the highest request rate the system must handle, usually in the busiest minutes. A common rule of thumb is two to five times the average, and the right factor depends on the product.
Example: a shop with 100 requests per second on average may see 300 per second at lunchtime, so its peak QPS is 300.
The chain, with made-up numbers for a learning site. These numbers are made up to show the idea.
- Monthly users: 1,000,000.
- Share who visit on a given day: 30 percent, so daily active users are 300,000.
- Page views per visitor per day: 8, so 300,000 × 8 = 2,400,000 page views a day.
- Seconds in a day: about 86,400. So QPS is 2,400,000 ÷ 86,400, about 28 per second.
- Peak factor of 3: peak QPS is about 85 per second.
A second chain for saving a learner's progress. Assume each daily user saves progress 5 times a day.
- 300,000 × 5 = 1,500,000 saves a day.
- 1,500,000 ÷ 86,400 is about 17 saves a second. Peak, at ×3, is about 50.
A quick check on size. If one ordinary server can handle about 200 requests per second (a made-up figure), then 85 reads and 50 writes a second fit on one server. A second server is for safety, not for speed.
Common mistake
Using the monthly total as if it were daily. 1,000,000 monthly users do not send 1,000,000 requests in one day. Always convert to a day first, then to a second.
Check yourself:
- If daily active users double, what happens to QPS?
- Why might lunchtime traffic be larger than the average by a factor of three?