System Design

#Numbers to know

The card to review the morning of the interview. Nothing here is derivable under pressure; all of it makes the estimation phase fast.


#1 · Latency

OperationTimeRatio to the one above
L1 cache reference1 ns—
Branch mispredict3 ns3×
L2 cache reference4 ns—
Mutex lock/unlock17 ns—
Main memory reference100 ns100× L1
Compress 1 KB (Snappy)2 µs—
Send 1 KB over 1 Gbps10 µs—
SSD random read100 µs1,000× memory
Read 1 MB sequentially from memory250 µs—
Datacentre round trip500 µs—
Read 1 MB sequentially from SSD1 ms—
Disk seek (spinning)10 ms100× SSD
Read 1 MB from disk20 ms—
US ↔ Europe round trip150 msPhysics

The three ratios that actually matter:

memory : SSD        = 1 : 1,000       -> why you cache
SSD    : disk seek  = 1 : 100         -> why SSDs changed database design
DC hop : intercontinental = 1 : 300   -> why you use a CDN, and why
                                         multi-region writes are hard

Interactive simulation — needs JavaScript.


#2 · Capacity per commodity machine

ComponentCapacity
Web/app server10k–50k QPS (simple requests)
SQL database writes5k–10k/s per primary
SQL database reads10k–50k/s (more with replicas)
Redis / Memcached~100k QPS per node
Kafka broker~100k messages/s
Nginx / Envoy~50k–100k connections
WebSocket connections10k–50k per server
Server RAM64–256 GB
Server SSD1–10 TB
NIC10–25 Gbps

The 5k–10k writes per primary figure earns its keep more than any other. It is the number that decides "one database" versus "shard", and being able to apply it instantly turns a guess into a justified decision.


#3 · Sizes

ItemSize
ASCII character1 byte
Unicode character (UTF-8)1–4 bytes
Integer / timestamp4–8 bytes
UUID16 bytes
Typical database row~1 KB
Tweet with metadata~1 KB
Compressed web page~100 KB
Photo (compressed)~1 MB
Photo (thumbnail)~10–200 KB
Minute of 1080p video~50 MB
Minute of 4K video~200 MB

Powers of two:

Power≈Unit
2¹⁰1 thousandKB
2²⁰1 millionMB
2³⁰1 billionGB
2⁴⁰1 trillionTB
2³²4.3 billionWhy 32-bit IDs run out
2⁶⁴1.8 × 10¹⁹Why 64-bit ones do not

#4 · Time conversions

Use 100,000 seconds per day. (Real: 86,400. Error: 16%. Worth it.)

Per day≈ QPS
1 million10
10 million100
100 million1,000 ← anchor
1 billion10,000
10 billion100,000
IntervalSeconds
Minute60
Hour3,600
Day86,400 (~100k)
Month2.6M
Year31.5M (~30M)

Peak = 2–3× average. Global services 2×; single-timezone 3×.


#5 · Availability

SLADowntime/year/month/week
99%3.65 days7.2 h1.7 h
99.9% ("three nines")8.8 h43 min10 min
99.95%4.4 h22 min5 min
99.99% ("four nines")53 min4.3 min1 min
99.999% ("five nines")5.3 min26 s6 s
SERIES (dependencies):    0.999^3 = 99.7%     -- each one costs you
PARALLEL (redundancy):    1 - 0.01^2 = 99.99% -- IF independent

Correlated failure is why the parallel number is optimistic — shared racks, shared control planes, shared deploy pipelines.


#6 · Cost, order of magnitude

ResourceRough monthly cost
Object storage$20–25 / TB
Block storage (SSD)$80–100 / TB
Database storage (managed)$100–200 / TB
Cloud egress$50–90 / TB ← usually dominates
CDN egress$10–40 / TB
App server (4 vCPU, 16 GB)$100–150
Cache node (32 GB)$200–400

Egress is the line item that surprises people. For any media-serving system, bandwidth cost typically exceeds compute and storage combined — which is why the CDN and serving correctly-sized variants are architectural decisions, not optimisations.


#7 · Ratios and rules of thumb

RuleValue
Read:write, social/content100:1 to 1000:1
Cache hit rate, well-designed90–99%
Hot data (the 80/20 rule)20% of data = 80% of traffic
Compression ratio, text3–5×
Compression ratio, JSON5–10×
Index storage overhead10–30% of table size
Replication factor3 (2 for cheap, 5 for critical)
Peak:average traffic2–3×
Bloom filter~10 bits/element for ~1% false positives

#8 · The 60-second estimation script

1. DAU x actions/day        = actions/day
2. / 100,000                = average QPS
3. x 2-3                    = peak QPS
4. writes/day x bytes x 365 x 3   = storage/year
5. peak QPS / 10,000        = app servers (then round UP for headroom)
6. hot data x entry size    = cache RAM

7. CONCLUDE. "So this needs / does not need X."

Step 7 is the only one being scored. An estimate that changes no decision was wasted time.


#9 · Sanity checks

If your answer looks like one of these, recheck:

ResultLikely error
> 1 PB/day of textDropped a factor of 1,000
> 1M QPS for a normal appConfused per-day with per-second
A single server at 500k QPSOff by 10×
Storage without replicationForgot the ×3
Provisioning for average loadForgot peak
More cache RAM than total dataCaching everything, including cold

Catching your own error out loud is a positive signal, not a negative one. "That gives 200 TB a day, which is more than YouTube — let me recheck" reads as someone with calibrated intuition.