Design a Webhook Delivery Platform
Practice designing a platform that takes events from internal services and delivers each one to a customer's HTTPS endpoint, retrying for up to 24 hours, without losing events or letting one down endpoint slow the rest.
Problem statement
Design a webhook delivery platform that stays reliable at very high volume.
For this exercise, assume internal product services hand the platform events, and it delivers each event to a customer's HTTPS endpoint as an HTTP POST, retrying until the endpoint accepts it. A producer service calls the platform with a target ID, its own event ID, an event type and a JSON payload of up to 256 KB.
The target ID names one customer endpoint. The endpoint's URL and signing secret live in an endpoint registry service that another team owns: your platform must look them up there, a customer can change the URL at any time, and the registry can be slow or briefly unavailable.
A delivery succeeds when the endpoint answers with a 2xx status within 10 seconds. Any other answer, a timeout or a connection error is a failed attempt, and the platform keeps retrying for up to 24 hours after the event was accepted.
After that the delivery is marked failed, and the producer can ask for it to be sent again, which starts a new 24-hour window. If the registry says the target has been deleted or disabled, the platform stops and marks the delivery canceled.
Also assume delivery is at least once: an endpoint may receive the same event more than once, and the platform promises no order between events.
Each request to an endpoint carries an ID that stays the same on every retry of that event, a timestamp and a signature, so the receiver can check that the request came from the platform and drop repeats. Producers can look up a delivery's state and attempt history for 30 days.
For this exercise, these are out of scope: the screens and APIs customers use to register endpoints (the registry owns them), sending one event to several endpoints, changing payloads on the way, and running in more than one region.
What to build
- A producer submits a target ID, event ID, event type and JSON payload and quickly gets either a durable acceptance with a delivery ID or a clear rejection; submitting the same event ID again returns the same delivery.
- The platform looks up the target's current URL and secret, sends a signed POST, and retries failed attempts for up to 24 hours before marking the delivery failed, or stops early and marks it canceled when the target is deleted or disabled.
- Every request to an endpoint uses one documented body and set of headers (a stable ID, event type, creation time, timestamp and signature) so receivers can verify it and drop repeats.
- A producer can read a delivery's state and attempt history for 30 days and can ask for a failed delivery to be sent again, which starts a new 24-hour window.
At scale
- For this exercise, assume about 2 billion accepted events a day (about 23,000 a second on average) with peaks of 100,000 a second; payloads average about 2 KB and are at most 256 KB.
- For this exercise, assume about 1 million endpoints. Most receive a few events an hour, the largest receive up to 5,000 a second, and any endpoint can be slow or down for hours.
- For this exercise, assume acceptance answers within 200 ms at the 99th percentile, and an event for a healthy endpoint gets its first attempt within 5 seconds at the 95th percentile.
- For this exercise, assume an accepted event must never be lost, including when one zone of the region fails, and accepting events must keep working while the registry or some endpoints are down.