All jobs / Backend developer / Distributed Systems
Backend developer interview question · 1–3 years
A RabbitMQ consumer acknowledges each message as soon as it arrives and then processes it. Messages go missing whenever a consumer pod restarts.
What do you change?
The strongest answer
Acknowledge after the work has committed rather than on receipt — an unacknowledged message is redelivered when the connection drops — and set a prefetch so one consumer does not hold more than it can finish
Why it works
Exactly — the ack is the consumer’s promise that the work is done, and prefetch keeps the redelivery set small.
What a good answer covers
- Ack after the work commits.
- Unacked messages are redelivered.
- Set prefetch to limit the blast.
- Keep the consumer idempotent.
Answers that fall short
- Close, but not the strongest: Acknowledge at the end of processing instead of at the start
Right, and the other half is prefetch: a consumer sitting on a hundred unacked messages redelivers all of them when it dies. - Weak: Turn on publisher confirms so the broker guarantees the message is delivered
Publisher confirms cover the publisher-to-broker hop; they say nothing about a consumer that acked and then crashed. - Red flag: Have the consumer write each message to a local file first, so nothing is lost when it restarts
A file on the pod disappears with the pod, and now two places think they own the message.
Who gets asked this
More Distributed Systems questions
- The interviewer asks: “Your queue consumer ran twice for the same message. What do you do?” Strongest answer?
- 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…