System Design Methodology and Trade-off Analysis Questions
The end-to-end approach to an open-ended design problem and the judgment that resolves it: clarifying scope and constraints, gathering functional and non-functional requirements, capacity and back-of-envelope estimation, and mapping requirements to a high-level architecture, then reasoning explicitly about competing options on cost, complexity, latency, and reliability to defend a choice. Covers driving a design interview from ambiguity to a proposal, trade-off frameworks, decision-making under uncertainty and incomplete information, reversible-versus-irreversible decisions, and defending choices under scrutiny. The process-and-judgment skill underneath every system-design case study.
For a content-moderation system, would you run every post through one large general-purpose model, or a cheap first-pass filter that only escalates uncertain cases to an expensive model? How do you decide?
Sample Answer
Direct answer
A cascade, a cheap filter first and an expensive model only on the fraction it is unsure about, wins whenever the input mix is skewed toward easy cases, because it lets you pay the expensive model's cost only on the hard tail. A single large model wins when you cannot build a cheap filter with high enough recall on the escalation decision itself, since a weak filter silently drops cases that needed the expensive model's judgment.
Structured elaboration
- Cascade design: a cheap stage-1 classifier resolves confident cases directly; anything below a confidence threshold is escalated to the expensive stage-2 model.
- What matters most: not the cascade's average accuracy, but the stage-1 filter's recall on "this needs escalation," a miss there means the expensive model never sees a case that needed it.
- Complexity cost: two models to version and monitor for drift, and request latency now varies by path length, some requests take one hop, some take two.
- Single model: simpler to operate, but every request pays the expensive model's full cost, even the easy 90%.
Worked example
10 million posts/day, cheap filter $0.0001/post, expensive model $0.01/post, and the filter confidently resolves 90% while escalating the other 10%:
cascade cost=10,000,000×$0.0001+1,000,000×$0.01=$1,000+$10,000=$11,000/day
all-expensive cost=10,000,000×$0.01=$100,000/day
That is roughly 89% cheaper. But if the filter's recall on "needs escalation" is only 95% against a true escalation population of 1,000,000:
missed escalations=1,000,000×(1−0.95)=50,000/day
50,000 posts a day get moderated by the wrong tier, a real cost that has to be weighed against the $89,000/day saved.
Trade-offs and pitfalls
Cascades only make sense if you can actually measure the filter's recall on the escalation decision, not just its overall resolve rate. Latency variance (a two-hop tail versus a one-hop median) can also blow past a p99 budget if not accounted for.
What the interviewer probes next
Expect follow-ups on how you would set and validate the confidence threshold, how to monitor drift when the two models retrain on different schedules, and how adversarial inputs crafted to slip past the cheap filter change the design.
A social feed needs replies to always appear after their parent post, but the rest of the feed's propagation can be eventually consistent. How would you design the consistency model for this one feature, and what would you measure to confirm ordering and staleness stay within an acceptable range?
Sample Answer
Direct answer
Give the reply-to-parent relationship a strong, causal ordering guarantee (a reply is never visible before the post it replies to), while letting everything else in the feed (impression counts, non-causal fan-out, feed ranking) settle down eventually. Achieve the causal guarantee without a full linearizable write path by attaching a compact causal timestamp to each write and holding a reply back at the read side until its parent is locally visible. Confirm it worked by measuring the ordering-violation rate directly (aim for effectively zero) and the write-to-visibility staleness distribution, not by trusting the design on paper.
Structured elaboration
Framing the guarantee
This is a per-feature consistency decision, not a system-wide one: only the parent-to-reply edge needs an ordering guarantee, so only that edge should pay for it. Making the whole feed strongly consistent to protect one relationship is the wrong instinct.
Mechanism: causal delivery, not full consistency
- Tag every write with a hybrid logical clock (HLC) timestamp, a logical clock that mixes physical time with a counter so causally related events can be ordered without comparing a full history per item.
- A reply carries a dependency: (parent_id, parent_HLC).
- At the delivery point in each region, hold a reply in a small buffer until its parent is present locally, showing a short "loading" state if needed, then release it. This gets you causal consistency (a specific point between strict linearizability, where every operation appears to happen instantly in one single global order that every reader sees the same way, and plain eventual consistency, which gives no ordering guarantee at all and just "settles" eventually) for exactly the edge that needs it.
- A full vector clock (one counter per replica) would also give causal ordering, but at a metadata cost that grows with the number of regions; HLC stays a fixed few bytes regardless of region count, which is why it is the better default at this scale (see the worked example).
The absorbed risk: this is not the same anomaly as a shopping-cart race
The reply-ordering problem is a single-writer, append-only causality problem: one thing must come after another. It should not be confused with the concurrent-write anomalies a feature like a shopping cart's quantity field runs into: lost updates (two concurrent writes to the same field, one silently overwrites the other) and write skew (two transactions each read a consistent snapshot, both commit valid-looking changes that are jointly invalid). Those need a different tool, optimistic concurrency control (a version check on write) or serializable transactions, because the problem is conflicting writes to the same value, not the order two different items become visible. Naming both anomaly families shows you are choosing the guarantee to fit the failure mode, not applying one mechanism everywhere.
Decision criteria to reuse elsewhere in the feed
Ask, for each field or edge: does a violation change what a user believes happened (a causality break) or does it just show slightly stale aggregate state (a like count)? Is the anomaly a mis-ordering (needs causal or session guarantees) or a lost or conflicting write (needs concurrency control)? What is the cost of buffering or retrying versus the cost of a global synchronous commit?
Worked example
Assume a mid-size product doing 5,000,000 replies per day globally, replicated across 6 regions.
Metadata overhead, HLC versus a full version vector (worst case, one entry per region that has touched the thread):
HLC size≈12 bytes (fixed) Version vector size≈6×12 bytes=72 bytes (worst case) Extra bytes/day=5,000,000×(72−12)=300,000,000 bytes≈286 MiB/dayThat gap is why HLC is the better default once you are geo-replicating at this volume: the version vector's cost scales with region count, HLC's does not.
Now size the read-side buffer. Assume cross-region replication lag has a 99th-percentile (P99) of 300 ms (illustrative; in practice you would pull this from your own replication metrics, not assume it):
buffer timeout=300 ms⇒covers≥99% of replies without a remote fetch fallback rate≈1%×5,000,000=50,000 reads/day≈0.58 reads/sec averageFifty thousand read-repair fallbacks a day is cheap; that number is what tells you a 300 ms buffer is a reasonable default rather than a guess.
Trade-offs & pitfalls
- Buffer timeout is the main dial: too short and you push load onto cross-region read-repair; too long and users occasionally see a stale placeholder instead of the reply.
- Hot threads (a viral post with a reply storm) can blow past the default buffer's assumptions; the fix is to synchronously fast-path-replicate just the parent for hot threads, not to raise the global timeout for everyone.
- Pitfall: conflating "causal ordering for one edge" with "the whole feed is strongly consistent." Interviewers listen for whether you can name the narrow guarantee you actually need.
- Pitfall: monitoring only the design's intent ("we use causal delivery") instead of the outcome (measured violation rate, measured staleness). A design without those two numbers wired up is unverified.
- Garbage-collect dependency-tracking state once a reply has been durably applied everywhere you care about; unbounded metadata retention is a quiet cost leak.
Explain the difference between eventual consistency and strong consistency. Give two product scenarios where eventual consistency is acceptable, and two where it is not, along with your reasoning.
Sample Answer
Direct answer
Strong consistency means every read after a write returns that write, as if there were only one copy of the data. Eventual consistency means replicas are allowed to disagree temporarily after a write, and are only guaranteed to converge if writes stop arriving. The trade-off: strong consistency gives simpler application logic at the cost of higher latency and lower availability during network trouble, while eventual consistency gives lower latency and higher availability at the cost of the application having to tolerate, or actively resolve, temporarily stale or conflicting data.
Structured elaboration
The consistency spectrum, not just two points
| Model | Ordering guarantee | Latency/availability cost | Needs application-level handling? |
|---|---|---|---|
| Eventual | None across unrelated writes; replicas converge with no fixed bound if writes stop | Lowest | Yes: conflict resolution, and no built-in bound on staleness |
| Causal | Writes that are causally related (a reply, then its parent comment) are seen in the same order everywhere; unrelated writes can still reorder | Moderate | Yes, but less: needs the system to track causal relationships (named here, not derived) |
| Strong (linearizable) | Every read sees the latest write immediately, everywhere | Highest, and reduced availability under partition | Minimal: the store does the work for you |
Why "eventual" has no built-in deadline
"Eventually" is not a duration; it is a promise that convergence happens once writes stop. The actual staleness window at any moment depends on the replication pipeline's replay capacity versus the current write rate (worked example below), which is a capacity problem, not a fixed property of the word "eventual."
Worked example
Suppose a replication pipeline can apply writes at 5,000 writes/sec sustained, and normal traffic sends 3,000 writes/sec. The replica keeps up, and staleness stays bounded by pure network propagation delay (milliseconds). If a promotional event spikes incoming writes to 6,000 writes/sec, the pipeline falls behind by:
6,000−5,000=1,000 writes/sec of backlog
so after 60 seconds of that spike, the replica is:
1,000×60=60,000 writes behind
an ever-growing staleness window until the spike ends or the pipeline gets more replay capacity. This is the concrete question an eventual-consistency design has to answer: not "how long is eventually," but "what happens to staleness when write rate exceeds replay capacity, and what backpressure or scaling kicks in when it does."
Two scenarios where eventual consistency is acceptable
- Social feed likes and comment counts: a like missing for a few seconds is invisible to the user experience and self-corrects on the next refresh.
- Near real-time analytics dashboards: aggregates lagging by seconds is normal and expected, and nobody is making a financial decision off the exact current second.
Two where it is not
- Financial account balances and transfers: a stale read can let a user believe funds are available when they aren't, or let two operations both proceed against the same balance.
- Inventory reservation at checkout: a stale stock count can oversell an item, which is a customer-facing failure and an operational one (an order that can't actually be fulfilled).
The same distinction shows up at the feature level in machine learning. An online feature store computing a rolling 7-day purchase count can safely be eventually consistent; a few seconds of lag rarely changes a recommendation. But if the offline training pipeline computes that same rolling count from a different, out-of-sync snapshot than the one used at serving time, the model trains on a systematically different feature distribution than it sees in production. That training-serving skew is a strong-consistency requirement in disguise: the question isn't "is the count right," it's "was the count computed from the same consistent point-in-time snapshot on both sides."
Trade-offs & pitfalls
- Assuming "eventual" implies a short, informal default delay; there is no bound unless the team designs one, backed by a replay-capacity-versus-write-rate analysis like the one above.
- Reaching for causal consistency without realizing it requires tracking machinery (commonly version vectors: a small per-replica counter attached to each write that lets the system tell whether one write happened before, after, or concurrently with another, named here only) to know which writes are causally related; it is not a free upgrade over plain eventual consistency.
- Applying strong consistency everywhere "to be safe" and paying its latency and availability cost even for the majority of operations, like a social feed's like count, that never needed it.
How do you decide the right granularity when splitting a system into services? Walk through how coupling versus cohesion, data ownership, and team boundaries change your answer.
Sample Answer
Direct answer
Split along business capability and data ownership, not by technical layer, and treat coupling and cohesion as the actual test: a service boundary is right when it groups things that change together and separates things that don't, and when one team can own its full lifecycle (build, deploy, operate) without waiting on another team to also deploy. Team size and deployment cadence usually decide the timing more than the theory does: a well-modularized monolith can run comfortably until the coordination cost of shared deploys and shared blast radius starts to exceed the operational cost of running the same code as separate services.
Structured elaboration
The criteria, applied together
- Bounded context or business capability: one service per coherent business concept (Orders, Inventory, Billing), not per database table.
- Data ownership: the service that owns a piece of data is its only writer; everyone else goes through its API or its events, never a shared schema.
- Deployment independence: if two "services" cannot be deployed on separate schedules without breaking each other, they are one service wearing two names, a distributed monolith.
- Team boundaries (Conway's Law: a system's structure tends to mirror the structure of the team that builds it): align a service to a team that can own it end to end, so ownership and org chart don't fight each other.
- Transaction boundary: keep operations that need a real ACID (atomicity, consistency, isolation, durability) transaction inside one service; cross-service consistency should default to eventual consistency plus an explicit compensating action, not a distributed transaction.
- Chattiness: if two components exchange many synchronous calls per user request, the network hop between them is pure overhead with no ownership benefit; merge them.
The team-size-driven worked example
Consider an org at 200 people, organized as roughly 20 teams, running a well-modularized monolith with clear internal module boundaries (a modular monolith). Model the shared deploy pipeline as a single server processing one deploy at a time, 30 minutes each, across a 16-hour working day (960 minutes):
deploy capacity/day=30960=32 deploys demand at 20 teams (1 deploy/day each)=20 deploys/day utilization=3220=62.5%At 62.5% utilization there is queueing delay, but the pipeline is stable. Now grow to 500 people, roughly 50 teams, same one-deploy-at-a-time pipeline:
demand at 50 teams=50 deploys/day>32 deploys/day capacityDemand exceeding capacity on a single-server queue means the queue is unstable: it does not just get slower, it grows without bound. That crossing point, not a stylistic preference for microservices, is the concrete signal to start extracting services along the module boundaries the modular monolith already has, so teams stop sharing one serialized deploy pipeline and one shared blast radius.
Anti-patterns that signal you split wrong (or didn't split at all)
- Shared database schema across "separate" services: the clearest sign of a distributed monolith with extra network hops.
- Splitting by technical layer (a UI service, an API service, a database-access service) instead of by capability: nothing can deploy alone, because every user-facing change touches all three.
- A "god" service or shared library that every team depends on for routine changes: it recreates the same coordination bottleneck a monolith had, with worse debugging.
- Over-splitting a capability that still needs real ACID guarantees just because a diagram looks tidier with more boxes.
Trade-offs & pitfalls
- Splitting too early, before the coordination cost above actually bites, buys distributed-systems complexity (network calls, partial failure, eventual consistency) for a coordination problem you didn't have yet.
- Splitting too late means the deploy-pipeline math above turns into a real, measured queue of waiting teams, not a hypothetical.
- The bounded-context choice is the expensive one to get wrong: correcting a wrong service boundary later means a data migration, not just a configuration change.
- Watch for teams treating microservices as a goal instead of a response to a specific coupling problem; the checklist above should produce the boundary, not the other way around.
Explain the CAP theorem: what do consistency, availability, and partition tolerance mean, and why can a distributed system only keep two of the three guarantees once a network partition happens? Give one real system that favors consistency (CP) and one that favors availability (AP), and explain what each gives up.
Sample Answer
Direct answer
CAP theorem says a distributed system cannot simultaneously guarantee all three of Consistency (every read returns the most recent write), Availability (every request receives a non-error response), and Partition tolerance (the system keeps working when some nodes cannot reach others). Because real networks drop packets and links fail, partition tolerance is not optional, so the actual choice during a partition is between consistency and availability. Systems like Google Cloud Spanner lean CP (some requests are blocked or rejected to stay correct); systems like Cassandra or Riak in their common tuning lean AP (every request gets an answer immediately, even a possibly stale one).
Structured elaboration
The three letters, precisely
- Consistency: every node that answers a read returns the same, most-recent value; there is no "which replica did you happen to hit" effect.
- Availability: every request that reaches a non-failed node gets a response, in bounded time, even if that response can't be proven up to date.
- Partition tolerance: the system continues operating even though some messages between nodes are lost or delayed.
Why "CA" is not a real option
A system that isn't partition tolerant is only correct as long as the network never drops a message, which no real, multi-node network guarantees. So "CA" only describes a single-node system, or a distributed system that hasn't yet been tested by a real partition; it is not a deployable choice for a genuinely distributed service.
CP vs AP
| Choice | Kept | Given up during a partition | Example system | Choose when |
|---|---|---|---|---|
| CP | Consistency, partition tolerance | Availability: some nodes refuse or delay requests rather than risk a wrong answer | Google Cloud Spanner, CockroachDB, a single-leader relational database | Correctness has a real cost of being wrong (money, regulatory records) |
| AP | Availability, partition tolerance | Strong consistency: a read may return stale or conflicting data that the application or client has to reconcile | Cassandra, Riak, DynamoDB in its default tuning | Uptime and low latency matter more than a few seconds of staleness |
PACELC, the extension worth naming
PACELC (if Partitioned, choose Availability or Consistency; Else, choose Latency or Consistency) points out that CAP only describes what happens during a partition. Even with no partition at all, a system still has to decide, on every write, how synchronously to replicate: wait for every replica to acknowledge (favors consistency, costs latency) or acknowledge after one replica and replicate the rest in the background (favors latency, costs consistency). An AP system's day-to-day behavior is really governed by its PACELC answer, not its CAP answer, since partitions are rare and normal operation is not.
Quorum tuning as the middle ground
Many stores let you tune how many replicas must acknowledge a write (W) and how many must respond to a read (R) out of N total replicas, sliding the same system between CP-like and AP-like behavior per operation rather than committing the whole deployment to one label. The mechanics of quorum protocols are their own topic; the point for this answer is that the CP/AP choice is a dial, not a single global switch.
Worked example
Take three replicas (N = 3) with a write quorum W = 2 and a read quorum R = 2, so that any write and any read are guaranteed to overlap on at least one replica:
W+R>N⇒2+2>3
Now a partition splits the three replicas into a group of 2 and a group of 1.
- The group of 2 can still assemble a quorum (2 out of the required 2), so it keeps serving reads and writes: consistent and available, on that side.
- The lone replica cannot assemble a quorum (1 is short of 2), so it must refuse requests rather than answer from possibly-stale local data: it sacrifices availability to avoid sacrificing consistency.
If the same store were instead configured for W = 1, R = 1 (an AP-leaning setting), both sides could keep accepting writes independently during the same partition, and the two sides would need to reconcile any conflicting writes once the partition heals; nothing here changes the network, only the dial.
Two alternate ways to see the same trade, folded in from adjacent scenarios: to a non-engineer stakeholder, the choice can be framed without the theorem's name at all: "during an outage, would you rather the app show a slightly out-of-date number and stay up, or freeze and show an error until we're sure the number is right?" That question is CAP in plain language. The same trade also shows up in machine learning infrastructure: an online feature store serving features to a live model at inference time typically leans AP (serve the last known values within a freshness window rather than block the request), while the offline pipeline that snapshots those same features for a training run typically leans CP (a training set built from a partially-written snapshot silently corrupts the model, so the pipeline waits for a consistent point-in-time snapshot instead).
Trade-offs & pitfalls
- Treating "pick 2 of 3" as one permanent, whole-system architecture decision, instead of a per-operation or even per-data-type decision a single platform can make differently in different places.
- Conflating CAP's "C" with the "C" in ACID (atomicity, consistency, isolation, durability): CAP consistency is about replicas agreeing with each other; ACID consistency is about the database enforcing its own integrity constraints. They answer different questions and can both be true or false independently.
- Forgetting PACELC: an AP system still owes an answer to "how synchronously do you replicate during normal operation," since that decision affects latency and staleness every day, not just during rare partitions.
- Citing "CA" as if it were a legitimate label for a real distributed deployment, rather than a description of a single-node system or an untested assumption.
Unlock Full Question Bank
Get access to all System Design Methodology and Trade-off Analysis interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.