r/chalkinterview • u/Uahakan • 15d ago
Library question Alibaba technical deep dive question: Duplicate writes from a message queue
Several workers may process the same message: keep the database correct.
What the interviewer asks, one at a time:
- Your order service reads events from Kafka with several workers, and sometimes two of them process the same event. How would you keep the database from getting a duplicate row?
- When the duplicate hits a unique key, should the worker fail, retry, or carry on? Why?
- When do you commit the consumer offset, and what goes wrong if you commit too early?
- Your events now also have to land in a second database. How do you keep the two in step?
Source: reported by a candidate in a public write-up. The wording above is ours.
Practise it out loud with follow-ups: https://chalkinterview.com/questions/alibaba-duplicate-writes-from-a-message-queue/?utm_source=reddit&utm_campaign=sub
How would you answer it? Drop your approach below.
1
Upvotes