Capacity and Traffic Estimation
Back-of-the-envelope math for requests per second, peak load, storage, bandwidth, cache and server counts, with worked examples and the numbers every architect should know.
What it is
Capacity estimation uses rough arithmetic to size a system: requests per second (RPS or QPS), storage, bandwidth, memory and machine count. The goal is not precision; it is to find which numbers force an architectural decision. If peak writes are 200/s, a single PostgreSQL primary is fine. If they are 200,000/s, you need partitioning or a different store.
Use the Capacity Calculator to practise.
Numbers to remember
| Quantity | Approximate value |
|---|---|
| Seconds per day | 86,400 ≈ 10⁵ |
| 1 million requests/day | ≈ 12 RPS average |
| 1 billion requests/day | ≈ 12,000 RPS average |
| Typical peak-to-average ratio | 2× to 3× daily; 10× or more for flash sales |
| Main memory reference | ~100 ns |
| SSD random read | ~16 to 100 µs |
| Round trip within a data center / availability zone | ~0.5 ms |
| Round trip between regions on the same continent | ~20 to 80 ms |
| Round trip transatlantic | ~70 to 100 ms |
| A well-tuned app instance | hundreds to a few thousand RPS (measure it) |
| A single PostgreSQL/MySQL primary | thousands to low tens of thousands of simple writes/s, depending on hardware and schema |
| Redis single shard | ~100K simple ops/s |
| Kafka partition | tens of MB/s writes |
[!WARNING] These are orders of magnitude Hardware, payload size and query shape change these by 10×. In a real design, replace them with load-test numbers.
Worked example: a photo-sharing feed
Assumptions (stated aloud in an interview):
- 100M daily active users, each views the feed 10 times and posts 0.2 photos per day.
- Average photo 300 KB after compression, metadata 1 KB.
- Read/write ratio dominated by feed views.
| Metric | Calculation | Result |
|---|---|---|
| Writes (posts)/day | 100M × 0.2 | 20M/day ≈ 230/s avg, ~700/s peak |
| Feed reads/day | 100M × 10 | 1B/day ≈ 11,600/s avg, ~35K/s peak |
| New photo storage/day | 20M × 300 KB | 6 TB/day → ~2.2 PB/year (before replication) |
| Metadata/day | 20M × 1 KB | 20 GB/day |
| Egress for feed images | 35K/s × 10 images × 50 KB thumbnails | ~17.5 GB/s at peak → must be served by a CDN |
Design conclusions: writes are modest (single partitioned metadata store is fine); reads are high but cacheable (precomputed feeds in Redis); media is the cost driver (object storage + CDN + multiple resolutions); bandwidth makes a CDN mandatory.
flowchart LR U[100M DAU] -->|35K feed reads/s peak| CDN[CDN for images] U -->|35K/s| API[Feed API] API --> C[(Feed cache<br/>Redis)] U -->|700 posts/s peak| W[Post API] W --> M[(Metadata DB<br/>20 GB/day)] W --> S[(Object storage<br/>6 TB/day)] S --> CDN
Method
- Users × actions/day → events/day → divide by 10⁵ → average RPS.
- Multiply by peak factor; state it.
- Split reads vs writes; reads are usually cacheable, writes are not.
- Storage = events/day × size × retention × replication (+ indexes ~30%).
- Bandwidth = RPS × payload. Separate API payloads from media.
- Servers = peak RPS ÷ per-instance capacity × (1 + headroom).
- Identify the bottleneck: the number that does not fit on one machine.
Advantages and disadvantages
| Advantages | Disadvantages |
|---|---|
| Quickly rules options in or out | Easy to be off by 10× on per-node capacity |
| Shows interviewer you reason quantitatively | Can consume interview time if over-detailed |
| Basis for cost estimation | Ignores burstiness inside a second |
Technology options for real capacity planning
- Load testing: k6, Gatling, JMeter, Locust, AWS Distributed Load Testing, Azure Load Testing.
- Production telemetry: Prometheus, CloudWatch, Azure Monitor, Cloud Monitoring.
- Forecasting: time-series forecasting on historical traffic (BigQuery ML, Prophet).
Architect-level considerations
[!ARCHITECT] Estimate per tier: edge, API, database, queues, storage. The design changes where a tier crosses a single-node limit. Leave headroom for failover: if one of three zones fails, the remaining two must carry the load (size at 150% of peak per zone pair).
[!CTO] Capacity math is also cost math. Bandwidth and storage often dominate the bill for media products, not compute.
Interview questions and answers
How many servers do you need for 50,000 peak RPS?
It depends on per-instance throughput, which I'd measure. If one instance handles 1,000 RPS at acceptable latency, I need 50 at peak, plus N+1 or zone-failure headroom, say 75, behind autoscaling with a minimum sized for normal traffic.
Why do you care about peak rather than average?
Systems fail at peak. Average traffic hides daily cycles and event spikes; autoscaling also lags, so you need either pre-scaling or buffering (queues) for sudden peaks.
What usually dominates storage cost?
Media and logs. Replication, indexes and backups multiply raw size by 3× to 5×. Tiered storage and lifecycle policies are the main levers.