Api Design hard
Your webhook system guarantees at-least-once delivery (retries). Customers complain about duplicate events causing double-processing. How do you help them achieve exactly-once?
- A Include a cryptographically signed event_id in every payload, and advise customers to implement an idempotent receiver pattern by persisting and checking for previously seen IDs.
- B Transition the entire webhook delivery infrastructure to a strictly synchronous HTTP protocol that requires an atomic acknowledgment from the receiver before the next event is sent.
- C Eliminate the retry mechanism entirely to ensure that if a transmission fails, the event is never repeated, thereby theoretically preventing any possibility of a duplicate execution.
- D Leverage an underlying UDP-based transmission protocol to ensure that packets are delivered as a single unit without the inherent retransmission logic found in TCP-based systems.
Answer: A. Include a cryptographically signed event_id in every payload, and advise customers to implement an idempotent receiver pattern by persisting and checking for previously seen IDs.
Achieving exactly-once delivery in distributed systems is theoretically impossible without coordination. The standard solution is **At-Least-Once Delivery** combined with **Idempotent Receivers**. The sender retries on failure (ensuring delivery), and the receiver tracks processed `event_id`s to ignore duplicates (ensuring exactly-once processing).
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- You're designing a REST API for a blog. Which endpoint best represents 'get all comments for post 123'?
- A client wants to update only the 'status' field of an order, leaving other fields unchanged. Which HTTP method is most appropriate?
- A client calls POST /users with valid data, and the user is created. What status code should the server return?
- A client retries a failed 'POST /payments' request due to network timeout. The server receives the request twice. Without idempotency handling, what can happen?
- An API returns 10,000 products. Returning all in one response is impractical. Which pagination approach is simple and stateless?
- Your API serves both mobile apps and third-party integrations. Which authentication method is most appropriate?