पाठ 8 / 30

Peaks, Spikes and Seasonality

यह पाठ अभी हिंदी में अनुवादित नहीं है, इसलिए अंग्रेज़ी में दिखाया जा रहा है।

Convert average QPS into a design peak using daily curves, event spikes and a safety margin.

लेखक: · 15 साल से वेब डेवलपर

Design for the peak, not the average

Traffic is never flat. Usage follows a daily curve with quiet nights and busy evenings, a weekly pattern, and event spikes: a cricket final, a festive sale, exam results, a push notification sent to every user at once. Systems fail at peaks, so capacity is planned for peak QPS = average QPS x peak factor. For organic daily traffic, a peak factor of roughly 2 to 3 is a common starting assumption; for flash events it can be far higher, and the only reliable source is your own historical metrics. Short spikes also differ from sustained peaks: a burst lasting seconds can be absorbed by queues and autoscaling headroom, while an evening peak lasting hours must be served by provisioned capacity. When you lack data, state a peak factor explicitly and explain why you chose it.

Peak from an hourly profile

If you know what share of daily traffic lands in the busiest hour, you can derive the peak factor instead of guessing.

daily_requests = 300_000_000
busiest_hour_share = 0.12      # 12% of the day's traffic in one hour

avg_qps = daily_requests / 86_400
peak_qps = daily_requests * busiest_hour_share / 3_600
print(f"average QPS : {avg_qps:,.0f}")
print(f"peak QPS    : {peak_qps:,.0f}")
print(f"peak factor : {peak_qps / avg_qps:.1f}x")

Output:

average QPS : 3,472
peak QPS    : 10,000
peak factor : 2.9x

Metro at rush hour

A metro line designed for the average number of passengers per hour would be unusable at 9 a.m. Trains, platforms and gates are sized for rush hour, and extra trains are added for big events. Servers are planned the same way.

Notifications create self-made spikes

Sending a push notification to all users at the same second can create a spike far above your normal peak. Staggering sends over several minutes is a cheap capacity fix.

त्वरित जाँच: If 10% of a day's requests arrive in the busiest hour, what is the peak-to-average factor?

  • 2.4x
  • 10x
  • 1.1x
  • 24x
Answer

2.4x — Spread evenly, each hour would carry 1/24 (about 4.2%) of traffic. 10% / 4.17% = 2.4x.