CS FundamentalsVery hardProduct-company system-design interview
A message broker delivers each message at least once, so consumers sometimes see duplicates (for example after a crash before an ack). A consumer credits a wallet on each 'payment received' message. How should it be designed?
- A. Ask the broker to switch to at-most-once delivery
- B. As an idempotent consumer: record processed message ids (or use a unique key in the same transaction) and skip duplicates
- C. Process messages twice to be safe
- D. Acknowledge messages before processing them
Correct answer: B. As an idempotent consumer: record processed message ids (or use a unique key in the same transaction) and skip duplicates
With at-least-once delivery, effects must be idempotent or deduplicated. At-most-once (or acking before processing) can lose payments when a consumer crashes, which is worse.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- Match the delivery guarantee. P: the consumer acks a message before processing it. Q: the consumer acks only after processing succeeds. R…
- In CQRS, what is separated, and what is a typical consequence?
- A method has cyclomatic complexity 25. Which conclusion is most reasonable?
- A team writes acceptance criteria as 'Given a cart worth ₹900, When the user applies coupon SAVE10, Then the total is ₹810', and automates…
- A codebase reports 100% line coverage, but the mutation score is only 20%. What is the most likely explanation?
- In TDD, a developer has one failing test, assertEqual(add(2, 3), 5), and makes it pass with return 5. What is the next step according to…