All jobs / Backend developer / Distributed Systems
Backend developer interview question · 3–5 years
The interviewer asks: “The replica is behind. Do you serve stale reads or error?” Strongest answer?
The strongest answer
It depends on the use case: a feed can be stale; a balance after a debit cannot. I name the consistency the product needs (read-your-writes, bounded staleness) and pick primary vs replica per query, not as a global religion.
Why it works
Exactly. This is a per-operation choice. Stronger consistency costs latency and availability during partitions; weaker consistency needs a UX that can live with it.
What a good answer covers
- Staleness is a product choice per read.
- Money and “did my write stick?” → primary / RYW.
- Feeds can use replicas.
- Don't busy-wait on lag.
Answers that fall short
- Close, but not the strongest: Always read the replica — that's why we paid for it.
Replicas exist for scale and failover. Using them for checkout totals is how you show yesterday's money. - Weak: CAP says we must choose one for the whole company.
CAP is a partition thought experiment, not a licence to pick one letter on a slide. You choose per decision. - Red flag: Retry the replica in a tight loop until it catches up so every read is linearisable.
Blocking until a replica catches up turns a lag spike into a site outage. Read the primary or fail that query.
Who gets asked this
More Distributed Systems questions
- The interviewer asks: “How do you publish an event only if the order row actually committed?” Strongest…
- The interviewer asks: “We need “all services succeed or none” across order, inventory and billing. What do…
- The interviewer asks: “Consumers are slow. The publisher is fast. What do you do?” Strongest answer?
- The interviewer asks: “A message fails every time. The consumer keeps retrying. What now?” Strongest answer?
- Order-status events for the same order are arriving out of order at the consumer. The topic has twelve…
- The interviewer asks: “The user saves a profile then immediately GETs it from another region and sees the old…
- The interviewer asks: “A dependency is failing. How do you stop your service from dying with it?” Strongest…
- The interviewer asks: “The outbox publisher crashed after sending but before marking sent. What happens?”…