Lesson 7 / 30

From Users to Requests per Second

Turn daily active users and per-user actions into average read and write QPS.

By · 15 years in web development

The traffic funnel

Traffic estimation starts from people, not servers. Begin with monthly active users (MAU) or daily active users (DAU); DAU is usually a fraction of MAU, and that ratio is itself an assumption. Multiply DAU by actions per user per day for each action type, for example feed loads, likes and uploads. That gives requests per day per action. Divide by 86,400 to get average QPS (queries per second). Remember that one user action may cause several backend requests: opening a feed might call the feed service, a profile service and an ads service. So decide whether you are estimating client requests at the edge or internal calls behind it, and multiply by a fan-out factor for the latter. Keeping reads and writes separate from the start matters, because they usually hit different components and scale differently.

From people to peak load

Traffic estimates move left to right: daily active users times actions per user gives requests per day, dividing by seconds per day gives average QPS, and a peak factor gives peak QPS.

Five connected stages: daily active users, actions per user, requests per day, average QPS, peak QPS.
Figure 3.1: daily active users -> actions per user -> requests per day -> average QPS -> peak QPS

A food-delivery app

Estimating average QPS for three actions of a hypothetical app.

dau = 20_000_000
actions = {               # per user per day
    "browse restaurants": 15,
    "track order": 6,
    "place order": 0.3,
}
for name, per_user in actions.items():
    qps = dau * per_user / 86_400
    print(f"{name:20s} {qps:10,.0f} avg QPS")

Output:

browse restaurants        3,472 avg QPS
track order               1,389 avg QPS
place order                  69 avg QPS

Fractions are fine

Not every user orders every day, so 0.3 orders per user per day is a perfectly good assumption. Averages over a population often come out fractional.

Quick check: A chat app has 10 million DAU, each sending 40 messages a day. Roughly what is the average message write rate?

  • About 400 per second
  • About 46,000 per second
  • About 4,600 per second
  • About 460,000 per second
Answer

About 4,600 per second — 10^7 x 40 = 4 x 10^8 messages per day; divided by 86,400 gives about 4,600 per second.