0% completed
Pattern Review
On This Page
- How to Use This Lesson
- Symptom → Pattern: The Diagnostic Table
- The Pattern Index
- The Decision Cheat Sheet
- Seven Threads That Run Through Everything
- The Whiteboard Checklist
1. How to Use This Lesson
This lesson provides a compact course review through one-line pattern summaries, major decisions, and a diagnostic table that maps symptoms to patterns. It does not replace the complete lessons; each summary links to the detailed walkthrough, calculations, trade-offs, and final reference card.
Three ways to use it:
- The night before an interview: read sections 2 through 5 in approximately 15 minutes, then complete one capstone actively.
- During design work: use section 2 as a lookup by finding the observed symptom and opening the linked pattern.
- As a self-test: hide the right-hand column of any table and reconstruct it from memory; review every linked lesson whose row you cannot complete accurately.
2. Symptom → Pattern: The Diagnostic Table
Every lesson began with a failing system because diagnosis requires mapping observed symptoms to known design problems; the following table summarizes those mappings.
| The symptom | Reach for |
|---|---|
| Checkout slows down whenever the analytics job runs | Primary-Replica: separate the workloads |
| The database is too big or too busy for any single machine | Sharding |
| Adding one cache node reshuffled almost every key | Consistent Hashing |
| One celebrity user, product, or tenant takes 40% of the load | The hot-key escape hatches: split, salt, dedicate, cache |
| A crash lost writes that were already acknowledged | Write-Ahead Log |
| "What was the state last Tuesday?" has no answer | Event Sourcing |
| One table serves five query shapes, all badly | CQRS: purpose-built read models |
| Users see stale data after a bulk import or manual fix | CDC: app-level invalidation misses bypass writes |
| The search index silently disagrees with the database | CDC + outbox: dual-writes tear |
| Cache entries expire together and the database spikes | Cache Stampede Prevention |
| A retry double-charged a customer | Idempotency |
| One slow dependency froze every server thread | Timeout + Circuit Breaker |
| The retries made the outage worse | Retry with Exponential Backoff: jitter and budgets |
| One poison message blocked the whole queue | Dead Letter Queue |
| Dashboards green, but one feature is starving | Bulkhead |
| The feature failed and users got a blank error page | Graceful Degradation: design the lesser answer in advance |
| A refund processed before its charge | Partitioned Consumption: key by customer |
| The producer outruns the consumer and memory climbs | Backpressure: bound, drop by policy, or slow the source |
| The answer was correct but arrived hours too late | Stream Processing |
| Finance and the dashboard report different revenue | Lambda & Kappa: the same question has two authors |
| Billing counts drift after every crash or deploy | Exactly-Once Semantics |
| Two datacenters both think they are primary | Quorum: majorities prevent split brain |
| Money must move across systems that share no database | Saga |
| Nobody can tell which service in the chain is slow | Distributed Tracing |
| A release broke everyone at once | Canary Deployment + Feature Flags |
| The model is great offline and bad in production | Feature Store: training/serving skew |
| GPUs run at 8% utilization and the bill is absurd | Model Serving & Batching |
| The traffic spike outran the ten-minute GPU boot | GPU Auto-Scaling: warm pools and calendars |
| Provider keys are scattered and one team burned $40K | LLM Gateway |
| 40% of LLM queries are rephrasings paying full price | Semantic Caching |
| The chatbot confidently serves last quarter's policy | RAG Pipeline |
3. The Pattern Index
The following index summarizes more than sixty patterns; each row identifies the problem a pattern solves and the operational or correctness cost it introduces. Hide one column to test your recall.
Module 2: Moving Data
| Pattern | Solves | Costs |
|---|---|---|
| Request-Response | Ask and wait: the default for user-facing reads | Caller's fate tied to callee's: needs Module 5 |
| Message Queue | Work nobody waits on; bursts absorbed as lag | At-least-once delivery: consumers must dedupe |
| Publish-Subscribe | One event, many independent consumers | Your event schema becomes a public contract |
| Event-Driven Architecture | Services react to facts instead of calling each other | Governance: who consumes what, and debugging flows |
| Webhooks | Push across company boundaries | Verify, persist, ack, dedupe, reconcile: all five |
| Server-Sent Events | Server streams updates over plain HTTP, auto-reconnect | One-directional only |
| Bidirectional Streaming | True two-way conversation on one connection | Sticky, stateful connections: two-tier gateways |
Module 3: Storing Data
| Pattern | Solves | Costs |
|---|---|---|
| Primary-Replica | Reads scale with copies; workloads separate | Replication lag: read-your-own-writes needs care |
| Sharding | Data too big for one machine, split by key | The key must be in every query; hot keys; cross-shard joins |
| Consistent Hashing | Nodes come and go, moving only 1/N of keys | Ring management, virtual nodes |
| Write-Ahead Log | Durability: record intent before applying | The log must trim; anything holding it back fills the disk |
| Event Sourcing | Complete history: state derived from events | The default answer is no; event schemas live forever |
| CQRS | Each query shape gets its own read model | Eventual consistency between models; rebuild machinery |
Module 4: Serving Data Fast
| Pattern | Solves | Costs |
|---|---|---|
| Cache-Aside | The default cache: app checks, loads, stores | Invalidation and staleness budgets are your job |
| Read-Through | The cache loads misses itself | A library or infra dependency in the read path |
| Write-Through | Reads always warm: cache written with the store | Every write pays double latency |
| Write-Behind | Absorb write bursts, flush later | A loss window: never for money |
| Cache Stampede Prevention | Expiry storms: single flight, jitter, early refresh | Complexity on the hottest path |
Module 5: Surviving Failure
| Pattern | Solves | Costs |
|---|---|---|
| Timeout | No wait is unbounded | Ambiguity: the work may have happened anyway |
| Retry with Exponential Backoff | Transient failures, retried politely | Needs jitter, budgets, and idempotency, or it becomes the outage |
| Idempotency | Same request twice, effect once | Keys generated at the source, honored end to end |
| Circuit Breaker | Stop calling the dead; fail fast; probe to recover | Thresholds to tune; false trips |
| Bulkhead | One workload cannot starve the rest | Capacity fragmentation |
| Dead Letter Queue | Poison messages quarantined, the queue flows | The DLQ needs an owner; ordering caveat |
| Graceful Degradation | Pre-designed lesser answers, shed by tier | Product decisions made in advance; fail open vs. closed per feature |
Module 6: Growing Under Load
| Pattern | Solves | Costs |
|---|---|---|
| Vertical Scaling | The bigger box: simplest capacity | A ceiling, and one failure domain |
| Horizontal Scaling | Many stateless copies | State must move out; per-server counters lie |
| Load Balancing | Spread work by health and actual load | Wrong signals spread wrong; draining discipline |
| Auto-Scaling | Capacity follows demand: calendar first, reactive second | Reaction lag is physics; the max is a bulkhead |
| Connection Pooling | Reuse expensive connections | Pool math multiplies across the fleet |
Module 7: Keeping Data Consistent
| Pattern | Solves | Costs |
|---|---|---|
| Two-Phase Commit | Atomic commit across participants | Blocks on coordinator failure; only within one trust boundary |
| Saga | Long transactions as local steps plus compensations | Designed undo; pivots ordered last |
| Quorum | Majority agreement: W+R>N; no split brain | Latency, and minority partitions go read-only |
| Vector Clocks | Detect concurrent edits, preserve causality | Siblings someone must merge; deletions need tombstones |
Module 8: The Entry Point
| Pattern | Solves | Costs |
|---|---|---|
| Reverse Proxy | One entry point: TLS, routing, shielding | One more hop, HA required |
| CDN | Content cached at the edge, near users | Invalidation; private data never enters shared caches |
| API Gateway | Cross-cutting policy once: auth, limits, routing | Stays thin, or becomes the monolith in disguise |
| Backend for Frontend | Per-client composition of reads | Duplication; writes stay in the domains |
| Rate Limiting | Capacity protected by tier: token bucket r/b | 429 UX; distributed counters |
| Cursor Pagination | Stable paging under live inserts | No jump-to-page-N |
| API Versioning | Change without breaking clients | Old versions supported for years: changes that cannot be undone |
| Sidecar | Cross-cutting code as a per-instance helper process | Resource overhead per instance |
| Service Mesh | Sidecars everywhere plus a control plane: mTLS, retries, telemetry | A heavy platform: clear the adoption bar first |
Module 9: Operating in Production
| Pattern | Solves | Costs |
|---|---|---|
| Health Check Endpoint | Readiness vs. liveness; deploys gated on truth | Shallow checks can be wrong |
| Distributed Tracing | The request's story across services | Instrumentation effort; sampling decisions |
| Blue-Green Deployment | Instant switch, instant rollback | The database does not blue-green: expand-contract |
| Canary Deployment | Small slice judged against a concurrent baseline | Needs real verdict metrics, or the verdict means nothing |
| Feature Flags | Deploy and release split; behavior flipped in seconds | Flag debt: delete them |
Module 10: Data-Intensive Systems
| Pattern | Solves | Costs |
|---|---|---|
| MapReduce | One big question over a huge bounded dataset | Hours-stale by construction; the shuffle dominates |
| Stream Processing | Answers while the data is still arriving: keyed state, event time, watermarks | The steepest learning curve in the course; amended answers |
| Lambda & Kappa | Batch and streaming without two drifting codebases | Overwrite machinery, or retention and replay capacity |
| Change Data Capture | Every committed change, published: cannot miss | Table schemas become contracts; slot retention watches the disk |
| Exactly-Once Semantics | Counted once despite crashes and replays | Throughput tax; the guarantee stops at external side effects |
| Backpressure | The producer outruns the consumer, by design not by outage | Someone upstream always feels it |
| Partitioned Consumption | Order per key, parallelism across keys | Partition count is a ceiling; hot partitions |
Module 11: AI-Era Systems
| Pattern | Solves | Costs |
|---|---|---|
| Feature Store | One feature definition, both training and serving | A real platform to own |
| Model Serving & Batching | GPUs filled by continuous batching: 30x economics | A TTFT floor; shared fate in the batch; buy the engine |
| GPU Auto-Scaling | Minute-long boots vs. minute-long spikes: warm pools, calendars, queue-depth signals | Deliberate idleness, priced as insurance |
| LLM Gateway | One egress door: keys, token budgets, routing, fallback sequence | Critical path; must stay thin: no prompts |
| Semantic Caching | The same question in different words, cached by meaning | False hits cost trust: conservative thresholds, audits |
| Vector DB Sharding | Similarity indexes beyond one machine's RAM | Scatter-gather economics unless a tenant filter restores the key |
| RAG Pipeline | Knowledge with freshness, citations, and access control | Retrieval sets the quality ceiling; two pipelines to run |
4. The Decision Cheat Sheet
The course's comparisons produced the following concise decision rules:
- Push vs. pull (the feed): push for most accounts and pull for high-follower accounts, using an empirically measured threshold.
- SSE vs. WebSocket: use SSE when clients do not send messages during the stream, and maintain two-way connections only when both directions are required.
- Queue vs. pub/sub: use a queue when one consumer performs each job, and pub/sub when independent consumers react to the same event.
- Cache strategy: begin with cache-aside, use read-through when its library model fits, and avoid write-behind for financial data.
- Vertical vs. horizontal: use one sufficiently large machine before accepting the operational costs of a large distributed fleet.
- 2PC vs. saga: use 2PC only within one trust boundary and sagas across boundaries; prefer ownership or one journal when either can remove the distributed transaction.
- Batch vs. streaming: let the staleness budget decide, and retain batch when it can meet the required deadline.
- Lambda vs. Kappa: maintain one metric definition, and use Kappa when log retention covers the reprocessing horizon; avoid separate pipelines without reconciliation.
- Idempotent vs. transactional sinks: begin with keyed upserts, then use transactions when outputs and offsets must advance atomically for financial records.
- Raw CDC vs. outbox: use raw table streams for internally owned infrastructure and outbox events for consumers in other teams; avoid dual-writes.
- RAG vs. fine-tuning vs. long context: use RAG for knowledge, fine-tuning for behavior, and long context for small stable corpora; these approaches can be combined.
- Own GPUs vs. provider APIs: begin with provider APIs until sustained volume, latency, or privacy requirements justify operating a GPU fleet.
5. Seven Threads That Run Through Everything
More than sixty patterns derive from a smaller set of recurring principles; reviewing these seven principles covers much of the course's reasoning.
- Skew. Hashing distributes keys but not their weights; this issue appears as hot shards, cache keys, reducers, partitions, clusters, tenants, and fee accounts. Common remedies are splitting, salting, preaggregation, dedicated capacity, and caching.
- Same question, two authors. Two implementations of the same logic eventually diverge; dual-written search indexes, separate batch and streaming metrics, and inconsistent training and serving features share this cause. Define logic once and generate or reuse it across every path.
- The log. Append-only history plus a recorded position enables durable state and replay-based recovery; this principle appears in database WALs, replication, event-sourcing journals, Kafka topics, CDC, streaming checkpoints, and agent step logs.
- Budgets: staleness and guarantees, priced per question. Determine the acceptable answer age and identify who audits its correctness; dashboards may tolerate staleness, while invoices cannot; one stream can support both through different downstream guarantees.
- Idempotency under at-least-once. Networks, frameworks, and agents all repeat operations; every external effect therefore needs a source-generated key that the sink honors, making repeated attempts harmless.
- Ownership over agreement. Assigning one matcher to a driver, one writer to an account, or one consumer to a partition can remove distributed coordination. Single ownership and short leases often replace locks and coordinators.
- Fail open vs. fail closed. Availability features may return reduced results, while financial and authorization decisions must refuse uncertain operations; in AI systems, text can degrade, but external actions must fail closed.
6. The Whiteboard Checklist
Use the five questions as a repeatable procedure for beginning any system design:
- Flow: identify which callers wait synchronously and which work should enter asynchronous queues.
- Storage: distinguish authoritative records from derived read models, caches, and indexes.
- Speed: identify the most frequent reads and define their acceptable staleness before selecting caching tiers or precomputation.
- Failure: for every dependency, define behavior when it stops responding, fails, or repeats a result; consider timeouts, retries, idempotency, breakers, and degradation.
- Growth: identify which load dimension increases first, its likely bottleneck or hot key, and the metric that triggers scaling.
Apply the three habits introduced in the first lesson throughout this procedure:
- Numbers before boxes: run the arithmetic first and use it to reject unnecessary components.
- Every pattern pays its price aloud: name the cost in the same sentence as the pattern.
- Question four wins interviews: explicit failure behavior demonstrates complete operational reasoning.
If any row differs from your expected answer, review its linked lesson; then finish with the course conclusion.
Reading Progress
0%
On This Page
- How to Use This Lesson
- Symptom → Pattern: The Diagnostic Table
- The Pattern Index
- The Decision Cheat Sheet
- Seven Threads That Run Through Everything
- The Whiteboard Checklist