System design pattern library
Choose the failure or scaling problem first. Each row names a design obligation and a concrete way to exercise it. The exercises are proposed acceptance tests.
| Pattern and source | When it helps | Design obligation | Test the decision |
|---|---|---|---|
| Backends for frontends | Mobile and operator clients need different aggregation, payload and offline behavior. | Assign each BFF an owner and retain domain permission checks downstream. | Measure the duplicated logic and round trips saved before splitting a shared BFF. |
| Bulkhead | One heavy tenant or tool can exhaust all worker capacity. | Give costly jobs a separate queue and concurrency pool. | Saturate the slow pool and measure p95 admission for an unrelated tenant. |
| Cache-aside | Repeated reads of an expensive profile or reference record dominate latency. | Define cache key, TTL, change notification and policy-version scope. | Revoke a grant and verify cache freshness at the documented boundary. |
| Circuit breaker | A failing provider turns normal traffic into repeated timeout waits. | Open on a measured failure threshold and probe recovery with bounded requests. | Display degraded work honestly and verify that half-open probes cannot overload the provider. |
| Compensating transaction | A partial process must release reservations or reverse reversible effects. | Record completed steps and compensations with stable effect identifiers. | Simulate a failed compensation and prove the case remains visible to an operator. |
| Competing consumers | Work can be distributed among interchangeable consumers. | Size parallelism against the downstream service limit and retain idempotent handling. | Crash after an effect and before acknowledgment. Verify one applied business change. |
| CQRS | Write invariants and read models have substantially different requirements. | Name the authoritative write model and the projection’s observable freshness. | After an accepted write, show the correct status while the projection is catching up. |
| Deployment stamps | Regional or tenant groups need bounded failure domains. | Assign tenant-to-stamp routing, migration and capacity ownership. | Prove an outage in one stamp leaves other tenants reachable. |
| Event sourcing | The business needs historical state reconstruction and changing projections. | Version domain events and decide how sensitive data and corrections are represented. | Rebuild a projection from a known checkpoint and compare it to the authoritative outcome. |
| Gateway aggregation | A client requires data from several services on the same screen. | Define per-dependency deadlines and which results may be partial. | One slow dependency produces an explicit partial view inside the client deadline. |
| Regional cells | Local traffic needs a complete service stack near each population. | Define jurisdiction, source of truth and cross-region consistency per data class. | Exercise regional failure when the fallback region is disallowed for one tenant. |
| Health endpoint monitoring | The platform needs to distinguish a process that is alive from one ready for traffic. | Separate startup, liveness and readiness criteria and control sensitive health metadata. | Verify a transient dependency issue does not create a restart storm. |
| Materialized view | Frequent analytical reads repeatedly compute the same expensive join. | Define high-water mark, rebuild process and acceptable staleness. | Display stale data clearly while the view rebuilds. |
| Transactional outbox | A business state transition and its corresponding message must survive a process crash. | Commit state and outbox intent together. Use receiver-side deduplication. | Crash between publish and marking delivery and measure duplicate effects. |
| Priority queue | Urgent human decisions and background imports share capacity. | Define fairness, aging, queue caps and maximum starvation time. | Run sustained urgent traffic and measure the oldest normal-priority item. |
| Publish/subscribe | Several independent consumers react to the same business event. | Assign schema, replay, retention and lag ownership per subscriber. | Take one consumer offline, recover it, and verify other consumers remained current. |
| Queue-based load leveling | Bursty intake exceeds safe processing throughput. | Set an admission limit and translate backlog into an estimated delay. | Measure oldest-item age and return meaningful guidance under overload. |
| Retry with backoff | A classified transient failure can recover without a human decision. | Use a deadline, jitter and one retry owner per operation. | Calculate total downstream attempts when the gateway and worker both fail. |
| Saga | A process spans independently committed services and needs compensations. | Specify coordinator, timeouts, forward and compensating actions and human exceptions. | Interrupt after each external commit and verify a known terminal or reconciled state. |
| Sharding | One storage partition can no longer meet capacity or isolation requirements. | Choose a shard key that supports the common request and plan online rebalancing. | Measure hot tenants, cross-shard transactions and restore of a single shard. |
| Strangler Fig | A high-availability legacy capability must be replaced incrementally. | Move one bounded workflow behind a routing seam and define data ownership at each stage. | Compare old and new results and verify rollback before migrating the next cohort. |
| Throttling | Quotas protect shared capacity, cost or downstream contracts. | Apply rate and concurrency limits by principal and tenant at the authoritative boundary. | Differentiate overload from permanent denial and provide a retry time where appropriate. |
| Valet key | Clients need short-lived access to a specific large object. | Authorize the object relation, mint a narrowly scoped grant and restrict expiry. | Verify a grant cannot be reused for a different object or after the permitted window. |
| Claim check | A payload is too large or sensitive to send repeatedly through a broker. | Put the body in controlled storage and send a bounded pointer as the message. | Handle expired references, unauthorized reads and orphan cleanup after failed publication. |