Study guide · System design

Study guide: system design trade-offs

Map threats and trust boundaries, control access, protect data across its life cycle, and verify system design trade-offs decisions.

Contents
  1. ·Learning objectives
  2. §1Core concepts
  3. §2Frame the decision before choosing components
  4. §3Compare alternatives on the same dimensions
  5. §4Quantify the consequence of an assumption
  6. §5Follow costs across component boundaries
  7. §6Include failure, security, operations, and change cost
  8. §7Record the choice and define a revision trigger
  9. ·Common mistakes
  10. ·Practice questions
  11. ·Review checklist

· · Start here

Learning objectives

  1. Frame an architectural choice using the user outcome, constraints, workload, and quality targets it must satisfy.
  2. Compare feasible alternatives against the same criteria and identify the benefit and cost of each.
  3. Calculate how an assumption about load, cache effectiveness, or dependency availability changes a decision.
  4. Explain how caching, replication, partitioning, and asynchronous work move costs between system properties.
  5. Include correctness, failure behavior, security, operations, and change cost when assessing an alternative.
  6. Record a decision with its assumptions, rejected alternatives, evidence, and conditions for revisiting it.

§1 · Definitions

Core concepts

This section defines a trade-off, the targets a design must meet, and the uncertainty present when a choice is made.

A system design decision is justified by linking an alternative to an objective and showing what it costs. Keeping a second copy of frequently read data may reduce response time and database work while allowing that copy to become stale. Deferring work may shorten the time before a request is acknowledged while delaying completion of the requested action. These are trade-offs only after the affected operation, tolerated behavior, workload, and failure case have been named. Some changes improve several properties at once; the task is to compare the available choices, not to assume every benefit must have an equal penalty.

The common confusion is to treat “faster,” “more scalable,” or “more reliable” as complete arguments. Each claim needs a measurement and a context. An option that serves search well may be unacceptable for inventory reservation, and a design that works at average traffic may fail at a peak. Trade-offs are relationships among requirements and alternatives, not fixed rankings of technologies.

§2 · Decision context

Frame the decision before choosing components

Begin with a user outcome and its non-negotiable rules. An online shop may require that a customer can place an order, that confirmed orders do not oversell stock, and that checkout remains responsive at an agreed peak rate. The first is behavior, the second is a correctness constraint, and the third needs a measured quality target. Record the current workload, likely growth, and what happens when a dependency fails. Without that frame, alternatives are compared on features that may not matter to the user.

The diagram shows how requirements narrow the choices before a component is selected.

System flow
User outcome + invariant + quality target + workload
                         ↓
               feasible alternatives
                         ↓
             measured costs and risks
                         ↓
                    decision

Read the first line as inputs to the decision, not as outputs of a chosen architecture. If the invariant forbids acknowledging an unreserved order, an option that returns success before reservation is complete does not become acceptable merely because it is faster. A hard constraint eliminates an option; a negotiable target can be revised only through an explicit product decision.

Uncertainty belongs in this frame. Mark estimates as assumptions, give each a source or a way to measure it, and identify which ones could reverse the choice. A projected tenfold increase in reads matters differently from a projected tenfold increase in writes. Use a representative peak workload rather than applying a universal request-rate threshold to every database or queue.

§3 · Compare options

Compare alternatives on the same dimensions

List at least a baseline and a credible alternative. Hold the workload, measurement window, failure model, and user outcome constant so that differences have a cause. Compare latency, throughput, consistency, durability, availability, security, delivery time, operating effort, and cost only where they are relevant; adding a dimension with no decision impact creates noise. Eliminate infeasible options first. Pareto dominance can then remove an option that is worse across all known dimensions, while acknowledging that an unmeasured cost might change the conclusion.

The table compares three ways to serve a frequently read product description. Its entries are conditional consequences, not universal performance claims.

Option Likely benefit New obligation or cost When to test it
Read the primary store One authoritative copy and a simple read path. The primary serves every read and may saturate. Test first when the estimated and measured load is modest.
Read a replica More read capacity and isolation from the primary's read load. Replication lag may return an older value; failover and replica health need handling. Test when reads dominate and the operation tolerates the observed lag.
Read a cache Fewer origin reads and potentially lower response time. Invalidation, cold starts, extra memory, and stale values need explicit rules. Test when hot keys or latency measurements justify another copy.

The first row is a useful baseline because it reveals whether extra moving parts are needed. A replica or cache should be selected for a measured need and given a freshness rule; neither is automatically better. The same comparison method applies to a single service versus several services, immediate versus deferred work, and one region versus multiple regions.

§4 · Quantify effects

Quantify the consequence of an assumption

A numerical comparison does not require a detailed forecast. It needs enough arithmetic to expose where an option stops working. Separate read and write rates, use the same time window for both, and label capacity figures as measurements or assumptions. A cache hit ratio is especially important because a small change near an origin's limit can turn a healthy design into an overloaded one.

Worked examplea cache that protects the origin

Consider a product-read path with an assumed peak of 2,000 reads per second. Assume load testing shows that the origin can sustain 600 reads per second at the required latency, and assume an 80% cache hit ratio at the peak mix. Misses reach the origin at 2,000 × (1 − 0.80) = 400 reads/s. The origin has 600 − 400 = 200 reads/s of headroom. Check: 2,000 × 0.80 = 1,600 reads/s are served from cache, and 1,600 + 400 = 2,000 total reads/s.

The minimum hit ratio that merely avoids exceeding the measured origin limit is 1 − 600 ÷ 2,000 = 0.70, or 70%. At 70%, misses are 2,000 × 0.30 = 600 reads/s, leaving zero headroom. If the cache becomes unavailable, all 2,000 reads/s may reach an origin measured for 600 reads/s, an excess of 2,000 − 600 = 1,400 reads/s. The design therefore needs a failure response, such as limiting requests or serving a safe degraded result, and a freshness rule for cached descriptions. The calculation supports using the cache under the assumptions; it does not prove that the cache failure path is safe.

Repeat the arithmetic when the read rate, origin capacity, or hit ratio changes. If the hit ratio falls to an assumed 60%, misses become 2,000 × 0.40 = 800 reads/s, exceeding the measured limit by 800 − 600 = 200 reads/s. That 60% case shows why cache effectiveness should be measured on the actual key distribution rather than selected from a general rule.

§5 · Mechanism costs

Follow costs across component boundaries

Each mechanism moves a cost rather than simply adding capacity. Replication can improve read service and recovery while creating lag or adding coordination to a write. Partitioning can spread writes and storage while making cross-partition queries and transactions harder. Asynchronous processing can reduce time spent waiting in the initiating request while delaying the final outcome and adding retries, duplicate handling, and queue monitoring. A cache can reduce origin work while adding another consistency boundary. These consequences depend on the particular operation and implementation; PostgreSQL's high-availability documentation distinguishes synchronous and asynchronous replication by their commit and failover behavior.

The diagram shows how moving work off the request path changes the meaning of success.

System flow
Synchronous:  client → API → validate → reserve stock → confirm order → response
Asynchronous: client → API → durable job → response: accepted
                                     └→ worker → reserve stock → final outcome

In the first line, the response can report the completed reservation if the calls succeed. In the second, the immediate response can only promise that work was accepted for processing; the client needs a way to learn the final outcome. Whether that change is acceptable is a functional decision, not merely a latency optimization. For payment and inventory, an “accepted” state must not be displayed as a confirmed purchase.

Choose consistency and recovery behavior per operation. A product popularity count may tolerate delayed updates; an order confirmation may require a current stock decision. A replica can answer the first read but may be unsuitable for the second. Synchronous replication can protect acknowledged writes from some failovers while adding commit latency and coupling writes to replica health; asynchronous replication can keep writes moving but may lose the most recent acknowledged data after a failure. The allowable loss and outage must be specified before the replication mode can be called a good trade.

§6 · Whole-system costs

Include failure, security, operations, and change cost

An option should be evaluated in the states it creates when something is slow or unavailable. A synchronous dependency can make the caller fail when the dependency fails; an optional dependency can be omitted or replaced with an agreed fallback. A cache failure can overload the origin. A partitioning scheme can confine a failure to one group of users, but only if routing and shared services do not rejoin those groups into a single failure domain. Identify the user-visible response, the affected population, and the signal that detects each mode.

Worked exampletwo required dependencies

Consider a request that succeeds only when two required services both respond correctly. Assume each service is available for 99.9% of requests and, solely for this calculation, assume their failures are independent. The probability both succeed is 0.999 × 0.999 = 0.998001, or 99.8001%. The failure fraction is 1 − 0.998001 = 0.001999, or 0.1999%. Check: 99.8001% + 0.1999% = 100%. This is an illustrative request-success calculation, not a time-based downtime promise. If failures share a network, database, or release, independence does not hold; measure the composed user journey instead of multiplying component percentages.

Security and correctness rules may eliminate a superficially faster option. An authorization timeout cannot silently become permission to proceed, and an unrecorded stock reservation cannot be presented as confirmed if the invariant requires durable reservation. Privacy choices also affect trade-offs: storing less personal data can reduce risk and future deletion work, though it may limit personalization. These are design requirements to name explicitly rather than costs to hide in a performance comparison.

Count operational cost over the likely life of the system. A second datastore adds migrations, backup and restore procedures, monitoring, access control, incident paths, and staff knowledge. A service split adds network calls and independent deployment and versioning; it may also reduce the blast radius of a change when ownership and isolation are real. A simpler baseline often wins until a measured bottleneck or ownership need justifies the new boundaries.

§7 · Decision records

Record the choice and define a revision trigger

Write down the selected alternative, rejected alternatives, assumptions, measured evidence, user-visible consequences, and remaining risks. A decision record preserves why a choice made sense at the time; later evidence can supersede it without rewriting history. Martin Fowler's description of architecture decision records emphasizes context, alternatives, rationale, and consequences.

The diagram shows how a decision remains connected to evidence after implementation.

System flow
Requirements → alternatives → decision → implementation → measurement
      ↑              ↑                                  │
      └──────── revised assumptions or targets ←────────┘

Read the loop as an invitation to revise a choice when measured behavior changes, not as permission to change an agreed requirement silently. A reversible cache configuration can be tested and rolled back quickly. A partition key or public API contract can be expensive to change because data and clients depend on it, so it deserves more evidence before commitment. A revision trigger might be sustained origin reads above the measured safe rate, cache hit ratio below the needed level, an untested failover path, or a new requirement for immediate visibility. Assign ownership for measuring the trigger and for deciding what to do when it fires.

· · Review

Common mistakes

Comparing technologies without a shared workload. A database, queue, or cache can look superior when each is evaluated on a different traffic mix or failure condition. Fix the user journey, peak load, measurement point, and correctness rules before comparing options.

Turning an illustrative threshold into a universal rule. “Partition above a certain writes-per-second number” ignores record size, indexes, hardware, transactions, hot keys, and latency targets. Measure the relevant workload and use thresholds as hypotheses to test, not as architecture laws.

Counting the benefit but hiding the new failure mode. A cache lowers origin traffic while creating stale reads and a cold-start load spike; a queue shortens the initiating request while delaying completion. Describe the new user-visible state and test the failure path before accepting the option.

Treating every objective as equally negotiable. An order invariant, authorization rule, or required deletion obligation cannot be traded away merely to improve latency. Separate hard constraints from targets the product can renegotiate, then compare only feasible options.

Recording a decision without a revision condition. A diagram and a list of pros and cons explain the present choice but do not tell a future team when it stops fitting. Record the assumptions, measure the quantities that could change them, and name who reviews the decision.

· · Exercises

Practice questions

These questions mix recall, calculation, and application across the guide; each answer is collapsed beneath its question to be opened after working out an answer.

Question 1 · distinction

For checkout, classify “an order cannot be confirmed without reserved stock,” “p99 response time should be under 500 ms at the agreed peak load,” and “peak reads are expected to be 2,000 per second.” Which statement may eliminate an alternative outright, and which should be verified as an assumption?

Answer

The stock rule is a correctness invariant and, if mandatory, eliminates any option that confirms before reservation. The p99 statement is a quality target that needs a measurement rule and agreement about whether it can change. The peak-read statement is a workload assumption until supported by observed traffic or a credible forecast. All three matter to a design, but they play different roles in accepting or rejecting an alternative.

Question 2 · calculation

At an assumed peak of 3,000 reads/s, an origin can sustain 900 reads/s at the required latency. What minimum cache hit ratio avoids exceeding that origin limit, and how many reads/s reach the origin at an assumed 75% hit ratio?

Answer

The maximum miss fraction is 900 ÷ 3,000 = 0.30, so the minimum hit ratio is 1 − 0.30 = 0.70, or 70%. At a 75% hit ratio, misses are 3,000 × (1 − 0.75) = 750 reads/s, leaving 900 − 750 = 150 reads/s below the measured limit. Check: the cache serves 3,000 × 0.75 = 2,250 reads/s, and 2,250 + 750 = 3,000.

Question 3 · application

A team proposes returning “order confirmed” as soon as a job has been queued, before stock reservation. What trade-off has been described incorrectly, and what contract could make the queued design honest?

Answer

The proposal treats earlier acknowledgement as earlier completion. If confirmation requires reserved stock, the queued design violates a functional invariant rather than merely changing latency. It could return “accepted for processing,” expose a pending state, and provide a way to retrieve or receive the final confirmed or rejected outcome. That revised contract needs product approval and tests for duplicate jobs and failed reservations.

Question 4 · misconception

Why does adding a read replica not guarantee both fresher reads and faster writes?

Answer

The replica is another copy. If it receives changes asynchronously, reads may lag behind accepted writes; if the primary waits for it before acknowledging writes, the write path gains a network and replica-health dependency. The actual effect depends on replication mode, read routing, and workload. The design must state which operations may read from a replica and what data loss or delay is acceptable.

Question 5 · open-ended

A product catalogue grows from modest traffic to a read-heavy global workload. Describe how you would compare a primary-only design, read replicas, and a cache; include failure behavior, security or privacy, operating cost, and a trigger for revisiting the choice.

Answer

First define the catalogue reads, peak rate, p99 target, acceptable freshness, write rate, and geographic distribution. Load-test the primary baseline. Compare replicas and cache against the same workload, measuring origin load, end-to-end latency, lag or staleness, failover behavior, and total operating effort. For a cache, test cold starts and origin overload; for replicas, test lag and promotion. Keep private or personalized catalogue fields within their access rules and avoid copying unnecessary data to public caches. Record the selected option and revisit it if measured p99, origin saturation, hit ratio, replica lag, or regional demand crosses an agreed threshold.

· · Finish

Review checklist

Without consulting notes, state the outcome, hard constraints, quality targets, workload, and assumptions for a choice; compare feasible alternatives on common dimensions; calculate where a capacity or reliability assumption changes the result; describe the costs introduced by copies, partitions, and queues; include failure, security, privacy, and operating consequences; and record the decision with evidence and a measurable revision trigger. A reader who can do all of these has covered the material.