System Design: 10 Patterns, Their Trade-offs, and Failure Modes

Ten common system design patterns, explained through an order service: when they help, what to measure, and how caching, queues, replicas, retries, and idempotency fail.

A slow system does not automatically need a cache. A growing queue does not automatically need more workers. A database under pressure does not automatically need sharding.

Each of those choices can help, but only when it addresses the resource that is actually limiting the system. Otherwise, the extra component moves the bottleneck, introduces another failure mode, or makes correctness harder to explain.

The useful part of a system design checklist is the question behind each pattern: what is waiting, what is saturated, and what must remain correct when something fails? This article expands ten familiar patterns into decisions, using a fictional order service throughout. The examples describe a hypothetical design, not a measured deployment.

Start with the constraint

Imagine an order service that serves product details, accepts orders, calls a payment provider, and sends confirmations. It stores transactional data in PostgreSQL. Customers also download invoices and upload attachments.

Before changing its architecture, separate the requirements. Product descriptions can tolerate some staleness. The result of a newly created order should be visible immediately to its customer. A payment must not be duplicated because a response was lost. A confirmation email can arrive later, but it must not disappear silently.

Then measure the affected path: latency percentiles, arrival and completion rates, resource saturation, database waits, dependency latency, and errors. For asynchronous work, include the age of the oldest unfinished item. A fast HTTP response can hide hours of queued work.

I would treat each proposed component as a testable hypothesis: “Repeated product reads dominate database work; caching eligible responses should reduce that work without exceeding the freshness budget.” That statement gives the change both a success signal and a reason to roll it back.

Choose system-design patterns through measurement and bounded experiments From an observed symptom, measure the bottleneck, form a hypothesis, make one bounded change with a rollback path, and compare the target metric and guardrails. If the target is met, retain the change and keep observing. If there is no useful gain or there is a regression, revert and measure again. Start with a symptom. Measure the bottleneck.A pattern is a testable hypothesis, not a diagnosis.01MeasureTail latency, errors,queue age, saturation02HypothesisName the bottleneck.Predict an outcome.03Bounded changeOne guarded step.Preserve rollback.04VerifyCompare targetand guardrails.Meets targetKeep the change.Keep observing.No useful gainor regression:revert the change.Re-measure after rollback. Use the same target and guardrails.
Choose system-design patterns through measurement and bounded experiments From an observed symptom, measure the bottleneck, form a hypothesis, make one bounded change with a rollback path, and compare the target metric and guardrails. If the target is met, retain the change and keep observing. If there is no useful gain or there is a regression, revert and measure again. Start with a symptom.Measure the bottleneck.01MeasureTail latency, errors,queue age, saturation02HypothesisName the bottleneck.Predict an outcome.03Bounded changeOne guarded step.Preserve rollback.04VerifyCompare targetand guardrails.Meets targetKeep thechange.Keep observing.No useful gainor regression:revert thechange.Re-measure after rollback.Use the same target and guardrails.
Define the target and guardrails before changing the system. Keep a useful change and continue observing; revert a failed experiment and measure again. A pattern does not establish the cause of a symptom.
Choose a pattern from evidence, then account for its main cost.
SymptomEvidence to gatherCandidate patternMain trade-off
Repeated readsHot keys and origin workCacheFreshness and invalidation
Write burstsArrival rate and queue ageBounded queueDelay and admission limits
Traffic overloadPer-instance saturationLoad balancing and scalingShared bottlenecks
Read-heavy databaseRead cost and acceptable lagRead replicasConsistency and routing
Write-heavy databaseLocks, logging, index costWrite optimization, then shardingDistribution complexity
Slow queriesPlans and row estimatesQuery and index changesWrite and storage cost
Slow file deliveryByte volume and origin latencyObject storage and CDNCache and access policy
Transient failuresFailure type and time budgetBounded retriesExtra downstream load
Unhealthy dependencyTimeouts and failure rateCircuit breakerExplicit degraded behavior
Duplicate operationsConcurrent and ambiguous retriesIdempotency contractAtomic state and retention

1. Repeated reads: cache data with an explicit freshness budget

A cache keeps reusable results closer to their consumers. It helps when a meaningful share of expensive reads asks for the same data and the application can reuse a previous answer.

For the order service, product descriptions are a plausible candidate. Available stock at the moment of purchase requires a different correctness decision. Serving both through the same cache policy would conceal that distinction.

Define the key, expiry, invalidation path, and behavior on a miss. Include tenant or authorization scope wherever it affects the result. A time-to-live limits how long an entry remains eligible; it does not guarantee that a customer sees their latest write. Cache-aside does not guarantee consistency. Simultaneous misses for a popular key can also send a burst to the origin. Request coalescing, staggered expiry, and deliberately serving stale data can help in suitable workloads, but each needs an explicit contract. The AWS Builders’ Library discussion of caching covers these operational failure modes.

Measure useful hits, miss latency, evictions, and origin load. A high overall hit ratio can coexist with a slow critical endpoint. Test an empty or unavailable cache too: if the database cannot survive the resulting miss traffic, cache failure has become an availability event.

2. Write bursts: use finite queues and backpressure

A queue separates acceptance from completion. It can absorb a temporary mismatch between incoming work and processing capacity. It cannot make a sustained capacity deficit disappear.

Consider a hypothetical confirmation pipeline receiving 800 jobs per second while workers complete 500. A 30-second burst adds 9,000 jobs: (800 − 500) × 30. If arrivals then fall to 350 per second, the workers have 150 per second of spare capacity. Draining that extra backlog takes 60 seconds.

This illustration assumes constant rates, sufficient finite buffer space, and sustained worker throughput. Retries, slow jobs, and failures change the result. It is a capacity calculation, not a delivery-time promise.

Bound the queue and decide what happens when it fills: reject new work, defer acceptance, or shed work whose contract permits dropping it. Already accepted orders and required confirmations must not disappear silently. Backpressure means communicating a capacity limit upstream so producers can slow down or stop. Also define expiry or escalation for work that has become too old. AWS’s guidance on avoiding queue backlogs explains why recovery behavior matters as much as normal throughput.

The API must distinguish “accepted for processing” from “completed.” Monitor oldest-item age, arrival versus completion rates, retries, and failed work. A durable queue still needs a plan for duplicates and permanently failing messages.

Control overload at admission and bound downstream work Requests reach admission control before entering a finite queue. Queue depth and oldest age inform admission. Work that cannot be admitted is explicitly rejected, deferred, or slowed according to the producer contract. Admitted work flows from the queue to workers and then a dependency. In-flight calls, including retries, have bounded concurrency; dependency calls use timeouts, deadlines, and a retry budget. Observe admitted rate, completion rate, queue depth, and oldest age. Bound the queue. Bound the work.Buffers absorb bursts; service capacity is still finite.depth + oldest ageRequestsVariablearrival rateAdmissionLimit entry.Check budget.Finite queueDepth limit.Watch age.WorkersBound in-flightcalls + retries.DependencyTimeouts andretry budget.not admittedReject / deferor slow the producerby contract.Bound the total work budgetRetries consume capacity too.Apply deadlines to dependency calls.Measure the backlogAdmitted rate, completion rate, queue depth, and oldest age.Admission limits must react before useful work becomes stale.A queue changes when work runs. It does not remove an overload.
Control overload at admission and bound downstream work Requests reach admission control before entering a finite queue. Queue depth and oldest age inform admission. Work that cannot be admitted is explicitly rejected, deferred, or slowed according to the producer contract. Admitted work flows from the queue to workers and then a dependency. In-flight calls, including retries, have bounded concurrency; dependency calls use timeouts, deadlines, and a retry budget. Observe admitted rate, completion rate, queue depth, and oldest age. Bound the queue.Bound the work.Requests: variable arrival rateAdmissionLimit entry. Check the request budget.Finite queueLimit depth. Watch the oldest age.WorkersBound in-flight calls, including retries.DependencyUse timeouts, deadlines, a retry budget.Depth and oldest age inform admission.The side path is work not admitted.If full, too old, or over budget:Reject / deferor slow the producer by contract.Measure the backlogAdmitted and completion rates.Queue depth and oldest age.Retries consume capacity too.Buffering buys time.It does not add service capacity.
The rejection path is an admission decision. It does not silently discard accepted durable work. Limit both backlog and in-flight dependency calls, including retries, and watch queue age as well as depth. A finite queue absorbs a burst only while the consumer can catch up.

3. Traffic overload: scale the resource that is saturated

A load balancer distributes requests across service instances. Horizontal scaling adds instances. This increases useful capacity when those instances can perform more independent work and their shared dependencies have room for it.

First inspect whether load is balanced and whether requests are waiting for CPU, connections, locks, or a remote service. One hot instance and three idle ones suggest a different problem from four equally saturated instances. Health and readiness checks should prevent new traffic from reaching an instance that cannot serve it.

Keep request handling independent of a particular process where practical. Local session state, files, or unfinished work can complicate routing and replacement. Moving that state elsewhere creates its own capacity and availability requirements.

In the order service, doubling application instances while doubling every connection pool could overload PostgreSQL sooner. Microsoft’s scale-out guidance highlights the constraints shared resources can impose. Set a system-wide connection and concurrency budget. Include startup delay and connection establishment in capacity planning; an autoscaling decision does not make an instance ready immediately. Drain active requests when removing capacity. Then verify end-to-end latency and downstream saturation under representative load.

4. Read-heavy databases: replicas need a consistency policy

A read replica can move eligible reads away from the writer. It is useful when database read work is the constraint and the chosen replication arrangement meets the application’s consistency requirements.

With asynchronous replication, a replica may not yet contain a committed write. PostgreSQL’s standby documentation describes replication lag and the different guarantees of synchronous replication settings. A replica is another database with operational behavior to understand, rather than a transparent read-capacity switch.

For the order service, an administrative report might tolerate lag. The customer’s immediate order-confirmation read should use the writer or another mechanism that establishes the required visibility. Arbitrarily sending the write and subsequent read to different nodes can produce an alarming “order not found” response.

Define routing by consistency need, monitor replication lag and replica resource usage, and plan how reads behave during failover. Replicas do not remove write work from the primary. Expensive reporting can also compete with replay on a replica, so adding readers still requires workload limits.

5. Write-heavy databases: reduce work before distributing it

A write bottleneck may come from lock contention, long transactions, logging and storage throughput, or maintaining indexes that the workload rarely uses. Distributing data before understanding that cost can preserve the expensive operation and add coordination overhead.

For orders, inspect transaction duration, repeated updates, index maintenance, and contention around shared rows. Batch suitable work within the latency and durability contract. Keep transactions focused, but preserve the invariants they exist to protect. Removing a correctness check to make a benchmark faster is not a capacity improvement.

Distinguish table partitioning from distributed sharding. PostgreSQL’s declarative partitioning divides a logical table into partitions managed by that database. It can improve pruning and data management for suitable workloads. It does not inherently distribute writes across independent database servers.

Sharding distributes ownership across nodes. It needs a routing key and answers for skew, rebalancing, backups, uniqueness, and transactions that cross ownership boundaries. Sharding orders by customer may localize customer history while leaving a shared inventory hotspot unresolved. Choose it when the measured constraint and access model justify those costs.

6. Slow queries: read the plan before adding an index

“The database is slow” is too broad to guide a change. Identify the expensive query shape and inspect where its work grows: scans, joins, sorting, returned rows, or repeated execution.

PostgreSQL’s EXPLAIN documentation shows how plans expose those operations. Compare estimated and actual row counts when safe measurements are available. A poor estimate can affect join and access choices; a sequential scan can be appropriate when much of the table is needed.

An index should match a real predicate, join, or ordering requirement. For customer order history, the customer filter and requested ordering matter together. Indexing every column is not a strategy. PostgreSQL notes that indexes impose overhead on data modification, in addition to consuming storage.

EXPLAIN ANALYZE executes the statement. That includes changes made by a write statement. Start with a non-executing plan where appropriate, and use a safe, bounded investigation environment for actual execution. Even a read can consume substantial resources. After changing a query or index, check the wider write and read workload, not only the isolated query.

7. Slow file delivery: separate bytes from application work

If application workers spend their time streaming invoices, images, or attachments, object storage and a content delivery network can give file delivery its own path. A CDN caches eligible responses near clients and reduces repeated requests to the origin.

Cache correctness still matters. Use versioned object names for immutable public assets, choose expiry deliberately, and ensure the cache key distinguishes responses that must differ. A cached response with the wrong authorization boundary is a data exposure, not a performance win. CloudFront’s documentation explains cache-key configuration and private content access.

For the order service, the application can authorize an invoice download and issue appropriately restricted access. The invoice must remain private even if its address is hard to guess. Restrict direct access to its origin as well; a signed CDN link does not make a publicly accessible storage object private. Define expiry, caching, and revocation behavior according to the document’s sensitivity.

Check both warm and cold delivery. A CDN miss still reaches an origin. Moving bytes also leaves metadata lookups and authorization on the application path, so measure whether file traffic was actually its limiting resource.

8. Temporary failures: retries need a shared budget

A retry is another attempt at work whose earlier result was unsuccessful or unknown. It can help with a transient failure, but it also adds load when the dependency may already be struggling.

Retry only failures for which another attempt is appropriate, following the endpoint’s contract. Bound attempts and elapsed time, use exponential backoff with jitter, and keep every attempt inside an overall deadline. Jitter spreads retry timing instead of making many clients retry together. AWS’s guidance on timeouts, retries, and backoff explains these interactions.

Account for retries across the whole call path. If three nested layers each permit three total attempts, including the first, one incoming operation can generate up to 27 attempts at the deepest dependency. That is illustrative multiplication, not a universal retry policy. Independent defaults can turn a small incident into a much larger workload.

For a payment call, a timeout does not establish that the charge failed. The provider may have completed it before the response was lost. The next attempt needs an idempotency contract or a status-reconciliation path. Stop retrying when the caller’s deadline or the shared retry budget is exhausted.

9. Dependency failures: circuit breakers bound repeated failure

A circuit breaker tracks failures at a dependency boundary. When its policy opens the circuit, calls fail quickly instead of repeatedly attempting a likely failing operation. A later half-open state permits limited probes to test recovery.

This is separate from a timeout, which bounds waiting, and a concurrency bulkhead, which limits how much capacity a dependency can occupy. Microsoft’s circuit breaker pattern and bulkhead pattern describe these different responsibilities. A breaker does not cancel the need for either resource limits or deadlines.

If the order service’s recommendation provider fails, checkout may proceed without recommendations. If its payment provider fails, returning a fabricated successful payment is not a valid fallback. The domain decides which degraded behavior is acceptable.

Choose the boundary carefully. One tenant’s invalid requests should not necessarily open a breaker for every tenant. Monitor state transitions, rejected calls, and probe outcomes. Recovery probes must be limited too, so an unhealthy dependency is not flooded as soon as a timer expires.

10. Duplicate operations: make idempotency a stored contract

Idempotency means repeating a logical operation has the same intended effect as performing it once. For an order API, the client can supply a key scoped to its account and operation. The server associates that key with a request fingerprint and an outcome.

Reserve the key atomically, for example through a unique database constraint. Where the effect is local, coordinate that reservation, the business change, and the recorded outcome in one transaction. A concurrent duplicate may wait for the active transaction, receive an in-progress response, or replay the completed result, according to the contract. Reusing the key with a different request should be rejected. AWS’s discussion of safe retries with idempotent APIs explains why identifying caller intent matters.

Specify retention, in-progress responses, and which outcomes are retained. Once a key expires, the protection window changes. An API’s treatment of failed attempts is part of its own contract; do not assume all implementations replay every error. If external work uses a separately committed in-progress state, define how a crash is detected and recovered. Otherwise, a stuck reservation can prevent the operation from ever finishing.

A local transaction cannot atomically include an arbitrary external payment call. A transactional outbox can commit an order and its pending external-work record together. Delivery can still repeat. The external boundary needs provider-supported idempotency or reconciliation, and consumers need duplicate handling. This combination does not justify a blanket promise of exactly-once effects.

Apply the patterns in stages

The order service does not need every component on day one. Start with its correctness boundaries: transactional order creation, a durable record of accepted work, explicit payment state, and safe handling of repeated requests.

Then follow measured constraints. If a query is expensive, investigate its plan before adding a replica. If confirmation bursts exceed worker capacity, add bounded buffering with an acceptance policy. If product reads dominate origin work, cache the data whose freshness contract permits it. Move large file delivery when byte serving is the constraint.

For every change, write down five things: the evidence, the correctness requirement, the capacity limit, the failure behavior, and the signal that would trigger rollback. Test the uncomfortable cases: cold cache, full queue, lagging replica, failed dependency, and concurrent duplicate requests.

A defensible system design explains how the system behaves at its limits. The component names become useful after that explanation is clear.

For the messaging and transaction boundaries behind this example, continue with Kafka vs RabbitMQ: When to Choose Each and Transactional Outbox Pattern with Kafka and PostgreSQL.

Inspired by a GeeksforGeeks infographic about common system design responses. The examples and analysis here are original, with primary documentation linked throughout.

Share
Edit Template

Get new engineering deep dives

Scala, JVM, AI, and backend systems. I send practical articles when there is something worth reading.

Join the newsletter