Ctrl K
Backend · Mid-level · Theory

A queue consumer processes "award bonus points" messages, and sometimes users get their bonus twice. Why does this happen, and how do you fix it?

~4 min by voice

How to approach it

They're checking whether you understand at-least-once delivery semantics and can design an idempotent consumer, rather than hunting for a "producer bug" or hoping for exactly-once in the broker.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsСервис заказов после оплаты кладёт событие в очередь, а сервис уведомлений его читает и отправляет пользователю пуш. Какие гарантии доставки бывают, почему пользователь может получить пуш дважды или не получить вовсе, и как это чинить? И как вы гарантируете порядок событий одного заказа? Mid-levelWrite a handler for creating a payment that takes an idempotency key and the payment data and returns the result. A repeat request with the same key must not charge the money a second time, even if two identical requests arrive simultaneously on different instances of the service; you have a database and an external payment provider. SeniorСервис зачислений читает из Kafka события об успешных платежах и пополняет счёт клиента. Как вы гарантируете, что одно и то же событие не зачислит деньги дважды? SeniorWhat is a message queue, and when should backend processing be moved into an asynchronous queue? JuniorDesign a notification service for push, email and SMS, handling about fifty million notifications a day, with spikes during marketing campaigns. Senior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min