How do you estimate the queries per second (QPS) a system must handle?
MediumConceptBack-of-the-Envelope Estimation
Answer
Start from daily active users, multiply by actions per user per day, and divide by the number of seconds in a day (about 10^5). Then apply a peak factor and split reads from writes.
- Example: 100 million DAU each making 10 requests a day gives 10^9 requests per day, or about 12,000 QPS on average.
- Peak: traffic is uneven, so assume 2 to 3 times the average, giving roughly 25,000 to 35,000 QPS.
- Read/write split: with a 10:1 read-to-write ratio, writes are about 1,100 QPS on average, which tells you whether a single primary database can cope.
- State every assumption, round freely, and sanity-check the result against what one server can handle.
More in Back-of-the-Envelope Estimation
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Which numbers should you know for back-of-the-envelope estimation? | Concept | Easy | Read the answer to Which numbers should you know for back-of-the-envelope estimation? | |||
| 2 | How do you estimate the queries per second (QPS) a system must handle? | Concept | Medium | Read the answer to How do you estimate the queries per second (QPS) a system must handle? | |||
| 3 | How do you estimate the storage a system will need over several years? | Concept | Medium | Read the answer to How do you estimate the storage a system will need over several years? | |||
| 4 | How do you estimate bandwidth, cache size and the number of servers? | Concept | Medium | Read the answer to How do you estimate bandwidth, cache size and the number of servers? |