Talking Through Trade-offs

How to explain a design choice in an interview: state what it gives, what it costs and when you would change it, shown on five common choices.

16 minLesson 1 of 5
On this page
  1. Where trade-off answers fit in the interview
  2. The five parts of a trade-off answer
  3. The five parts applied to common choices
  4. Problems that weaken a trade-off answer
  5. In the interview
  6. What to practise next

A trade-off answer explains a design choice by saying what the choice gives you, what it costs and when you would choose differently. Interviewers ask "why did you pick that?" to find out whether you understand the alternatives, and a good answer shows that your choice came from the requirements and not from habit.

Without this structure, answers sound like "SQL is more reliable" or "NoSQL scales better". Such a sentence does not say what the choice costs or when it stops being right, so the interviewer cannot tell whether you understand the choice or are repeating a rule. Two candidates can pick the same database and still get very different scores for how they explain it.

Where trade-off answers fit in the interview

A trade-off answer connects a requirement from the first minutes of the interview to a choice in the design.Requirements and estimates to Design choice (drives); Design choice to Spoken trade-off answer (explained by); Spoken trade-off answer to Interviewer follow-up (tested by).Requirements andestimatesDesign choiceSpoken trade-offanswerInterviewerfollow-updrivesexplained bytested by
A trade-off answer connects a requirement from the first minutes of the interview to a choice in the design.

The five parts of a trade-off answer

A full answer has five parts, spoken in this order: the option you choose, what it gives you, what it costs, why it fits this problem, and what would make you switch. The option, the cost and the reason it fits are expected for every decision. The condition that would change the choice is worth giving for the important decisions.

The option and what it gives you

Start with the decision in one sentence, such as "I'll use a relational database for orders", and then name the benefit in concrete terms: "because an order and its stock change must succeed or fail together." A benefit that could apply to any database ("it is reliable") is not concrete. A benefit that names a requirement of this system is.

The cost

Every choice makes something worse, and you should say what. This part is expected every time, because an interviewer who hears only benefits will ask for the cost anyway, and volunteering it first shows that you see the whole picture. For the relational database the cost is that a single primary node takes all writes.

Why it fits here

Tie the choice to a fact from your requirements or estimates, such as a read-to-write ratio, a latency target or a rule like "no double bookings". This part is also expected every time, because it is the evidence that you decided on purpose. Without it, the benefit and the cost are only a general comparison.

What would change the choice

Say which change in the requirements or the load would make you pick the other option: "If writes grew to tens of thousands a second and every read were by order id, I would move to a key-value store partitioned by order id." Use this part for the three or four decisions that shape the design. For small decisions it can be left out, and a clause such as "round robin, since the servers are identical" is enough.

When two options are equally good for the problem, say so and say how you break the tie: "Both work at 200 writes a second, so I'll use the one the team already runs."

The five parts applied to common choices

SQL or NoSQL

Frame this choice by access pattern: what you read and write together, and whether you need a transaction across several rows. The choosing a database lesson covers the categories. A relational database is the better fit when several records must change atomically or when you need to query the data in ways you did not plan in advance. A key-value or document store is the better fit when almost every access is a lookup by one key and the write rate is higher than one primary can take.

Defending the databaseStrong answer
Interviewer

Why a relational database for orders?

You

An order writes the order row and decrements stock, and both must happen or neither. A relational database gives me that transaction. The cost is that one primary takes all writes. At 200 orders a second, against a few thousand writes a second that one primary can handle, that is fine. If we grew to tens of thousands a second and every read was by order id, I'd move to a key-value store partitioned by order id and handle stock with a separate reservation step.

Cache or no cache

Sometimes the strongest answer is to leave a component out. An admin tool that makes 5 reads a second would gain only an extra component and stale data from a cache. A user-profile service is different: if reads are about 100 times as frequent as writes and a few profiles get most of the views, a cache removes most of the database reads. You would say that you put a cache in front of the profile table with a five-minute TTL and a delete on every write, that the cost is that other users can briefly see a stale profile, and that you would remove the cache if writes became as common as reads, because the hit rate would then drop.

Synchronous or asynchronous

Ask whether the user needs the result of this step before you can answer them. A card charge must finish first, because the user needs to know whether the payment worked. A receipt email does not, so it can go through a queue, and an outage at the email provider then stops being the shopper's problem.

Checkout with the email step made asynchronousUse the arrows or ← → keys
  1. Checkout with the email step made asynchronous, step 1Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorEmail queueOrders DBEmail workerEmail providerPOST /orderschargeinsert ordersend
    shopper waiting
    yes

    1A shopper places an order.

  2. Checkout with the email step made asynchronous, step 2Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorEmail queueOrders DB9071 pendingEmail workerEmail providerPOST /orderschargeinsert ordersend
    shopper waiting
    yes

    2It writes order 9071 as pending first, so no card is ever charged without a record of why.

  3. Checkout with the email step made asynchronous, step 3Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorapprovedEmail queueOrders DBEmail workerEmail providerPOST /orderschargeinsert ordersend
    shopper waiting
    yes

    3It charges the card synchronously, with the order id as the idempotency key so a retry cannot charge twice. The shopper must know the result, so they wait.

  4. Checkout with the email step made asynchronous, step 4Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorEmail queueOrders DB9071 paidEmail workerEmail providerPOST /orderschargeinsert ordersend
    shopper waiting
    yes
    queued emails
    1

    4It marks the order paid and queues a "send receipt for 9071" message, without waiting for the email.

  5. Checkout with the email step made asynchronous, step 5Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorEmail queueOrders DBEmail workerEmail providerPOST /orderschargeinsert ordersend
    shopper waiting
    no
    queued emails
    1

    5The shopper sees "Order placed". Adding the message to the queue is fast, and the email is sent later without the shopper waiting for it.

  6. Checkout with the email step made asynchronous, step 6Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorEmail queueOrders DBEmail workerEmail providerdownPOST /orderschargeinsert ordersend
    shopper waiting
    no
    queued emails
    1

    6The worker takes the message and calls the email provider, which is down.

  7. Checkout with the email step made asynchronous, step 7Shopper to Checkout service (POST /orders); Checkout service to Card processor (charge); Checkout service to Orders DB (insert order); Checkout service to Email queue, asynchronous; Email queue to Email worker, asynchronous; Email worker to Email provider (send).ShopperCheckout serviceCard processorEmail queueretry in 60 sOrders DBEmail workerEmail providerdownPOST /orderschargeinsert ordersend
    shopper waiting
    no
    queued emails
    1

    7The message goes back on the queue to retry in a minute. Orders keep succeeding; called directly, this outage would fail every checkout.

1 / 7

The cost of the asynchronous step is that the email can arrive minutes late, and a retry can send it twice unless the worker is idempotent. There is also a gap if checkout crashes between marking the order paid and enqueueing the message, which loses the receipt. The usual fix is an outbox: the email job is written in the same database transaction as the order, and a separate process moves it to the queue. A login code that the user is waiting for would change the choice, because it must be sent right away.

Strong or eventual consistency

Use the terms precisely. Strong consistency (linearizability) means that once a write is acknowledged, every later read sees it. Eventual consistency means that replicas converge if writes stop, with no promised limit on how stale a read can be. A replica that "lags by about a second" is therefore eventually consistent and not strongly consistent. The CAP and consistency lesson covers the models and explains why a quorum is not the same as strong consistency.

One feature can need both. For ticket booking, two people must never get seat 14C, so a reservation is a conditional write on the primary that takes the seat only if it is still free. The seat map that people browse can be a few seconds stale, because the reservation itself is always checked. If the system went multi-region, you would make one region the owner of each event's seats.

Push or pull

Push, also called fan-out on write, copies each new post into the feed of every follower when it is posted, so reading a feed is one lookup. Its cost is that a post by an account with 10 million followers causes 10 million writes. Pull, also called fan-out on read, stores each post once and builds a feed when the user opens it, by reading the posts of every account they follow and merging them. Its cost is that every feed load does that work. Push is right when most accounts have a few hundred followers and feeds are read far more often than posts are written. Pull is right when follow counts are small and feeds are rarely opened.

Most real systems use a hybrid: push for ordinary accounts, and pull at read time for the few accounts with huge follower counts. The cost of the hybrid is two code paths and a follower-count threshold to tune. The news feed case study works through the numbers.

Feed delivery: where to pay the fan-out cost
OptionGood atBad atPick it when
Push (fan-out on write)A feed read is one lookup of a ready-made list.A post by an account with 10 million followers costs 10 million writes.Most accounts have a few hundred followers and reads far outnumber posts.
Pull (fan-out on read)A post is one write, whoever posts it.Each feed load reads every followed account and merges the results, which is slow and costly.Follow counts are small and feeds are rarely opened.
Hybrid Usual defaultOrdinary accounts are pushed and the few huge accounts are pulled at read time.There are two code paths and a threshold to tune.Follower counts are very uneven, which is the usual interview case.

Problems that weaken a trade-off answer

Listing pros and cons without choosing

"SQL has transactions, NoSQL scales horizontally, and both have their place" describes the options but makes no decision. The interviewer asked you to choose. Pick one, give the reason, and then say what would make you pick the other.

Naming only the flaws of the option you rejected

If you describe only what is wrong with the alternative, the interviewer will ask what is wrong with your own choice. State the cost of your choice yourself, because doing so before being asked shows that you understand it.

In the interview

Use the full five-part answer for the three or four decisions that shape the design, and a single clause for the minor ones. Always give the cost and the reason it fits, and give the switching condition for the major decisions.

Questions to expect:

  • "Why this option and not the other one?" Give the strength of the option you rejected first, and then the specific cost that rules it out for this problem. Rejecting an option without crediting what it does well sounds like a memorized rule.
  • "What is the downside of your choice?" Name the cost directly and say how you would limit it. For example, a cache can serve stale data, so you use a short TTL and read from the database for anything that must be exact.
  • "What if you are wrong about that number?" Say what breaks first and how you would notice, such as write latency rising on the primary. Then say what you would change, for example partitioning the data or adding a queue.
  • "What would make you change this decision?" Name a specific change in the requirements or the load, such as write volume growing by a factor of ten or users having to see a result before the request returns. A vague answer like "if it does not scale" does not count.
  • "What if I disagree with your choice?" Do not defend it by repeating it. Ask which requirement the interviewer has in mind, and if it differs from the one you assumed, work through the choice again with that requirement and say what changes. If the interviewer is only testing you, restate the cost and the reason it fits and stay with the choice.
  • "Can you have both?" Often you can, by choosing per operation. A ticket system can use a strongly consistent conditional write for reservations and a slightly stale cache for the seat map.
Asked to justify a queueStrong answer
Interviewer

Why did you put the thumbnail generation behind a queue?

You

Users do not need the thumbnail to finish an upload, so a queue lets the upload return as soon as the file is stored. The cost is that a post can show a placeholder for a few seconds, and failed jobs need retries. If users had to see the thumbnail before posting, I would generate it inline.

Interviewer

What if the queue falls behind?

You

Uploads would still succeed and only the thumbnails would be late. I would alert on queue depth and add workers, and the placeholder keeps the page usable meanwhile.

Quick check

Which part of the answer is missing? "I'll queue the thumbnail jobs so uploads return fast. That fits, since users don't need the thumbnail right away. If users had to see the thumbnail before posting, I'd do it inline."

A candidate says "profile reads are strongly consistent because they go to a replica that lags under a second." What is wrong?

Most users have about 300 followers and a few have 5 million. Under pure push, how many feed writes does one post by a 5-million-follower account cost, and what do you choose?

What to practise next

Read System Design Mistakes, then practise giving the five-part answer on Design Ticket Booking.