Sub topic 7
Peak Load Versus Average Load
This chapter assumes you can convert daily active users into average queries per second (QPS) using the 86,400-second day. It also assumes you know what a load balancer, cache, and database do. The goal is to turn an average rate into the rate your system must survive.
Why the average is the wrong number to design for
An average QPS spreads all of a day's traffic evenly across 86,400 seconds. Real users don't behave that way. They wake up, commute, take lunch breaks, and watch TV in the evening. The system sees a daily wave, not a flat line.
If you size servers for the average, they will be overloaded for several hours every day. Users see slow responses or errors exactly when the most people are using the product.
Capacity is therefore planned against peak load, the highest sustained request rate you expect in normal operation. The average still matters for cost and storage, but peak decides how much hardware you need at the busiest moment.
| Quantity | Driven by | Used for |
|---|---|---|
| Average QPS | Total daily volume | Cost, long-term totals, daily bandwidth |
| Peak QPS | Busiest period of the day | Server count, database capacity, load balancer limits |
| Burst QPS | Short spikes of seconds to minutes | Queues, rate limits, autoscaling reaction time |
The peak factor method
The simplest approach is to multiply average QPS by a peak factor:
peak_qps = avg_qps × peak_factorTypical starting values:
| Traffic shape | Peak factor |
|---|---|
| Steady, global, many time zones | 1.5 to 2 |
| Consumer app concentrated in one region | 2 to 3 |
| Commute or evening-driven usage | 3 to 5 |
| Event-driven (sales, live sports, ticket drops) | 10 or more |
Start with 2 unless you have a reason not to, and say so out loud. The first code example of this tutorial uses the same convention:
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)) # 2315In an interview or design review, round further: about 1,000 average and about 2,000 to 2,500 peak. The exact digits carry no information, because the peak factor itself is a guess.
Deriving the peak factor from a daily curve
A factor of 2 is an assumption. If you can describe the shape of the day, you can derive the factor instead. Estimate what share of daily traffic arrives in the busiest hour, then convert that hour into QPS.
peak_qps = daily_requests × peak_hour_share / 3600The next script uses an assumed hourly profile. Each entry is the percentage of daily traffic in that hour, and the entries sum to 100.
daily_requests = 100_000_000 # 10M users x 10 requests
# Assumed share of daily traffic per hour, hour 0 to hour 23 (percent)
hourly_share = [
1, 1, 1, 1, 1, 2, 3, 4,
5, 5, 5, 5, 5, 5, 4, 4,
4, 5, 6, 7, 8, 8, 7, 3,
]
assert len(hourly_share) == 24
assert sum(hourly_share) == 100
avg_qps = daily_requests / 86_400
peak_share = max(hourly_share) / 100
peak_hour = hourly_share.index(max(hourly_share))
peak_qps = daily_requests * peak_share / 3600
print(f"average QPS: {avg_qps:.0f}") # 1157
print(f"busiest hour: {peak_hour}:00") # 20:00
print(f"peak QPS: {peak_qps:.0f}") # 2222
print(f"implied peak factor: {peak_qps / avg_qps:.2f}") # 1.92The busiest hour carries 8% of the day, and a perfectly flat day would carry about 4.17% per hour. The ratio is about 1.9, which supports using 2. If 20% of traffic arrived in one hour, the implied factor would be 20 / 4.17, or about 4.8.
What shapes the peak
Several factors change how tall the peak is. Name the ones that apply to your system.
- Geography. A global product spreads its peak across time zones, so the curve is flatter. A product used in one country has a deep overnight trough and a sharper peak.
- Usage pattern. Work tools peak during business hours. Streaming peaks in the evening. Payment systems peak around paydays and holidays.
- Read versus write mix. Reads and writes often peak at different times and with different factors. Estimate them separately when the design treats them differently, for example a read-heavy cache and a write-limited database.
- Fan-out. One user action can trigger many internal requests. A page load that calls five backend services multiplies backend peak QPS by five.
- Retries. When a system slows down, clients retry. Retries add load at the worst moment. Plan headroom beyond the nominal peak.
Peak versus burst
Peak load, as used above, is hour-scale. It is the sustained rate you design capacity for. A burst is a shorter spike lasting seconds or minutes, such as a push notification sent to every user at once.
A burst can exceed the hourly peak several times over. Servers rarely absorb it by raw capacity, because buying hardware for a five-second spike is wasteful. Other mechanisms handle it:
- Queues smooth write bursts by letting work wait.
- Rate limits reject or delay excess requests.
- Caches and CDNs absorb repeated reads.
- Autoscaling adds servers, but only after a delay of tens of seconds to minutes.
Autoscaling does not help a spike that ends before new servers are ready. State which mechanism you are relying on when you pick a burst number.
Choosing what to size for
Sizing for the absolute maximum is expensive. Sizing for the average fails. A practical rule:
- Size baseline capacity for the expected daily peak plus headroom.
- Handle rarer events, such as launches and sales, with autoscaling, queues, or pre-provisioning for known dates.
- Keep a separate, explicit number for the worst foreseeable event and decide whether to pay for it or degrade gracefully.
Where peak and average each belong
Different resources respond to different numbers.
| Estimate | Use | Reason |
|---|---|---|
| Server count | Peak | Servers must keep up at the busiest moment |
| Database connections and IOPS | Peak | Saturation causes errors and latency |
| Network bandwidth and load balancer limits | Peak | Links saturate at the busiest moment |
| Storage growth | Average (daily totals) | Data accumulates regardless of when it arrives |
| Monthly cost of transfer | Average (daily totals) | Billing is by volume |
| Cache memory | Working set, not rate | Depends on distinct data, not QPS |
Storage is the clear exception. Ten million records written in one hour or spread across a day take the same disk space. Write throughput, however, still needs peak planning, because the disk and database must absorb the writes at the rate they arrive.
Worked example: peak for a feed read path
Assume 20 million DAU, with each user loading the feed 15 times per day, in one region.
- Daily feed loads: 20M × 15 = 300M.
- Average QPS: 300M / 86,400 ≈ 3,500.
- Traffic is concentrated in one region with an evening peak, so assume a peak factor of 3.
- Peak feed-load QPS: 3,500 × 3 ≈ 10,500, or about 10,000.
- Each feed load calls four backend services. Backend peak: 10,000 × 4 = 40,000 internal QPS.
The backend figure is four times the user-facing figure. The service and database teams must size for 40,000, not 10,000. Fan-out is easy to forget and changes the answer more than the peak factor does.
Common mistakes
- Using the average and calling it capacity. The system will fail daily at the busiest hour.
- Applying a large factor with no reason. A factor of 10 on a steady global service inflates cost by 5x or more. Justify any factor above 3 by naming the cause.
- Forgetting that the factor is a guess. Present a range, such as "2,000 to 3,000", not a precise figure.
- Ignoring headroom. Peak is the load you expect. Servers should not run at 100% at peak. The next chapters cover headroom in server capacity planning.
- Applying the peak factor to storage. Total volume is unaffected by when requests arrive.
Exercise
A service has 5 million DAU, and each user makes 20 requests per day. You expect 12% of daily traffic in the busiest hour. Compute average QPS, peak QPS from the busiest-hour share, and the implied peak factor. Round to the nearest hundred.
Show answer
Daily requests = 5M × 20 = 100M. Average QPS = 100M / 86,400 ≈ 1,157, about 1,200 rounded. Peak QPS = 100M × 0.12 / 3,600 = 12M / 3,600 ≈ 3,333, about 3,300. Implied peak factor = 3,333 / 1,157 ≈ 2.9, so about 3. A flat day would give 4.17% per hour, and 12 / 4.17 ≈ 2.9 confirms it.
Exercise
Each request in the previous exercise fans out to 3 internal calls to a database-backed service. Which QPS number should the database team plan for, and which number should the storage team use for yearly growth planning?
Show answer
The database team plans for peak internal QPS: about 3,333 × 3 ≈ 10,000. The storage team uses average daily totals, such as records written per day, because stored volume does not depend on when requests arrive within the day.