Combining System Design Patterns
Evaluate a complete request path using consistency, failure, and recovery trade-offs.
system design, trade-offs, observability, recoveryChoose from constraints, not a checklist
Consider a small hypothetical shop: browse should be fast, checkout must not silently duplicate a charge, and customers should know when an order is pending. Use only patterns justified by those needs. Define the expected request rate, latency targets, failure budget, acceptable data loss and freshness before choosing a topology.
Trace a checkout
- A gateway routes checkout to a service; a load balancer can spread requests among healthy instances. A limiter protects capacity.
- Checkout reserves stock using an appropriate authoritative consistency mechanism and calls payment with a stable operation ID. A timeout is an unknown outcome, not proof of failure.
- If payment is uncertain, persist a pending state and reconcile it before confirming the order. A transaction records each order-state change and its corresponding outbox event together. A relay publishes it; a queue or subscriptions deliver work to consumers, which handle duplicates.
See the reasoning
Follow the example one step at a time
Trace a checkout across independent failure boundaries. This is a prepared teaching demonstration, not live code execution.
Route
client → gateway / limiter → checkout
Routing and capacity limits do not guarantee that checkout or its dependencies succeed.
Evaluate the ten patterns together
Cache catalogue reads only within an agreed freshness limit. Replicas may serve lag-tolerant reports, not automatically current stock. Shard only if the workload justifies cross-shard complexity. A circuit breaker limits repeated calls to a failing payment provider; bounded backoff with jitter can retry safe operations. Queues decouple work; publish/subscribe fans events out. Neither implies exactly-once effects.
Operate and recover
Measure request errors and tail latency, saturation, cache freshness, replication lag, queue age, failed messages, breaker state and payment reconciliation. Correlate requests and events without recording secrets. Test restore, failover, duplicate delivery, a lost response and dependency outages. An outbox does not atomically commit a remote payment: use a durable workflow and reconciliation for that boundary. Complexity, privacy, cost, partial failure and human response time are part of the design.
Reflect on the concept
Four fixed questions to reinforce the reasoning. Answers are not saved or scored.
