Interview Study Guide

Guide / Revision kit

27. Cheat sheet for the night before

Created · Updated · 2 min read

Framework: clarify (5) → estimate (5) → API + data model (5) → high-level design (10) → deep dives (15) → failures + wrap-up (5). For AI rounds add: quality metric, latency/cost budget, safety boundaries.

Numbers: 1M req/day ≈ 12 QPS · peak = 2–5× · RAM ~100 ns, SSD ~100 µs, same-DC hop ~0.5 ms, cross-continent ~150 ms · Postgres node ~5–20K simple QPS · Redis ~100K ops/s · 3× replication · 1 token ≈ 4 chars · 10M × 1,536-dim float32 vectors ≈ 61 GB.

One-liners:

  • Cache: cache-aside + TTL with jitter + delete-on-write; DB first, then delete cache.
  • Stampede → single-flight lock / serve stale. Penetration → negative cache + Bloom filter. Avalanche → jitter + multi-level.
  • Idempotency: client key + unique constraint + guarded state transitions + reconciliation.
  • Exactly-once = at-least-once delivery + idempotent processing.
  • Dual write → transactional outbox. Cross-service transaction → saga with compensations.
  • Ordering → partition by entity key; sequence numbers, not wall clocks.
  • Shard key: high cardinality, even load, in most queries.
  • CAP: during a partition choose C or A, per feature. PACELC: else latency vs consistency.
  • R + W > N for quorum reads.
  • Locks for correctness need fencing tokens; prefer unique constraints and conditional updates.
  • Inventory: UPDATE ... SET qty = qty - 1 WHERE qty > 0; check affected rows.
  • Pagination: cursor/keyset, never deep offset.
  • Composite index: equality columns first, then range/sort.
  • Big aggregates: pre-aggregate on write, stream, or warehouse — never on the OLTP request path.
  • Celebrity feed: push for most, pull for celebrities.
  • WebSocket reconnect: backoff + jitter, resend last sequence number, replay or snapshot.
  • Retries: backoff + jitter, budget, only idempotent operations, DLQ.
  • RAG: retrieval decides quality — hybrid + rerank + ACL filter in the query + evals.
  • Vector DB: pgvector until scale/filters/QPS demand Qdrant/Pinecone/Milvus.
  • HNSW = best recall/latency, memory-hungry, weak on deletes and selective filters.
  • Agents only when steps aren’t known; otherwise a workflow. Cap steps, tokens, cost.
  • Prompt injection: least privilege in code, untrusted content is data, human approval for risky actions.
  • Evals gate every prompt/model change; calibrate LLM judges against humans.
  • RAG for facts, fine-tuning for behaviour.

Red flags: no requirements, no numbers, buzzword stacking, eventual consistency for money, single DB with no scaling story, ignoring failure, trusting the prompt for security.

Closing line: “If I had more time, I’d look at [the next bottleneck] and [the operational risk], and I’d measure [the metric] to validate the design.”

Finished this page?Mark it done to track your progress across the guide.
Pritam Ghosh · System design & AI engineering study notes