Engineering Decisions Senior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

  1. 1. A social feed serves mostly users with a few hundred followers, plus some accounts with 50M. Reads must be fast. How do you build timelines?

    Correct answer: A hybrid: fan-out on write, except for huge accounts

    Precomputed timelines make reads fast for most accounts, and merging huge accounts at read time avoids millions of writes per post. Pure fan-out on write fits a network with no extreme accounts, but one celebrity post would flood the write path. Pure fan-out on read fits low-read systems and stays simple, but assembling each feed on every open gets too slow at this scale.

  2. 2. A store serves product pages from a global CDN. Descriptions rarely change, but a corrected price must appear within seconds. What's the caching strategy?

    Correct answer: A long CDN TTL plus tag-based purges on change

    A long TTL keeps the hit rate high, and purging by tag applies a price fix everywhere within seconds. A short TTL fits content with no change events to hook into, but it sends far more traffic to the origin. Skipping the CDN fits fully personalized pages, and here it would give up speed for visitors around the world.

  3. 3. A six-person startup is still searching for product-market fit, and domain boundaries keep moving. What architecture do you start with?

    Correct answer: A modular monolith with clear internal boundaries

    A modular monolith keeps refactoring cheap while boundaries move, and clean modules can become services later. Microservices fit many teams that need independent releases, but six people would spend their time on network and deployment concerns. Per-endpoint functions fit spiky, isolated workloads, while spreading a changing domain across them makes shared logic hard to evolve.

  4. 4. After saving an order, the service must publish an event to a broker. Events must not be lost, and the broker can't join a database transaction. What do you do?

    Correct answer: A transactional outbox, published by a relay

    Writing the event in the same transaction as the order means both exist or neither does, and a relay delivers it later. Publishing after commit fits events you can afford to lose, but a crash between the two steps drops the event. Publishing first fits nothing that must stay consistent, because a failed commit leaves consumers reacting to an order that doesn't exist.

  5. 5. An order spans the payment, inventory and shipping services, each with its own database. Any step can fail, and short inconsistency is acceptable. How do you coordinate it?

    Correct answer: A saga with compensating actions per step

    A saga runs local transactions and undoes finished steps on failure, which suits services that own their data and accepts brief inconsistency. Two-phase commit fits a few tightly coupled databases that all support it, but it blocks participants and hurts availability. A shared database fits services that aren't really separate, and it brings back the coupling they were split to avoid.

  6. 6. A payments ledger must survive the loss of a whole region with zero lost writes. An extra 20 ms per commit is acceptable. Which replication do you choose?

    Correct answer: Synchronous replication to a second region

    Synchronous replication confirms a commit only after the second region has it, so a region loss loses nothing, and the latency cost is accepted here. Asynchronous replication fits most products, keeping commits fast, but the last transactions are lost on failover. Nightly backups fit archives with a tolerance of hours, and for a ledger they would lose up to a full day.

  7. 7. Reads go to replicas that lag by about a second. Users complain that their just-saved profile shows old data, while others seeing it a second late is fine. What do you do?

    Correct answer: Route that user's reads to the primary briefly

    Pinning only the author to the primary for a moment fixes read-your-writes and keeps replicas serving everyone else. Synchronous replicas fit data where nobody may ever see old values, but every write would pay that latency. Reading only from the primary fits a small system, and here it would remove the capacity the replicas were added for.

  8. 8. A PostgreSQL primary is near its limit: 95% of the load is reads, and writes are modest. Growth is steady, and the team is small. What's the next step?

    Correct answer: Add read replicas and a cache for hot reads

    With a read-heavy load, replicas and a cache add capacity with little change to the application. Sharding fits a write load or dataset too big for one primary, but it costs cross-shard queries and operations a small team doesn't need yet. A NoSQL store fits data shaped around key access at huge scale, and a migration here would solve nothing the replicas can't.

  9. 9. A SaaS has 5,000 small customers and 3 enterprise clients who contractually require isolated data. How do you lay out tenants?

    Correct answer: Shared tables with RLS, dedicated databases for the 3

    A hybrid keeps small customers cheap and meets the contracts of the three that need real isolation. A database per tenant fits a few high-value customers, but 5,000 of them mean heavy costs for migrations and connections. Shared tables fit a uniform customer base, but they break the contract here, no matter how strict the filtering is.

  10. 10. A flash sale will push traffic past what the database can take, and it can't scale up in minutes. Checkout matters most, while browsing can degrade. What do you prepare?

    Correct answer: Priority load shedding that protects checkout

    Shedding low-priority requests keeps the bottleneck healthy so the most valuable path still works. Autoscaling fits load limited by app servers, but more instances only push harder on the database here. A queue fits work that can wait, like reports, while users on a live page would simply time out in it.

  11. 11. A degraded service gets three times its normal traffic, because the client, the gateway and the backend each retry three times. How do you stop the amplification?

    Correct answer: Retry at one layer, plus a circuit breaker

    Retrying at one layer stops the multiplication, and a breaker gives the struggling service room to recover. Shorter delays fit brief network blips on a healthy service, but here they would only hit it harder. Longer timeouts fit calls that are slow by nature, yet they keep threads busy and spread the slowdown to the callers.

  12. 12. You must rename a column in a 500M-row table. The app has rolling deploys, so old and new versions run together, and downtime isn't allowed. What's the plan?

    Correct answer: Expand and contract across several releases

    Adding a new column, writing to both and dropping the old one later keeps every running version working. A single rename fits a small app with one instance, but during a rolling deploy old code would break on the missing column. A maintenance window fits internal tools or rare, huge changes, and it's ruled out by the no-downtime requirement.

  13. 13. A public API runs on 40 instances, and each key may make 100 requests per minute. Small bursts are fine, but the limit must hold across instances. Where do the counters live?

    Correct answer: In a shared Redis, using a token bucket

    A shared in-memory store sees all instances and handles this rate of updates cheaply, and a token bucket allows short bursts. Per-instance counters fit rough protection against floods, but a key could reach 40 times its limit. A database row fits low-volume quotas such as monthly billing, while updating it on every request turns one row into a hot bottleneck.

  14. 14. Storing every trace costs too much, but during incidents you need the errors and slow requests above all. How do you sample?

    Correct answer: Tail-based: decide after the request has finished

    Tail-based sampling sees how a request ended, so it can keep every error and slow trace and drop the routine ones. Head-based sampling fits cheap overall statistics, and it's simple to run, but a random 1% misses most rare failures. Logs alone fit one small service, and they lose the cross-service view that tracing exists to give.