Guide / System design Fundamentals
1.1 Back-of-envelope estimation
The handful of numbers and the four-step method that turn 'DAU' into QPS, storage, bandwidth and cache size, with worked examples and the follow-ups interviewers ask.
Estimates exist to pick an architecture (one DB or sharded? does the cache fit in RAM? do we need a CDN?), not to be exact. Aim for the right power of ten, and say your assumptions out loud.
Fundamentals#
1.1.1 Numbers to remember#
| Number | Value |
|---|---|
| Seconds per day | ~86,400 ≈ 10^5 |
| 1M requests/day | ~12 QPS average |
| 1B requests/day | ~12K QPS average |
| Peak QPS | 2–5× average (10× for flash sales) |
| L1 cache / RAM / SSD read / same-DC round trip / cross-continent | ~1 ns / ~100 ns / ~100 µs / ~0.5 ms / ~150 ms |
| One Postgres node (well indexed) | ~5–20K simple QPS; plan to shard at TBs or sustained >10K writes/s |
| One Redis node | ~100K+ ops/s |
| One Kafka partition | ~10 MB/s; a cluster does millions of msgs/s |
| One app server (typical API) | ~1–5K req/s depending on work per request |
| Sizes | 1 char ≈ 1 byte (ASCII), tweet-like text ≈ 300 B, JSON row ≈ 1 KB, image ≈ 200 KB–2 MB, 1 min HD video ≈ 50–100 MB |
| Powers | 2^10 ≈ 10^3 (KB), 2^20 ≈ 10^6 (MB), 2^30 ≈ 10^9 (GB), 2^40 ≈ 10^12 (TB) |
| Availability | 99.9% ≈ 8.8 h downtime/year; 99.99% ≈ 53 min/year |
These are rules of thumb for interviews, not benchmarks.
1.1.2 The method#
- Traffic:
DAU × actions per user per day ÷ 86,400 = average QPS; multiply by a peak factor (2–5×). Split reads and writes. - Storage:
writes per day × bytes per record × retention days × replication factor (usually 3); add ~30% for indexes and overhead. - Bandwidth:
QPS × average response size. Ingress and egress separately. - Memory (cache): about 20% of daily hot data (80/20 rule), or
hot keys × value size. - Servers:
peak QPS ÷ QPS per server, then add headroom (target ≤ 60% utilisation) and N+1.
1.1.3 Worked examples#
A. Social feed (100M DAU, 10 reads + 1 write per user per day).
- Reads: 100M × 10 = 1B/day → ~11.5K QPS average, ~35K peak (3×).
- Writes: 100M/day → ~1.2K QPS average.
- Storage: 1 KB per write × 100M/day × 365 × 5 years ≈ 180 TB raw; ×3 replicas ≈ 550 TB → sharding is required.
- Conclusion: read-heavy (10:1), so cache + replicas + CDN; data too large for one node, so shard by user.
B. URL shortener (100M new URLs/month, 100:1 reads).
- Writes: 100M / (30 × 86,400) ≈ 40/s. Reads ≈ 4K/s average, ~12K peak.
- Storage: 500 B × 100M × 12 × 5 years ≈ 3 TB. Fits a modest sharded KV store.
- Cache: 20% of daily redirects fits in a few GB of Redis.
- Key space: 7 base62 characters = 62^7 ≈ 3.5 trillion keys, more than enough.
C. Chat (50M DAU, 40 messages sent per user per day, 100 B each).
- 2B messages/day ≈ 23K msg/s average, ~70K peak.
- Storage: 2B × 100 B ≈ 200 GB/day ≈ 73 TB/year (before replication).
- Concurrent connections: if 20% online, ~10M WebSockets; at ~100K sockets per gateway node, you need about 100 gateway nodes plus headroom.
D. Video upload (1M uploads/day, 100 MB average).
- 100 TB/day ingress ≈ 1.2 GB/s average. Transcoding to several resolutions multiplies storage 2–3×. This one is bandwidth- and storage-bound, not QPS-bound, so object storage + CDN + async pipeline.
1.1.4 Common mistakes#
- Forgetting peak vs average, or the read/write split.
- Forgetting replication (×3) and retention.
- Using precise numbers where order of magnitude is enough, and burning minutes on arithmetic.
- Estimating per second QPS but ignoring that a single hot key or tenant may receive far more than the average.
- Not stating the decision the number leads to.
Most asked questions#
1. Estimate QPS and storage for Twitter / Instagram / WhatsApp. State DAU, actions per user, record sizes, retention. Follow the method above, then the decision: “reads dominate, so cache and fan-out; storage 100s of TB so shard”.
2. How many servers do you need for 50K QPS? If one server handles about 2K req/s at 60% utilisation (~1.2K), then 50K ÷ 1.2K ≈ 42, so ~45–50 plus N+1 across zones. Say your per-server assumption explicitly.
3. How much cache memory? Daily hot data × 20%. Example: 100M users × 1 KB profile = 100 GB total; caching the hot 20% = 20 GB, which fits one Redis node but you would use a cluster for throughput and availability.
4. Is one database node enough? Compare write QPS and data size to the single-node limits in the table: if you have 1.2K writes/s and 5 TB, one well-tuned node with replicas may do for a while, but plan the sharding key.
Senior-level questions#
1. “How do you estimate when you do not know the numbers?” Anchor on known quantities (population, DAU of similar products), state assumptions, compute a range (low/high), identify which assumption the design is most sensitive to, and validate with measurements from a prototype or existing metrics.
2. “Your estimate says 3K QPS; production sees 30K at peak. What did you miss?” Peak factor and burstiness (flash sales, notifications causing synchronised opens), fan-out amplification (one user action causing 20 internal calls), retries, bots, background jobs, or a diurnal pattern concentrated in a few hours per region. Capacity must be sized from peak per region, not global average.
3. “How do estimates change the design?” Show 2–3 thresholds: under ~10K QPS and 1 TB a single replicated Postgres works; above that a cache and replicas; above ~10K writes/s or tens of TB sharding or a distributed store; above ~1 Gbps egress a CDN. Tie each threshold to a component you add.
Quiz#
1. 300M requests per day is roughly how many QPS on average?
300M ÷ 86,400 ≈ 3.5K QPS (about 12 QPS per million). With a peak factor of 3, about 10K QPS.
2. 10M users each store 2 KB of data, kept for 5 years with 3 replicas, assuming no growth. How much storage?
10M × 2 KB = 20 GB; × 3 replicas = 60 GB. (If each user generated 2 KB per day, it would be 20 GB/day × 365 × 5 × 3 ≈ 110 TB.) State which interpretation you used.
3. Why use 20% for cache sizing?
Access is skewed (80/20): the hot 20% of data typically serves most reads, so caching it yields a high hit ratio at a fraction of the memory.
4. What availability corresponds to about 53 minutes of downtime a year?
99.99% (“four nines”).
5. 7-character base62 IDs: how many unique values?
62^7 ≈ 3.5 × 10^12 (3.5 trillion).