One-Page Cheat Sheet
Read it the night before and again 30 minutes before the interview. Every number here is approximate — say "roughly" when you quote one, and know which page explains it.
TL;DR
- Memory ≈ 100 ns, SSD read ≈ 100 µs, same-DC round trip ≈ 0.5 ms, cross-region ≈ tens to 100+ ms.
- 1 day ≈ 10^5 s, so 1M/day ≈ 12/s and 100M/day ≈ 1,200/s; plan peaks at 2–3× (normal) or 10×+ (sales).
- 99.9% ≈ 43 min/month down, 99.99% ≈ 4.3 min/month. Serial dependencies multiply availabilities.
- Default answers: Postgres for money, Redis for hot reads/counters, Kafka for events with replay, object storage for blobs, a search engine for text, OLAP for analytics.
- At-least-once delivery + idempotent consumers is the realistic "exactly-once".
- Money: integers or decimals (never float), currency with every amount, double-entry, immutable entries, idempotency keys, daily reconciliation.
Latency numbers (rough)
| Operation | Rough time | Remember as |
|---|---|---|
| L1 cache reference | ≈ 1 ns | |
| Branch mispredict | ≈ 3–5 ns | |
| L2 cache reference | ≈ 4 ns | |
| Uncontended mutex lock/unlock | ≈ 15–25 ns | |
| Main memory reference | ≈ 100 ns | 100× L1 |
| Compress 1 KB with a fast codec | ≈ 1–3 µs | |
| Read 1 MB sequentially from memory | ≈ tens of µs | |
| NVMe SSD random 4 KB read | ≈ 20–100 µs | ≈ 1,000× memory |
| Read 1 MB sequentially from NVMe SSD | ≈ 0.2–1 ms | 1–5 GB/s |
| Round trip within one data centre / AZ | ≈ 0.1–0.5 ms | |
| Redis GET, same DC | ≈ 0.2–1 ms | network dominates |
| PostgreSQL primary-key lookup, same DC | ≈ 0.5–2 ms | |
| Cross-AZ round trip | ≈ 1–2 ms | |
| Kafka produce with acks=all, same region | ≈ 2–10 ms | |
| HDD seek / read 1 MB sequentially | ≈ 5–10 ms each | avoid on hot paths |
| Ho Chi Minh City ↔ Hanoi round trip | ≈ 15–30 ms | |
| Vietnam ↔ Singapore round trip | ≈ 20–50 ms | common cloud region |
| Asia ↔ US round trip | ≈ 150–250 ms |
Consequences: a request with 10 sequential DB calls costs ≈ 10 ms of network alone; a synchronous cross-region call in a payment path eats most of a 200 ms budget; anything on disk per request needs caching or batching.
Availability nines
| Availability | Per year | Per 30-day month | Per week | Per day |
|---|---|---|---|---|
| 99% | 3.65 days | 7.2 h | 1.68 h | 14.4 min |
| 99.9% | 8.76 h | 43.2 min | 10.1 min | 1.44 min |
| 99.95% | 4.38 h | 21.6 min | 5.04 min | 43.2 s |
| 99.99% | 52.6 min | 4.32 min | 1.01 min | 8.64 s |
| 99.999% | 5.26 min | 25.9 s | 6.05 s | 0.86 s |
- Serial (all must work): A = A1 × A2 × … → three services at 99.9% ≈ 99.7%.
- Parallel redundancy (any one works): A = 1 − (1 − A1)(1 − A2) → two independent 99% replicas ≈ 99.99%. Real failures are correlated (same AZ, same bug, same config push), so the real number is lower.
- RTO = how long to recover; RPO = how much data you may lose. Synchronous replication → RPO ≈ 0 at a latency cost. See High Availability & DR and Observability & SLOs.
Estimation shortcuts
| Fact | Value |
|---|---|
| Seconds per day | 86,400 ≈ 10^5 (use 100k, correct by ≈ 15%) |
| Seconds per month / year | ≈ 2.6M / ≈ 31.5M |
| 1M per day | ≈ 12 per second |
| 10M / 100M / 1B per day | ≈ 115 / 1,160 / 11,600 per second |
| Peak factor | 2–3× normal; 10×+ for flash sales, campaigns, payday |
| 2^10 / 2^20 / 2^30 / 2^40 | ≈ 10^3 (K) / 10^6 (M) / 10^9 (G) / 10^12 (T) |
| int64, timestamp | 8 B each |
| UUID | 16 B binary, 36 chars as text |
| Typical JSON event / API response | ≈ 0.5–2 KB |
| Product thumbnail / photo | ≈ 20–50 KB / ≈ 0.5–3 MB |
| Replication factor | 3 (plan raw storage × 3) |
QPS = requests per day / 86,400 (x peak factor)
Storage = items per day x item size x retention days x replication
Bandwidth = QPS x payload size
Cache size = hot items x item size (often 10-20% of daily working set)
Concurrency = throughput x latency (Little's law)
e.g. 2,000 req/s x 0.15 s = 300 requests in flight -> pool sizes
Servers = peak QPS / per-server QPS (measured, keep 30-50% headroom)
Very rough single-node ceilings to sanity-check (measure your own): a stateless Go API node handles thousands to tens of thousands of simple requests/s; a tuned PostgreSQL primary handles thousands to low tens of thousands of simple writes/s; a Redis node ≈ 100k+ simple ops/s; a Kafka partition ≈ tens of MB/s. See Back-of-the-Envelope Estimation.
Pattern → problem map
| Problem | Pattern | Read |
|---|---|---|
| Client retries cause duplicates | Idempotency key + unique constraint / dedup store | Idempotency |
| Write DB and publish event atomically | Transactional outbox or CDC | Outbox & CDC |
| Business transaction across services | Saga (orchestrated or choreographed), TCC | Distributed Transactions |
| Read-heavy hot data | Cache-aside + TTL + stampede protection | Caching |
| One key or account is extremely hot | Local cache, key replication, sharded counters, pull model | News Feed |
| Traffic spike beyond capacity | Queue-based load levelling, waiting room, rate limiting, load shedding | Flash Sale |
| Slow or failing dependency | Timeout + retry with jitter + circuit breaker + bulkhead | Resilience Patterns |
| Oversell on limited stock | Atomic conditional decrement, reservation with TTL | Inventory & Flash Sales |
| Lost update on one row | Atomic UPDATE, optimistic version, SELECT FOR UPDATE | Locking & Concurrency |
| Per-entity ordering | Partition by entity key (Kafka key, shard key) | Message Queues |
| Single writer / leader | Lease with fencing token, consensus store (etcd) | Distributed Locks |
| Read model differs from write model | CQRS with projections | Event-Driven Architecture |
| Full history and audit | Append-only ledger, event sourcing, audit log | Ledger Design |
| Huge, growing table | Time partitioning, archival, sharding | Partitioning in Practice |
| Full-text search, facets | Inverted index fed by CDC/events | Search Systems |
| Replace a legacy system | Strangler fig + anti-corruption layer + reconciliation | Migration Strategies |
| Long-running business process | Explicit state machine + durable workflow/timers | Order Management |
| Unknown outcome after timeout | Status query + reconciliation, never assume failure | Reconciliation |
Database choice matrix
| Need | Choose | Examples | Avoid when |
|---|---|---|---|
| ACID, relations, money, ad-hoc queries | Relational | PostgreSQL, MySQL, Oracle | Write volume beyond one primary with no natural shard key |
| Huge write throughput, key-based access, multi-DC | Wide-column / managed KV | Cassandra, ScyllaDB, DynamoDB | You need joins, ad-hoc queries or multi-row transactions |
| Flexible documents read as a whole | Document | MongoDB, Couchbase | Heavy cross-document invariants |
| Sub-ms reads, counters, rate limits, leaderboards | In-memory KV | Redis, Valkey, Memcached | It would be the only copy of important data |
| Full-text search, facets, relevance | Search engine | Elasticsearch, OpenSearch | As the system of record |
| Analytics over billions of rows | Columnar OLAP | ClickHouse, BigQuery, Druid | Point lookups and frequent updates |
| Metrics over time | Time-series | Prometheus, TimescaleDB | Business entities |
| Relationship traversal (fraud rings) | Graph | Neo4j, Neptune | Simple one-hop lookups |
| Files, images, statements, backups | Object storage | S3, GCS, MinIO | Small, frequently updated records |
| Strong consistency with horizontal scale | Distributed SQL | Spanner, CockroachDB, TiDB, YugabyteDB | Team lacks operational experience; latency budget is tight |
See NoSQL Data Modeling and Storage Engines.
Consistency choices
| Model | Guarantee | Use for | Cost |
|---|---|---|---|
| Linearizable (strong) | Every read sees the latest committed write | Balance checks, stock decrement, uniqueness | Latency; unavailable under partition (CP) |
| Serializable transactions | Transactions behave as if run one at a time | Transfers, double-booking prevention | Throughput, retries on conflict |
| Read-your-writes | A user sees their own updates | Profile edits, "my orders" after checkout | Sticky sessions or primary reads |
| Monotonic reads | No going back in time between reads | Paging through history on replicas | Session pinning |
| Causal | Effects seen after causes | Chat replies, comment threads | Tracking dependencies |
| Eventual | Replicas converge eventually | Feeds, counters, search index, analytics | Stale reads, conflict resolution |
See Consistency Models and CAP & PACELC.
Caching strategies
| Strategy | How | Strengths | Weaknesses | Use for |
|---|---|---|---|---|
| Cache-aside | App reads cache, on miss loads DB and fills | Simple, cache failure tolerated | Stale until TTL/invalidation; stampedes | Default for read-heavy data |
| Read-through | Cache library loads from DB on miss | Cleaner app code | Same staleness; library coupling | Uniform entity caches |
| Write-through | Write cache and DB together | Cache always warm | Write latency; caches cold data | Read-after-write heavy data |
| Write-behind | Write cache, flush to DB async | Fast writes, batching | Data loss on cache failure | Counters, views — never money |
| Refresh-ahead | Refresh hot keys before expiry | No miss latency on hot keys | Wasted refreshes | Predictable hot sets (home page) |
Invalidation: delete on write (don't update), short TTLs as a safety net, versioned keys for bulk changes, CDC-driven invalidation for many writers. Stampedes: singleflight, per-key lock, early probabilistic expiry, serve-stale-while-revalidate. Never use a cache to authorise money movement — check balances and stock at the source.
Messaging semantics
| Semantics | How | Risk | Use for |
|---|---|---|---|
| At-most-once | Commit/ack before processing; fire-and-forget | Loss | Metrics, typing indicators, best-effort analytics |
| At-least-once | Process, then commit/ack; retry on failure | Duplicates | Almost all business events — with idempotent consumers |
| Effectively-once | Idempotent producer + transactions (Kafka) inside the pipeline, or at-least-once + dedup at the sink | Complexity; boundary ends at external systems | Ledger postings, financial aggregates |
- Ordering is guaranteed only per partition / per key. Choose the key (account ID, order ID) deliberately.
- Plan for poison messages (DLQ after N attempts), consumer lag alerts, retention for replay, and schema evolution (registry, backward-compatible changes).
| Kafka | RabbitMQ | SQS | |
|---|---|---|---|
| Model | Partitioned log, consumers track offsets | Broker queues, routing via exchanges | Managed queue |
| Replay | Yes, within retention | No (once acked) | No |
| Ordering | Per partition | Per queue (single consumer) | FIFO queues only |
| Strength | Throughput, replay, stream processing | Flexible routing, per-message TTL/priority | Zero ops |
Money handling rules
- Never use floating point. Use integer minor units (
int64) or fixed-precision decimals (NUMERIC(19,4)); in Go,int64or a decimal library. - Store the currency with every amount (ISO 4217). VND has 0 minor units in ISO 4217, USD 2, KWD 3 — don't hard-code 2.
- Round once, by a stated rule (half-up vs banker's rounding), at a defined step; allocate remainders explicitly (100,000₫ split three ways = 33,334 + 33,333 + 33,333).
- Double-entry: every movement has debits equal to credits; balances derive from entries.
- Immutable entries: correct with reversal/adjustment entries, never
UPDATE/DELETE. - Idempotency on every money-moving call, with a unique constraint on the business reference.
- A timeout is "unknown", not "failed". Query status, then reconcile; never blindly retry a payout.
- Reconcile with every external party (switch, PSP, partner bank) daily and ideally intraday.
- Holds vs postings: authorisation reserves (available balance), capture/settlement posts (ledger balance).
- Time: store UTC, display
Asia/Ho_Chi_Minh; business date and cut-off times differ from calendar date. - Audit: who, what, when, why for every change; four-eyes approval for manual adjustments.
- FX: store rate, source and timestamp with each conversion.
See Double-Entry Ledger Design and Schema Patterns: Money, Audit, Multi-tenancy.
LLM feature design checklist
- Does it need an LLM? Rules, search or a form may be cheaper, faster and auditable.
- Non-AI fallback. The feature degrades; checkout, payments and transfers never depend on a model call.
- Facts from systems of record, not from the model or stale documents: rates, fees, balances, stock come from tools/APIs, cited and timestamped.
- Retrieval respects entitlements: filter by the caller's ACL before ranking, never after generation.
- Untrusted text is data, not instructions: memos, reviews, emails, tickets, web pages. Break the lethal trifecta (private data + untrusted input + a way out).
- Side effects are proposals: the model drafts, the user confirms (strong authentication for money); tools are narrow, scoped to the user, idempotent.
- Structured output validated against a schema; bounded retries; never execute or render raw output.
- Gateway: timeouts, fallback on retryable errors only, per-tenant token budgets, cost attribution, PII redaction.
- Evals as a release gate: golden set + red-team set; re-run on every prompt, model or retrieval change.
- Trace and audit every step (prompt/model version, retrieved docs, tool calls) without logging card data or secrets.
See LLM Application Architecture and LLM Security, Privacy & Governance.
Reference diagrams
1. Baseline scalable service
2. Outbox + CDC event flow
3. Checkout saga (orchestrated)
4. Multi-region active-passive
5. Admission control for a traffic spike
Self-check
1. A request makes 8 sequential calls to a database in another AZ. Rough network cost?
≈ 1–2 ms per cross-AZ round trip × 8 ≈ 8–16 ms before any query time. Fix with batching, fewer round trips, or co-locating the service with the primary.
2. Three serial services at 99.95% each, behind a load balancer at 99.99%. Overall availability?
0.9995³ × 0.9999 ≈ 0.9984 → ≈ 99.84%, or roughly 70 minutes of downtime per month. Serial dependencies erode availability quickly — hence caching, async paths and graceful degradation.
3. 30M orders/day, 2 KB each, kept 5 years with 3× replication. Storage?
30M × 2 KB = 60 GB/day; × 365 × 5 ≈ 110 TB; × 3 ≈ 330 TB. The order of magnitude says time partitioning plus archival of old orders to cheaper storage.
Related
- System Design Interview Framework — where these numbers are used.
- Back-of-the-Envelope Estimation — estimation in depth.
- Question Bank — test yourself on each row.
- Quality Attributes & Trade-off Analysis — turning nines into requirements.
- Data Structures Inside Real Systems — the structures behind these components.
Do the self-check first. Marking it complete schedules spaced reviews (1, 3, 7, 14, 30… days).