The interview problem
A service commits an order but crashes before publishing its event. Design a relay that avoids lost events without claiming exactly-once delivery.
Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.
1. Scope and worked approach
Assume the order and outbox share one transactional database. Commit the business change and an event row together, using a stable event ID and aggregate sequence. A relay claims committed rows, publishes them, then records acknowledgment. Consumers atomically record processed IDs with their local effects. Keep ordering per aggregate where required; global order is unnecessary for independent orders.
2. Trace the design or derivation
Commit order and event → relay committed rows → publish → deduplicate consumer effect
A poison event must not block every aggregate. Preserve its error and sequence position, then decide whether that aggregate pauses or uses an explicitly compatible skip policy. Monitor oldest unpublished age as well as row count; a small stuck backlog can be more serious than a large recent burst.
3. Calculate the example
If 100 transactions commit and the relay publishes 97 before a crash, three remain pending. If one of the 97 acknowledgments was lost, recovery may publish four messages: three new and one duplicate. Consumer deduplication makes the duplicate harmless within its retention contract.
4. Failure cases and trade-offs
Marking sent before publishing loses events; marking afterward permits duplicates. Relay leases do not make a remote publish atomic. Polling is simple but adds database load; log-based capture adds infrastructure and schema coupling. Bound backlog and retention independently of normal request latency.
5. Validation, follow-ups and self-review
Crash before commit, after publish and before acknowledgment. Follow-up: how long must consumers remember IDs? Self-review: identify the atomic boundary, duplicate path and per-aggregate ordering rule.
Sources and related practice
Technical reference: microservices.io — Atomic business/outbox writes and duplicate delivery boundaries.
Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.
Continue with Design a change-data-capture pipeline with snapshot recovery; Design a durable work queue.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.