All jobs / Backend developer / Distributed Systems
Backend developer interview question · 1–3 years
The interviewer asks: “Your queue consumer ran twice for the same message. What do you do?” Strongest answer?
The strongest answer
Assume at-least-once. Make the handler idempotent — unique key, upsert, or a processed-message table — then ack. Don't assume the broker delivered once.
Why it works
Exactly. Duplicates are normal (timeouts, rebalances). Idempotency is the consumer's job.
What a good answer covers
- Queues are at-least-once by default.
- Handlers must be idempotent.
- Ack after success.
- Duplicates are a no-op, not a crash loop.
Answers that fall short
- Close, but not the strongest: That's a broker bug; I'll switch vendors.
Every mainstream broker in 2026 is at-least-once unless you buy a very specific exactly-once story and still write idempotent handlers. - Weak: Ack before processing so I never see duplicates.
Ack-before-work drops messages on crash. That's at-most-once loss, not a fix. - Red flag: If I detect a duplicate, throw so the message retries forever.
Throwing on duplicates is a poison loop. Detect, no-op, ack.
Who gets asked this
More Distributed Systems questions
- What do you tell them, and what does it force on your code?
- The interviewer asks: “The replica is behind. Do you serve stale reads or error?” Strongest answer?
- 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…