Sub topic 6
From Daily Active Users to Queries per Second
This chapter assumes you know the basics of client-server architecture, can do arithmetic with large numbers and powers of ten, and can read short Python snippets. You should already be comfortable with the 86,400-second day from the previous chapter on time conversions.
Why traffic is the first number
Almost every other estimate depends on request rate. Storage growth, bandwidth, cache size and server count all start from "how many requests per second do we handle?" Queries per second (QPS) is the number of requests the system receives in one second. In system design discussions, "query" means any request, not only a database query.
The standard path has four steps:
- Pick a number of daily active users (DAU).
- Estimate how many requests each user makes per day.
- Divide total daily requests by the seconds in a day to get average QPS.
- Multiply by a peak factor to get peak QPS.
Step 1: Choose DAU
DAU is the number of distinct users who use the product on a given day. It is not the same as registered users or monthly active users (MAU). A product with 100 million registered users might have 30 million MAU and 10 million DAU.
In an interview or design review, the requirements may give you DAU. If they don't, ask. If nobody knows, state an assumption and move on. A common shortcut is to assume DAU is a fraction of MAU, often 20% to 50% depending on how habitual the product is. A messaging app is used daily. A tax-filing app is not.
Step 2: Estimate requests per user per day
This is the hardest number to guess, because it depends on what you count. Decide first which operation you are sizing. A single user action can produce many requests: opening a feed may trigger one API call for the feed, several for images, and one for analytics.
Pick the unit that matters for the component you are designing. For a URL shortener, the interesting operations are "create a short link" and "follow a short link". For a social feed, they might be "post" and "read timeline". Treat reads and writes separately, because they usually differ by a large ratio and stress different parts of the system.
Useful habits:
- Count one meaningful operation per request. Say what it is.
- Use round numbers such as 1, 5, 10 or 50.
- Keep the read-to-write ratio explicit, for example 100:1 for a read-heavy service.
Step 3: Convert to average QPS
Total daily requests are DAU multiplied by requests per user. Divide by 86,400 seconds to spread them across the day.
For exact arithmetic, the calculation looks like this:
dau = 10_000_000
requests_per_user_per_day = 10
seconds_per_day = 86_400
peak_factor = 2
avg_qps = dau * requests_per_user_per_day / seconds_per_day
peak_qps = avg_qps * peak_factor
print(round(avg_qps)) # 1157
print(round(peak_qps)) # 2315Ten million users making ten requests each gives 100 million requests per day, which is about 1,157 requests per second on average.
Doing it in your head
You rarely need the exact figure. Round the day to 100,000 seconds (10^5) and the arithmetic becomes an exponent subtraction:
- 100 million requests per day is 10^8 / 10^5 = 10^3, so roughly 1,000 QPS.
The rounding error is about 14%, since 86,400 is about 14% below 100,000. That is well inside the margin of error of the other assumptions. Round up or down only when you want to be conservative. Here, rounding the day to 100,000 seconds makes the QPS slightly low. If you prefer to err on the side of over-provisioning, use 10^5 anyway and then apply a generous peak factor.
A second shortcut: one million requests per day is about 12 QPS (10^6 / 86,400 ≈ 11.6). You can scale from that. Ten million per day is about 120 QPS. One billion per day is about 12,000 QPS.
| Requests per day | Average QPS (exact) | Average QPS (mental) |
|---|---|---|
| 1 million | 12 | 10 |
| 10 million | 116 | 100 |
| 100 million | 1,157 | 1,000 |
| 1 billion | 11,574 | 10,000 |
| 10 billion | 115,741 | 100,000 |
Step 4: Apply a peak factor
Traffic is not flat. Users are active at certain hours, and events cause spikes. Systems fail at the peak, not at the average, so capacity planning uses peak QPS.
The peak factor is the ratio of peak load to average load. A factor of 2 is a common starting assumption for consumer apps, and 3 to 5 is common when usage clusters tightly, for example around a sports event or a daily commute. State the factor you chose. The next chapter covers peak versus average load in more detail, so here the aim is only to include the multiplication in the chain.
Splitting reads and writes
Most designs need separate numbers for reads and writes. Start with the write rate because it is usually the smaller and easier one to justify, then apply the ratio.
dau = 10_000_000
writes_per_user_per_day = 1
read_write_ratio = 100 # 100 reads for every write
seconds_per_day = 86_400
peak_factor = 2
write_qps = dau * writes_per_user_per_day / seconds_per_day
read_qps = write_qps * read_write_ratio
print(round(write_qps), round(write_qps * peak_factor)) # 116 231
print(round(read_qps), round(read_qps * peak_factor)) # 11574 23148Writes land on the primary datastore and drive storage growth. Reads can often be served from caches and replicas. Keeping the two numbers apart lets you size each path on its own.
Worked example: a note-sharing app
Suppose you design a note-sharing app. You assume:
- 50 million MAU, with 20% active each day, so 10 million DAU.
- Each user opens the app 4 times a day, and each open loads the note list (1 request) plus on average 3 notes (3 requests): 4 reads per open, so 16 reads per day.
- Each user creates or edits 2 notes per day.
- Peak factor of 3.
The calculation:
dau = 50_000_000 * 0.20
reads_per_user = 4 * 4
writes_per_user = 2
seconds_per_day = 86_400
peak_factor = 3
read_qps = dau * reads_per_user / seconds_per_day
write_qps = dau * writes_per_user / seconds_per_day
print(f"DAU: {dau:,.0f}")
print(f"avg read QPS: {read_qps:,.0f}, peak: {read_qps * peak_factor:,.0f}")
print(f"avg write QPS: {write_qps:,.0f}, peak: {write_qps * peak_factor:,.0f}")The output is:
DAU: 10,000,000
avg read QPS: 1,852, peak: 5,556
avg write QPS: 231, peak: 694In round numbers: about 2,000 read QPS and 200 write QPS on average, and about 5,000 and 700 at peak. That is enough to say a single database primary can handle the writes, but the reads will need replicas or a cache. That is the kind of conclusion an estimate exists to support.
Edge cases and common mistakes
Counting registered users as DAU
Registered users can be ten times or more the daily active count. Using them inflates QPS by the same factor. Always confirm which population a figure describes.
Forgetting the fan-out
One user action can trigger many internal requests. A post that is pushed to 500 followers' feeds is one write at the API but 500 writes inside the system. If you size the internal path, multiply by the fan-out. If you size the public API, don't.
Mixing units
Be careful with "per day", "per hour" and "per second". Write the unit next to every number as you go. A figure of "10 million per day" is not 10 million per second, and the error is a factor of 86,400.
Assuming uniform traffic across regions
Users in one time zone peak while another is asleep. A global service with traffic spread evenly across time zones has a smaller peak factor than a regional one. A single-country product has a sharper daily curve.
False precision
Reporting 1,157.407 QPS suggests accuracy the inputs do not have. Round your answer to one or two significant figures, such as "about 1,200 QPS", and carry on.
Summary of the method
- Name the population (DAU) and the operation you are counting.
- Multiply to get daily requests, then divide by 86,400, or by 10^5 in your head.
- Keep reads and writes separate.
- Apply a stated peak factor once.
- Round the result and say what it implies for the design.
Exercise
A video-sharing site has 30 million DAU. Each user watches 5 videos per day, and each watch needs 1 request to fetch metadata and 1 request to start the stream, so 2 requests per watch. Uploads are 1 per 50 users per day. Using a peak factor of 3, compute average and peak read QPS, and average upload QPS. Use 86,400 seconds per day and round to the nearest whole number.
Show answer
Daily read requests = 30,000,000 x 5 x 2 = 300,000,000. Average read QPS = 300,000,000 / 86,400 ≈ 3,472. Peak read QPS = 3,472 x 3 ≈ 10,417. Uploads per day = 30,000,000 / 50 = 600,000, so average upload QPS = 600,000 / 86,400 ≈ 7. The read-to-upload ratio is about 500:1, which points to caching and a content delivery network for reads, while a single write path is enough for uploads.
Exercise
Your teammate estimates QPS for a service with 2 million registered users, assuming each makes 20 requests per day, and gets about 463 QPS. You know only 10% of registered users are active daily. What is the corrected average QPS, and which step of the method did your teammate skip?
Show answer
The teammate used registered users instead of DAU. Correct DAU = 2,000,000 x 0.10 = 200,000. Daily requests = 200,000 x 20 = 4,000,000. Average QPS = 4,000,000 / 86,400 ≈ 46. The teammate skipped Step 1, choosing DAU, so the result is ten times too high.