Skip to content
AI360Xpert

QPS/Bandwidth Estimation

QPS/Bandwidth Estimation architecture
QPS/Bandwidth Estimation architecture

Overview

Queries Per Second (QPS) and Bandwidth estimations determine the network and compute capacity your system requires. QPS dictates how many load balancers, app servers, and database connections you need. Bandwidth dictates your network costs and whether you require a Content Delivery Network (CDN).

🧠 Mental model: QPS is the number of cars passing through a tollbooth every second (compute load). Bandwidth is the combined weight of the cargo in those cars (network load). A million motorcycles (high QPS, low bandwidth) stress the system differently than ten massive freight trucks (low QPS, high bandwidth).

Key Concepts

QPS (Queries Per Second)

To calculate QPS, divide the total daily requests by 100,000 (roughly the number of seconds in a day: 86,400).

  • Average QPS: Daily Requests / 100,000
  • Peak QPS: Traffic is never perfectly uniform. Assume peak traffic is 2x to 5x the average. Peak QPS = Average QPS * 2.
  • Read vs. Write QPS: Always separate these. Social media apps are read-heavy (100:1 ratio). IoT logging apps are write-heavy. This dictates your caching and database replication strategy.

Bandwidth

Bandwidth is measured in Bytes per second (or Mbps/Gbps). Multiply the QPS by the average size of the request/response payload.

Example: YouTube Clone (Video viewing)

Assumptions: 10 million DAU. Users watch 5 videos a day. Average video size is 50 MB.

  • Daily views: 10M * 5 = 50 million views/day
  • Average QPS: 50M / 100,000 = 500 QPS
  • Peak QPS: 500 * 2 = 1,000 QPS
  • Egress Bandwidth: 500 QPS * 50 MB = 25,000 MB/sec = 25 GB/sec

Architectural conclusion: 500 QPS is trivial for modern app servers (a few Node.js or Go servers can handle it easily). However, 25 GB/sec of egress bandwidth is massive and expensive. We must use a CDN to cache videos at the edge to offload our origin network.

Trade-offs

Designing for Peak QPS ensures reliability but leaves resources idle during off-peak hours (costing money). The tradeoff is managed using Auto-scaling groups to dynamically match capacity to QPS. High bandwidth systems trade raw egress costs for CDN costs; CDNs are almost always cheaper for static media, but require complex cache-invalidation strategies.

Interview Tips

  • Always calculate Average QPS and Peak QPS.
  • Always establish the Read-to-Write ratio before doing QPS math.
  • If bandwidth is high (GB/sec), immediately suggest a CDN. If write QPS is high (10,000+), suggest message queues (Kafka) to buffer the load. If read QPS is high, suggest caching (Redis).

Summary

  • QPS determines compute capacity; Bandwidth determines network capacity.
  • Divide daily requests by 100,000 to easily estimate Average QPS.
  • Peak QPS is usually estimated at 2x to 5x of Average QPS.
  • Always separate Read QPS from Write QPS, as they require different architectural solutions.
  • High bandwidth requirements strongly indicate the need for a CDN.