The seven-step estimate for any design question: DAU to QPS, peak, read:write, storage, bandwidth, cache memory, then a sanity check against one machine.
The problem
The interviewer says "design X for 100 M users" and wants to see whether you can turn that into numbers that drive decisions: one box or a cluster, SQL or sharded store, cache or no cache. The goal is not a precise answer but a defensible order of magnitude, reached by explicit assumptions and round numbers.
How it works
- Step 1, traffic: state users, then DAU (often 10-30% of MAU unless told), then actions per user per day. Total requests/day = DAU × actions.
- Step 2, QPS: average QPS = requests per day ÷ 86,400 (round to 10^5). Peak QPS = average × a factor you state out loud, typically 2-5 (×3 is a fine default; use more for spiky events like sales or live matches).
- Step 3, read:write ratio: social feeds and URL redirects are read-heavy (10:1 to 100:1 or more); logging and metrics ingestion are write-heavy. Derive read QPS and write QPS separately, because they scale differently.
- Step 4, storage: records/day × bytes per record × retention days × replication factor (usually 3), plus 20-50% for indexes and growth. Do blobs (images, video) and metadata separately.
- Step 5, bandwidth: QPS × payload size, for ingress and egress separately. Egress is usually reads × response size and dominates; convert bytes to bits (×8) before comparing with NIC speeds.
- Step 6, cache memory: working set per day × hot fraction (the 80/20 rule: cache the hottest ~20% to serve most reads). Check it fits in RAM of a handful of nodes.
- Step 7, sanity check: compare peak QPS with what one node can do (thousands to tens of thousands of simple QPS for a DB or app server, order of magnitude). Nodes ≈ peak QPS ÷ per-node QPS ÷ target utilization (0.5-0.7). Take the larger of the QPS-driven and storage-driven shard counts.
- Worked example, traffic: DAU 10 M × 10 requests/day = 10^8/day; 10^8 ÷ 86,400 ≈ 1,160 QPS average (≈1.2K); ×3 peak ≈ 3,500 QPS (≈3.6K if you round to 1.2K first). One decent node handles this, so you shard for storage or availability, not QPS.
- Worked example, storage: 100 M users × 1 KB profile = 100 GB, fits on one disk; with 3 replicas 300 GB. 10 M new 1 KB posts/day × 365 × 3 replicas ≈ 11 TB/year, which is when sharding starts to matter.
Examples
import "fmt"
const secondsPerDay = 86_400
// Assumptions are explicit fields: change one, re-run, and the answer moves.
type Assumptions struct {
DAU float64 // daily active users
ActionsPerUser float64 // requests per user per day
PeakFactor float64 // peak QPS / average QPS, usually 2-5
WritesPerAction float64 // records stored per action
RecordBytes float64 // bytes per record
RetentionDays float64 // how long data is kept
ReplicationCount float64 // physical copies, typically 3
}
type Estimate struct {
AvgQPS float64
PeakQPS float64
StorageBytes float64
}
func avgQPS(perDay float64) float64 {
return perDay / secondsPerDay
}
func peakQPS(avg, factor float64) float64 {
return avg * factor
}
func storageBytes(recordsPerDay, recordBytes, days, replicas float64) float64 {
return recordsPerDay * recordBytes * days * replicas
}
func estimate(a Assumptions) Estimate {
perDay := a.DAU * a.ActionsPerUser
avg := avgQPS(perDay)
return Estimate{
AvgQPS: avg,
PeakQPS: peakQPS(avg, a.PeakFactor),
StorageBytes: storageBytes(perDay*a.WritesPerAction, a.RecordBytes, a.RetentionDays, a.ReplicationCount),
}
}
var examples = []struct {
name string
in Assumptions
}{
{"qps-example", Assumptions{DAU: 10e6, ActionsPerUser: 10, PeakFactor: 3}},
{"posts-1y", Assumptions{DAU: 10e6, ActionsPerUser: 1, PeakFactor: 3, WritesPerAction: 1, RecordBytes: 1000, RetentionDays: 365, ReplicationCount: 3}},
}
func report() []string {
var out []string
for _, ex := range examples {
e := estimate(ex.in)
out = append(out, fmt.Sprintf("%s: avg=%.0f peak=%.0f storage=%.1fTB", ex.name, e.AvgQPS, e.PeakQPS, e.StorageBytes/1e12))
}
return out
}The worked examples as integer shell arithmetic (no bc needed).
#!/usr/bin/env bash
set -eu
# Example 1: DAU 10 M, 10 requests/user/day
dau=10000000
per_user=10
per_day=$((dau * per_user)) # 100,000,000 requests/day
avg=$((per_day / 86400)) # 1157 QPS, say ~1.2K
peak=$((avg * 3)) # 3471 QPS, say ~3.5K (x3 assumed)
echo "avg=${avg} QPS peak=${peak} QPS"
# Example 2: 100 M users x 1 KB each
users=100000000
bytes_each=1000
gb=$((users * bytes_each / 1000000000))
echo "profile storage=${gb} GB"
# Example 3: 10 M posts/day x 1 KB x 365 days x 3 replicas
gb=$((10000000 * 1000 * 365 * 3 / 1000000000)) # 10950 GB
echo "posts for one year, replicated: ${gb} GB (~11 TB)"In practice
- Interview tip: say assumptions out loud — Write each assumption on the board ("DAU 10 M, 10 requests each, peak ×3") so the interviewer can correct it early; a wrong assumption stated is cheap, a silent one is fatal.
- Interview tip: round aggressively — Use 86,400 ≈ 10^5, 1 KB = 1,000 B, 1 year ≈ 3×10^7 s. Being within 2× is enough, and clean numbers make the arithmetic visible and fast.
- Interview tip: think in powers of ten — Compare to thresholds, not exact values: ~10^3 QPS is one node, ~10^5 needs a cluster or cache, ~10^2 GB fits in RAM, ~10^1 TB needs sharding. Stop estimating as soon as the decision is clear.
- Interview tip: tie numbers to a decision — End each estimate with "so we need ..." (a cache, 10 shards, a CDN). Numbers that change nothing in the design are noise; skip them.
Trade-offs
Pros
- Turns a vague prompt into numbers that justify each component
- Cheap: five minutes of arithmetic avoids over- or under-engineering
- Explicit assumptions make the discussion collaborative
Cons
- Garbage in, garbage out: the DAU, ratio and payload guesses dominate the result
- Averages hide hot keys, bursts and fan-out, so peak and skew still need a design answer
- Over-precise arithmetic wastes interview time