System Design Patterns: From Fundamentals to Real Systems
Vote

0% completed

​

Pattern Review

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

System Design Pattern Review: The Symptom-to-Pattern Diagnostic Table, the Decision Cheat Sheet, and the Whiteboard Checklist (Video)
Pattern Review
Pattern Review

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.

SymptomPatternSeen in
The caller waits for work it does not need to see finishedMessage QueueFeed: "posted" in 100 ms, fan-out later
Several teams need the same factPublish-SubscribePayment: ledger and webhooks read one stream
A retry charges a buyer twiceIdempotencyPayment: key 1042 makes one pay_7310
A dependency that never answers holds every threadTimeoutPayment: no answer in 2 s means "unknown"
A down dependency is called again and againCircuit BreakerCopilot: the carrier API fails fast
Slow calls that succeed stop all other workBulkheadStore: the checkout example above
One message fails on every attemptDead Letter QueueStore: order 3907 with no address
One optional part turns a page into an errorGraceful DegradationFeed: large lists skipped after 30 ms
Reads exceed one databasePrimary-Replica, Cache-AsideFeed: posts from the post cache
Data or writes exceed one machineShardingFeed: 800 GB on 16 shards
Two writers change one key at onceOne owner, as in Design 2, Ride-Sharing DispatchDispatch: server 5 applies claims for d_7731 in order
A change across services stops halfwaySagaPayment: a rejected payout gets a new entry
One caller uses everyone's capacityRate LimitingPayment: 1,200 charges per second
A release breaks some requestsCanary DeploymentCopilot: 5 percent of conversations first
Indexes miss changes made outside the appChange Data CaptureCopilot: help page edits reach the index
Reworded questions pay for new answersSemantic CachingCopilot: 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.

62 patterns under five questions
62 patterns under five questions

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

PatternSolvesCosts
Request-ResponseThe caller needs the answer to continueWaiting, and waits add up along a chain
Message QueueThe producer continues once work is storedAt-least-once delivery, a backlog to watch
Publish-SubscribeOne fact, a copy for each subscriberA schema contract, an outbox, duplicates
Event-Driven ArchitectureServices react to facts, not callsBriefly stale copies, hidden dependencies
WebhooksAnother company reports events, no pollingAny order, at least once, signatures
Server-Sent EventsThe server pushes on one open responseOpen connections, no proxy buffering
Bidirectional StreamingBoth sides send often on one connectionState on one gateway node, resume logic

Storing Data

PatternSolvesCosts
Primary-ReplicaRead capacity and a failover copyAbout 50 ms of lag, a write pause on failover
ShardingWrites and data beyond one machineKey-less queries hit every shard, hot keys
Consistent HashingA new machine takes about 1 ÷ N of keysVirtual nodes to keep slices even
Write-Ahead LogA confirmed write survives a crashAn fsync per commit, log kept for slow readers
Event SourcingFull history, state by replayPermanent schemas, eventual consistency
CQRSRead models per query, 5 ms not 300 msAbout 200 ms of lag, projectors to run

Serving Data Fast

PatternSolvesCosts
Cache-Aside99 percent hits: 12,000 reads become 120Stale entries, delete on write, a TTL
Read-ThroughOne loader per key type, merged missesA library in the read path
Write-ThroughThe next read sees the writeEach write waits on two systems
Write-BehindMany writes become fewCan lose 2 seconds of writes, never money
Cache Stampede PreventionOne rebuild, not 600 queriesLocks, serving old values, early refresh

Surviving Failure

PatternSolvesCosts
TimeoutA callee that never answers holds a known number of threadsA timed-out write has an unknown result
Retry with Exponential Backoff3,000 transient errors become about 8Extra load, so jitter and a budget
IdempotencyA repeat has the effect of one callA key table kept 24 hours
Circuit BreakerA down dependency fails in about 1 msCannot see slow calls that succeed
BulkheadOne slow dependency cannot take every threadCapacity split into compartments
Dead Letter QueueA message that always fails stops being retriedAn owner, an alert, a safe redrive
Graceful DegradationOptional parts fail, and the page keeps workingA list of required and optional parts

Growing Under Load

PatternSolvesCosts
Vertical ScalingCapacity with no design changeA size ceiling, one failure domain
Horizontal ScalingMore copies behind a balancerServers hold no state, N + 1 sizing
Load BalancingRequests spread over a poolHealth checks, draining, a redundant pair
Auto-ScalingServer count follows demandReacts 3 to 7 minutes late, so spare capacity
Connection PoolingConnections opened once, reusedServers × pool size under the database limit

Keeping Data Consistent

PatternSolvesCosts
Two-Phase CommitAll participants commit, or noneBlocks if the coordinator stops
SagaCross-service work, undone by compensating stepsA saga log, idempotent steps
QuorumLeaderless writes with W + R > NNo order for concurrent writes
Vector ClocksFinds concurrent writesSiblings to merge, tombstones

The Entry Point

PatternSolvesCosts
Reverse ProxyOne address, private serversAn extra hop of about 1 ms, run as a pair
CDNRound trips of 10 ms, not 200 msInvalidation, no private data
API GatewayShared rules run onceRuns on every request, must stay small
Backend for FrontendOne response per screen, 190 ms not 450 msA server per client team
Rate LimitingEach caller's rate capped at the entranceCounters shared across nodes
Cursor-Based PaginationStable pages at about 3 msNo jump to page N, no cheap total
API VersioningBreaking changes, no broken clientsOld versions kept two years
SidecarNetwork rules written onceCPU, memory, about 1 ms per call
Service MeshOne control plane for all sidecarsRule changes as risky as deploys

Operating in Production

PatternSolvesCosts
Health Check EndpointRestart and traffic decisions per serverChecking a shared dependency fails all servers
Distributed TracingWhere one request spent its timeHeaders in every service, sampling
Blue-Green DeploymentAn undo in about 10 secondsTwo environments, shared schemas
Canary DeploymentA defect reaches 1 percent firstGates, one schema for both versions
Feature FlagsDeploy separate from releaseOld flags to delete

Data-Intensive Systems

PatternSolvesCosts
MapReduceOne big question over fixed dataAnswers 2 to 26 hours old
Stream ProcessingAnswers while events arriveResults that change, hard to build
Lambda and KappaBatch and stream numbers that agreeTwo definitions, or replay capacity
Change Data CaptureEach committed change as an eventLog kept for stopped readers
Exactly-Once SemanticsOne effect after a crashOutput waits up to one checkpoint
BackpressureA slow consumer slows its producerSomeone upstream waits or drops work
Partitioned ConsumptionOrder per key, keys in parallelNo more workers than partitions, hot keys

AI-Era Systems

PatternSolvesCosts
Feature StoreOne feature definition for training and productionA platform to own
Model Serving4 GPUs instead of 96A minimum first-token wait, shared batches
GPU Auto-ScalingGPUs follow demand10-minute starts, a warm pool
LLM GatewayOne entry point with keys, caps, fallbackAdds under 5 ms, must stay small
Semantic CachingReworded questions reuse a stored answerA wrong cached answer loses trust
Vector Database ShardingAn index beyond one machine's RAMScatter-gather without a tenant filter
RAG PipelineCurrent knowledge, with sourcesTwo 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.

Which failure, which pattern
Which failure, which pattern

The first three rows sort failures by how long they last. In the fourth row nothing fails, as in the opening example.

NeighborsFirst whenSecond whenExample
Message Queue or Publish-SubscribeOne group of workers shares the workSeveral teams each need a copyFeed: a topic, then a queue of fan-out jobs
Server-Sent Events or <span style="white-space:nowrap">Bidirectional</span> StreamingThe client only receivesBoth sides send oftenDispatch: SSE for riders, <span style="white-space:nowrap">WebSocket</span> for drivers
Request-Response or WebhooksThe caller needs the result nowAnother company reports it laterPayment: the charge answers, then webhooks
Primary-Replica or ShardingReads exceed one machineWrites or data exceed one machineFeed: 16 shards, one replica each
Circuit Breaker or BulkheadCalls failCalls succeed slowlyCopilot: a breaker on the carrier API
Two-Phase Commit (2PC) or SagaAll <span style="white-space:nowrap">participants</span> are your own shardsSteps cross services or <span style="white-space:nowrap">companies</span>Payment: 2PC only between its own shards, a saga for payouts
Blue-Green or CanaryA fast undo is enoughOnly a few users may see it firstCopilot: 5 percent against a baseline
MapReduce or Stream ProcessingAn answer hours old is fineThe answer is needed in secondsStore: a nightly job, live sale counts
RAG Pipeline or a tool callThe model needs shared knowledgeThe model needs one buyer's stateCopilot: 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.

  1. 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.
  2. Every pattern names its cost. Hybrid fan-out limits the feed's inserts, and its cost is a feed that may be seconds old.
  3. 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.
  4. Retries deliver twice, so receivers are idempotent. Key 1042 makes one payment, pay_7310, however often the store retries. Key c_8120-refund-1 returns the same refund, re_4410, on every attempt.
  5. Each key has one writer. An owner is the one server allowed to change a key's state. Server 5 applies claims for d_7731 in order. Of two 60 payouts from a 100 account, exactly one succeeds, with no distributed lock.
  6. 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.
  7. 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?

<details> <summary>Show answer</summary>

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.

</details>

💡 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.

General
Test Your Knowledge
Check your understanding and reinforce the key concepts covered in this section with a short, targeted assessment.
9 Questions
~14 mins
Your progress is saved automatically

Reading Progress

0%


Vote for new content

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