SysDesignAtlas

The Cheat Sheet

Every number, comparison table, and decision heuristic worth having in working memory — the page to review the morning of the interview.

HLDEasy8 min readreferencenumberscheatsheet
Confidence

#Latency numbers

OperationTime
L1 cache reference1 ns
Main memory reference100 ns
Compress 1 KB2 µs
Read 1 MB from memory10 µs
SSD random read100 µs
Read 1 MB from SSD200 µs
Round trip within a datacenter500 µs
Read 1 MB from disk (HDD)2 ms
Disk seek (HDD)5 ms
US East ↔ US West RTT~60 ms
US ↔ Europe RTT~100 ms
US ↔ Asia RTT~180 ms

The three derived facts: memory is ~1,000× faster than SSD; a same-DC round trip costs more than reading 1 MB from memory (so chatty services are expensive); and cross-continent latency is bounded by physics — only moving data closer helps.

#Estimation shortcuts

Two abbreviations used throughout: QPS is queries per second, and DAU is daily active users.

   1 day ≈ 10⁵ seconds        (86,400, round it)
   1 month ≈ 2.6 × 10⁶ s
   1 year ≈ 3 × 10⁷ s

   QPS = DAU × actions_per_day / 10⁵
       → "multiply, then drop five zeros"

   Peak = average × 3          (default; 10× for event spikes)
DAUActions/dayAvg QPS
1M10100
10M101,000
100M1010,000
100M100100,000
1B10100,000

#Object sizes

ItemSize
64-bit ID / UUID8 B / 16 B
Short text post~300 B
Typical DB row~1 KB
Chat message~1 KB
Compressed web page~50–100 KB
Thumbnail~10 KB
Web-optimized photo~200 KB–2 MB
1 min of 1080p video~30 MB
1 hour of 1080p video~2 GB

#Single-machine capacities

ResourceOrder of magnitude
RAM per server64–512 GB
SSD throughput0.5–2 GB/s
Network interface10 Gbps ≈ 1.2 GB/s
Postgres/MySQL writes10–50K/s
Redis operations~100K/s per core
Kafka broker100 MB/s – 1 GB/s
Web server (JSON)5–20K QPS
WebSocket connections~100K–1M per node

Storage multipliers: ×3 for replication, ×1.3 for index overhead, plus backups.

#Availability

NinesDowntime/yearDowntime/month
99%3.65 days7.2 h
99.9%8.8 h43.8 min
99.99%52.6 min4.4 min
99.999%5.3 min26 s
   Serial dependencies MULTIPLY:   0.999⁵ = 99.5%
   Parallel redundancy ADDS nines: 1 − (1−0.99)³ = 99.9999%

   Availability = MTBF / (MTBF + MTTR)
   → halving MTTR is usually far cheaper than halving failures

MTBF is mean time between failures; MTTR is mean time to repair (how long each outage lasts).

#Decision tables

#Database

NeedChoose
Multi-row ACID transactionsRelational (Postgres)
Point lookups by key, extreme scaleKey-value (DynamoDB, Redis)
Flexible schema, nested documentsDocument (MongoDB)
Write-heavy, time-ordered, known queriesWide-column (Cassandra)
Multi-hop relationship traversalGraph (Neo4j)
Aggregations over huge scansColumnar (ClickHouse, BigQuery)
Full-text relevance rankingSearch (Elasticsearch)
Large binariesObject storage (S3) + metadata in a DB

Default answer: Postgres. Revisit past ~30K writes/s or when the working set outgrows RAM.

#Caching

TTL — time to live — is the expiry stamped on a cache entry. Jitter means randomising it slightly per key, so entries written together don't all expire together.

ProblemFix
Popular key expires, herd hits DBRequest coalescing, probabilistic early refresh, TTL jitter
Requests for nonexistent keysCache negatives; Bloom filter
Mass expiry / cache node lossTTL jitter, replication, gradual warm-up
One key saturates a nodeStore copies under suffixed names (key#1…key#8) and read a random one; local in-process cache

Write strategy: cache-aside by default. On write, delete the key rather than updating it. Every entry gets a TTL as a safety net.

#Consistency

DataModel
Balance before a transferLinearizable
Seat/ticket assignmentLinearizable
Username uniquenessLinearizable
A user's own editsRead-your-writes
Comment threadsCausal
Feed timelineEventual + monotonic reads
Like/view countsEventual
Search indexEventual

Pick per operation, never per system.

#Rate limiting

NeedAlgorithm
Daily/monthly quotaFixed window
Exact small limits (logins)Sliding window log
General API limitingSliding window counter
Allow bursts, cap averageToken bucket
Protect a burst-intolerant downstreamLeaky bucket

#Messaging

NeedChoose
Replay, multiple consumers, high throughputLog (Kafka)
Complex routing, priority, per-message TTLBroker (RabbitMQ, SQS)
Caller needs the result nowDirect synchronous call

Delivery: at-least-once + idempotent consumers. Exactly-once delivery doesn't exist across systems.

#API style

ConsumerChoose
Public / third-partyREST
Internal service-to-servicegRPC
Mobile/rich clients, diverse data needsGraphQL

#Sharding

Choosing a key: high cardinality · even distribution · present in most queries · keeps co-read data together.

SystemKey
Chatconversation_id (not user_id)
Social postsuser_id
Orderscustomer_id
Multi-tenant SaaStenant_id
Time series(metric_id, time_bucket)

Always pre-split into virtual shards (e.g. 1,024 logical shards spread over a few machines). Adding a machine then means moving some whole virtual shards and updating the lookup table of which machine holds which — not rehashing and moving every key.

#Resilience checklist

Every remote call needs all four:

  1. Timeout (with deadline propagation — pass the remaining time budget downstream so later calls don't keep working on a request the caller has already abandoned)
  2. Retry — exponential backoff + jitter, at one layer only (retries stacked at every layer multiply), with a budget (e.g. retries capped at 10% of traffic)
  3. Circuit breaker with a fallback
  4. Idempotency key for anything that mutates

Plus: bounded queues everywhere, bulkheads per dependency (a separate connection or thread pool for each, so one slow dependency can't use up all of them), load shedding by priority, 60–70% target utilization.

#Phrases that score

"The alternative would be X, but Y decided it."

"The obvious problem with this is Z — let me handle it."

"I'd start with the simple version. Here's the threshold at which I'd revisit."

"I've not operated that myself; my mental model is X, but I'd be guessing past that."

"That number tells me we need to shard / need a CDN / can stay on one box."

"Under overload I'd shed low-priority traffic rather than queue everything."

"This is eventually consistent, which is fine here because [reason] — but the user's own writes need read-your-writes."

#The 60-second pre-interview reset

  1. 1 Restate & cut scope Out loud, and invite redirection.
  2. 2 Ask the four questions Scale? Read:write ratio? Latency target? Consistency needs?
  3. 3 Estimate what decides something End every calculation with its conclusion.
  4. 4 API, then data model Finish with the partition key and its justification.
  5. 5 Draw and narrate Label every arrow. Walk one request end to end.
  6. 6 Volunteer the flaw Then go deep on it before you're pushed.
  7. 7 Close deliberately Bottleneck at 10×, failure mode, v1 cut, what you'd monitor.
The 60-second reset — read this on the way into the room.

#Check yourself

Recite the key latency numbers.Show answer
L1 1 ns, memory 100 ns, 1 MB from memory 10 µs, SSD random read 100 µs, same-datacenter round trip 500 µs, HDD seek 5 ms, US–Europe ~100 ms.
What are the estimation shortcuts?Show answer
A day ≈ 10⁵ s, a year ≈ 3 × 10⁷ s; QPS = DAU × actions ÷ 10⁵; peak ≈ 3× average (10× for events). 100M DAU × 10 actions ≈ 10,000 QPS.
Give rough single-machine capacities.Show answer
RAM 64–512 GB, SSD 0.5–2 GB/s, 10 Gbps NIC ≈ 1.2 GB/s, Postgres 10–50K writes/s, Redis ~100K ops/s per core, web server 5–20K QPS, 100K–1M WebSockets per node.
How do availability numbers compose?Show answer
Serial dependencies multiply (0.999⁵ ≈ 99.5%); parallel redundancy adds nines (1 − 0.01³ = 99.9999%); availability = MTBF ÷ (MTBF + MTTR), so cutting MTTR is usually cheapest.
What is the default database and when do you revisit it?Show answer
Postgres — revisit past ~30K writes/s or when the working set outgrows RAM. Wide-column for write-heavy time-ordered data, columnar for big scans, object storage for binaries.
What are the cache-problem fixes?Show answer
Stampede: coalescing, early refresh, TTL jitter. Missing keys: cache negatives or a Bloom filter. Mass expiry: jitter and warm-up. Hot key: replicate with suffixes plus a local cache.
What four things does every remote call need?Show answer
A timeout with deadline propagation, retries with backoff and jitter at one layer with a budget, a circuit breaker with fallback, and an idempotency key for mutations.
How do you pick a shard key?Show answer
High cardinality, even distribution, present in most queries, keeps co-read data together — conversation_id for chat, user_id for posts, tenant_id for SaaS — with ~1,024 pre-split virtual shards.

#What to carry forward

  • Know the latency ladder and the 10⁵-seconds-per-day shortcut.
  • Serial dependencies multiply failure; redundancy adds nines.
  • Default to Postgres, cache-aside with delete-on-write, consistency chosen per operation.
  • Every remote call: timeout, retry with jitter, breaker, idempotency key.
  • Use the scoring phrases, and run the 60-second reset before the interview.
00:00
/ 8m