0% completed
Pattern Review
On This Page
How to Use This Review
From Symptom to Pattern
The Pattern Index: 62 Patterns by Module
Moving Data
Storing Data
Serving Data Fast
Surviving Failure
Growing Under Load
Keeping Data Consistent
The Entry Point
Operating in Production
Data-Intensive Systems
AI-Era Systems
The Decision Guide: Choosing Between Neighbors
The Seven Principles
Using the Review in an Interview
Check Yourself
Checkout's 200 threads are all busy, and buyers cannot update their carts. The error rate is 0 percent, and every circuit breaker is closed. The only change is in fulfillment, which now answers in 900 ms instead of 50 ms. 900 ms is under its 1,000 ms timeout, so every call succeeds. Which pattern fixes this?
The answer is Bulkhead. Checkout places 200 orders per second, and each now holds a thread for 1.1 seconds. Page loads and carts need 25 more threads. So checkout needs 200 × 1.1 + 25 = 245 threads, but it has 200.
A timeout cannot help, because no call reaches its limit. A breaker cannot help, because nothing fails. A bulkhead allows only 20 fulfillment calls at once. The rest of the pool stays free, and only 85 threads are busy.
Most design questions work this way. You see a symptom, and you must name the pattern that answers it and say what it costs. This lesson is a reference for that step, in four parts: a symptom table, a one-line index of all 62 patterns, a decision guide for neighboring patterns, and the seven principles of the four designs.
How to Use This Review
Read the symptom table first, and open the lesson for any row you cannot explain. Use the index to test yourself: cover the last two columns and say what each pattern solves and costs.
The examples come from this module's designs. The News Feed is read-heavy, and Ride-Sharing Dispatch changes its state every 4 seconds. The Payment Platform must never lose or repeat money. The AI Copilot runs slow, costly steps that are not safe to repeat.
From Symptom to Pattern
Each row starts with what you observe. The last column shows where the symptom appeared.
| Symptom | Pattern | Seen in |
|---|---|---|
| The caller waits for work it does not need to see finished | Message Queue | Feed: "posted" in 100 ms, fan-out later |
| Several teams need the same fact | Publish-Subscribe | Payment: ledger and webhooks read one stream |
| A retry charges a buyer twice | Idempotency | Payment: key 1042 makes one pay_7310 |
| A dependency that never answers holds every thread | Timeout | Payment: no answer in 2 s means "unknown" |
| A down dependency is called again and again | Circuit Breaker | Copilot: the carrier API fails fast |
| Slow calls that succeed stop all other work | Bulkhead | Store: the checkout example above |
| One message fails on every attempt | Dead Letter Queue | Store: order 3907 with no address |
| One optional part turns a page into an error | Graceful Degradation | Feed: large lists skipped after 30 ms |
| Reads exceed one database | Primary-Replica, Cache-Aside | Feed: posts from the post cache |
| Data or writes exceed one machine | Sharding | Feed: 800 GB on 16 shards |
| Two writers change one key at once | One owner, as in Design 2, Ride-Sharing Dispatch | Dispatch: server 5 applies claims for d_7731 in order |
| A change across services stops halfway | Saga | Payment: a rejected payout gets a new entry |
| One caller uses everyone's capacity | Rate Limiting | Payment: 1,200 charges per second |
| A release breaks some requests | Canary Deployment | Copilot: 5 percent of conversations first |
| Indexes miss changes made outside the app | Change Data Capture | Copilot: help page edits reach the index |
| Reworded questions pay for new answers | Semantic Caching | Copilot: 25 percent from the cache |
Some symptoms match two rows. A slow card network needs a timeout first, and a breaker only if it stays down.
The Pattern Index: 62 Patterns by Module
Each line gives what the pattern solves and what it costs. The modules are grouped under the Five Questions of the course.
Read the columns in the order of the five questions. Each card is one module with its number of patterns. The peach band is the AI-era module, which uses all five questions.
Moving Data
| Pattern | Solves | Costs |
|---|---|---|
| Request-Response | The caller needs the answer to continue | Waiting, and waits add up along a chain |
| Message Queue | The producer continues once work is stored | At-least-once delivery, a backlog to watch |
| Publish-Subscribe | One fact, a copy for each subscriber | A schema contract, an outbox, duplicates |
| Event-Driven Architecture | Services react to facts, not calls | Briefly stale copies, hidden dependencies |
| Webhooks | Another company reports events, no polling | Any order, at least once, signatures |
| Server-Sent Events | The server pushes on one open response | Open connections, no proxy buffering |
| Bidirectional Streaming | Both sides send often on one connection | State on one gateway node, resume logic |
Storing Data
| Pattern | Solves | Costs |
|---|---|---|
| Primary-Replica | Read capacity and a failover copy | About 50 ms of lag, a write pause on failover |
| Sharding | Writes and data beyond one machine | Key-less queries hit every shard, hot keys |
| Consistent Hashing | A new machine takes about 1 ÷ N of keys | Virtual nodes to keep slices even |
| Write-Ahead Log | A confirmed write survives a crash | An fsync per commit, log kept for slow readers |
| Event Sourcing | Full history, state by replay | Permanent schemas, eventual consistency |
| CQRS | Read models per query, 5 ms not 300 ms | About 200 ms of lag, projectors to run |
Serving Data Fast
| Pattern | Solves | Costs |
|---|---|---|
| Cache-Aside | 99 percent hits: 12,000 reads become 120 | Stale entries, delete on write, a TTL |
| Read-Through | One loader per key type, merged misses | A library in the read path |
| Write-Through | The next read sees the write | Each write waits on two systems |
| Write-Behind | Many writes become few | Can lose 2 seconds of writes, never money |
| Cache Stampede Prevention | One rebuild, not 600 queries | Locks, serving old values, early refresh |
Surviving Failure
| Pattern | Solves | Costs |
|---|---|---|
| Timeout | A callee that never answers holds a known number of threads | A timed-out write has an unknown result |
| Retry with Exponential Backoff | 3,000 transient errors become about 8 | Extra load, so jitter and a budget |
| Idempotency | A repeat has the effect of one call | A key table kept 24 hours |
| Circuit Breaker | A down dependency fails in about 1 ms | Cannot see slow calls that succeed |
| Bulkhead | One slow dependency cannot take every thread | Capacity split into compartments |
| Dead Letter Queue | A message that always fails stops being retried | An owner, an alert, a safe redrive |
| Graceful Degradation | Optional parts fail, and the page keeps working | A list of required and optional parts |
Growing Under Load
| Pattern | Solves | Costs |
|---|---|---|
| Vertical Scaling | Capacity with no design change | A size ceiling, one failure domain |
| Horizontal Scaling | More copies behind a balancer | Servers hold no state, N + 1 sizing |
| Load Balancing | Requests spread over a pool | Health checks, draining, a redundant pair |
| Auto-Scaling | Server count follows demand | Reacts 3 to 7 minutes late, so spare capacity |
| Connection Pooling | Connections opened once, reused | Servers × pool size under the database limit |
Keeping Data Consistent
| Pattern | Solves | Costs |
|---|---|---|
| Two-Phase Commit | All participants commit, or none | Blocks if the coordinator stops |
| Saga | Cross-service work, undone by compensating steps | A saga log, idempotent steps |
| Quorum | Leaderless writes with W + R > N | No order for concurrent writes |
| Vector Clocks | Finds concurrent writes | Siblings to merge, tombstones |
The Entry Point
| Pattern | Solves | Costs |
|---|---|---|
| Reverse Proxy | One address, private servers | An extra hop of about 1 ms, run as a pair |
| CDN | Round trips of 10 ms, not 200 ms | Invalidation, no private data |
| API Gateway | Shared rules run once | Runs on every request, must stay small |
| Backend for Frontend | One response per screen, 190 ms not 450 ms | A server per client team |
| Rate Limiting | Each caller's rate capped at the entrance | Counters shared across nodes |
| Cursor-Based Pagination | Stable pages at about 3 ms | No jump to page N, no cheap total |
| API Versioning | Breaking changes, no broken clients | Old versions kept two years |
| Sidecar | Network rules written once | CPU, memory, about 1 ms per call |
| Service Mesh | One control plane for all sidecars | Rule changes as risky as deploys |
Operating in Production
| Pattern | Solves | Costs |
|---|---|---|
| Health Check Endpoint | Restart and traffic decisions per server | Checking a shared dependency fails all servers |
| Distributed Tracing | Where one request spent its time | Headers in every service, sampling |
| Blue-Green Deployment | An undo in about 10 seconds | Two environments, shared schemas |
| Canary Deployment | A defect reaches 1 percent first | Gates, one schema for both versions |
| Feature Flags | Deploy separate from release | Old flags to delete |
Data-Intensive Systems
| Pattern | Solves | Costs |
|---|---|---|
| MapReduce | One big question over fixed data | Answers 2 to 26 hours old |
| Stream Processing | Answers while events arrive | Results that change, hard to build |
| Lambda and Kappa | Batch and stream numbers that agree | Two definitions, or replay capacity |
| Change Data Capture | Each committed change as an event | Log kept for stopped readers |
| Exactly-Once Semantics | One effect after a crash | Output waits up to one checkpoint |
| Backpressure | A slow consumer slows its producer | Someone upstream waits or drops work |
| Partitioned Consumption | Order per key, keys in parallel | No more workers than partitions, hot keys |
AI-Era Systems
| Pattern | Solves | Costs |
|---|---|---|
| Feature Store | One feature definition for training and production | A platform to own |
| Model Serving | 4 GPUs instead of 96 | A minimum first-token wait, shared batches |
| GPU Auto-Scaling | GPUs follow demand | 10-minute starts, a warm pool |
| LLM Gateway | One entry point with keys, caps, fallback | Adds under 5 ms, must stay small |
| Semantic Caching | Reworded questions reuse a stored answer | A wrong cached answer loses trust |
| Vector Database Sharding | An index beyond one machine's RAM | Scatter-gather without a tenant filter |
| RAG Pipeline | Current knowledge, with sources | Two pipelines to run |
The Decision Guide: Choosing Between Neighbors
Some patterns answer similar problems, and one fact about the system separates them. Failure has the most neighbors, so it comes first.
The first three rows sort failures by how long they last. In the fourth row nothing fails, as in the opening example.
| Neighbors | First when | Second when | Example |
|---|---|---|---|
| Message Queue or Publish-Subscribe | One group of workers shares the work | Several teams each need a copy | Feed: a topic, then a queue of fan-out jobs |
| Server-Sent Events or <span style="white-space:nowrap">Bidirectional</span> Streaming | The client only receives | Both sides send often | Dispatch: SSE for riders, <span style="white-space:nowrap">WebSocket</span> for drivers |
| Request-Response or Webhooks | The caller needs the result now | Another company reports it later | Payment: the charge answers, then webhooks |
| Primary-Replica or Sharding | Reads exceed one machine | Writes or data exceed one machine | Feed: 16 shards, one replica each |
| Circuit Breaker or Bulkhead | Calls fail | Calls succeed slowly | Copilot: a breaker on the carrier API |
| Two-Phase Commit (2PC) or Saga | All <span style="white-space:nowrap">participants</span> are your own shards | Steps cross services or <span style="white-space:nowrap">companies</span> | Payment: 2PC only between its own shards, a saga for payouts |
| Blue-Green or Canary | A fast undo is enough | Only a few users may see it first | Copilot: 5 percent against a baseline |
| MapReduce or Stream Processing | An answer hours old is fine | The answer is needed in seconds | Store: a nightly job, live sale counts |
| RAG Pipeline or a tool call | The model needs shared knowledge | The model needs one buyer's state | Copilot: help pages <span style="white-space:nowrap">retrieved</span>, order via <span style="white-space:nowrap">get_order</span> |
When both neighbors fit, a design often uses both. The feed uses a topic and a queue, and the payment platform may use 2PC inside its ledger, and it uses a saga outside it.
The Seven Principles
The four designs shared seven rules. Together, they summarize the course.
- Numbers before boxes. Dispatch sends 75,000 updates per second, but all driver state is 30 MB. The arithmetic shows that the problem is the update rate and who owns each driver, not memory.
- Every pattern names its cost. Hybrid fan-out limits the feed's inserts, and its cost is a feed that may be seconds old.
- The caller waits only at the edge. Priya waits about 100 ms for "posted", and fan-out runs afterward. Maya sees the copilot's first words within 1.5 seconds, before any tool has finished.
- Retries deliver twice, so receivers are idempotent. Key
1042makes one payment,pay_7310, however often the store retries. Keyc_8120-refund-1returns the same refund,re_4410, on every attempt. - Each key has one writer. An owner is the one server allowed to change a key's state. Server 5 applies claims for
d_7731in order. Of two 60 payouts from a 100 account, exactly one succeeds, with no distributed lock. - Save before you send. The payment service saves the payment and an outbox row in one transaction before any event leaves. The copilot records each step in its step log before running it.
- Silence is a signal, so reconcile. A card network that does not answer leaves a payment "unknown", not failed. Reconciling with the nightly settlement file then finds every difference the live path missed.
Using the Review in an Interview
In an interview, the review becomes three spoken steps: the symptom with a number, the pattern, and its cost. For example: "Two matchers can claim d_7731 in the same millisecond. I give each map cell one owner that applies claims in order. The cost is a rebuild of about 4 seconds when an owner fails."
Before an interview, test yourself on the index, then work through one capstone aloud. The Course Conclusion lesson gives the full plan for before and after the interview.
Check Yourself
Q1. The store's mobile home screen makes 3 rounds of calls from the phone, at 150 ms each, so the buyer waits 450 ms. Which pattern answers this, and what does it cost?
<details> <summary>Show answer</summary>Backend for Frontend. One server built for that screen makes the calls inside the data center, so the buyer waits 190 ms. The cost is one more server per client team, and it must hold no business rules.
</details>Q2. Two servers edit the price of one product at almost the same moment. Each writes the database and then the cache. Why does cache-aside delete the cache key instead of updating it?
<details> <summary>Show answer</summary>The two cache writes can arrive in the wrong order and leave the older price until the TTL ends. A delete is safe in any order, because the next read loads the current price. Only the database decides the order of the writes. This is principle 5.
</details>Q3 (incident). In the copilot, the carrier API slows from 200 ms to 9 seconds but answers every call. Within a minute, agent workers stop answering every question, even ones that never call track_package. The carrier breaker stays closed. Which patterns answer this, in order?
First, a Timeout on track_package that leaves room in the 20-second step budget. Second, a Bulkhead that limits how many workers may wait on the carrier, so other questions keep their workers. Third, Graceful Degradation: the copilot answers without tracking and says so. The breaker stayed closed because a slow success is not a failure.
💡 In the interview: Answer a symptom in three parts: the number, the pattern, and the cost. A strong answer sounds like this: "Fulfillment answers in 900 ms with no errors, so checkout needs 245 threads and has 200. A timeout and a breaker see nothing wrong. I add a bulkhead that limits fulfillment to its own share of threads, and the cost is capacity that other calls cannot borrow." Expect a follow-up asking what happens to the rejected calls. Answer that the order is placed, and its fulfillment step waits in a queue.
Key takeaway: A design answer moves from a symptom to a pattern to a cost. The symptom table maps what you observe to a pattern, the index gives each of the 62 patterns one line of benefit and one of cost, and the decision guide separates neighbors by one fact. All four designs follow seven principles: numbers before boxes, a named cost, waiting only at the edge, idempotent receivers, one writer per key, save before you send, and reconcile on silence.
Reading Progress
0%
On This Page
How to Use This Review
From Symptom to Pattern
The Pattern Index: 62 Patterns by Module
Moving Data
Storing Data
Serving Data Fast
Surviving Failure
Growing Under Load
Keeping Data Consistent
The Entry Point
Operating in Production
Data-Intensive Systems
AI-Era Systems
The Decision Guide: Choosing Between Neighbors
The Seven Principles
Using the Review in an Interview
Check Yourself