All jobs / Backend developer / Distributed Systems
Backend developer interview question · 3–5 years
The interviewer asks: “The user saves a profile then immediately GETs it from another region and sees the old one. Why?” Strongest answer?
The strongest answer
They read a replica that hasn't applied the write. For read-your-writes I stick to the primary (or a session that waits for the write's LSN). Cross-region lag is normal.
Why it works
Exactly. Replication is asynchronous unless you paid for sync. Name the consistency: RYW after a write, eventual for other readers.
What a good answer covers
- Async replicas lag; that's expected.
- Read-your-writes → primary or wait-for-LSN.
- Don't global-flush as a reflex.
- Don't serialise the world on the primary.
Answers that fall short
- Close, but not the strongest: The cache is wrong; I flush Redis globally on every profile save.
Flushing a global cache on every save is a stampede and may not even be the bug — replica lag still exists. - Weak: The write must have failed; I'll retry until GET matches.
Retrying GET until it matches can loop for seconds and still hide the real model. Read the primary for that session instead. - Red flag: I'll make every GET a lock on the primary so this can never happen.
Locking every read on the primary throws away the replica fleet. Use it for the session that just wrote, not for the internet.
Who gets asked this
More Distributed Systems questions
- 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?”…
- The interviewer asks: “Recommendations are down. Checkout still needs to work. What do you do?” Strongest…
- The interviewer asks: “We're adding a search index. Can the API write DB and Elasticsearch in one request?”…
- What happened, and what actually protects the write?
- The interviewer asks: “Active-active in two regions — what's the hard part?” Strongest answer?
- The interviewer asks: “A client retries POST /payments because of a timeout. How do you not charge twice?”…
- The interviewer asks: “A downstream HTTP call timed out. Do you retry?” Strongest answer?