Scrivio Interview library
DesignAdvanced7 min read · updated 13 November 2026

A SaaS company wants to let customers register webhook URLs for 40 event types. Expected volume is 50 million events a day, customers want to replay missed events, and the security team worries about customer-supplied URLs.

Design the webhook platform, including how events flow from services to endpoints, replay, and protection against abuse of the URLs.

Services publish domain events to a log such as Kafka; a dispatcher matches each event to subscriptions by tenant and event type and creates delivery tasks in per-endpoint queues with retries and exponential backoff over hours to days. Every event and attempt is stored for a retention period, with an API and UI to inspect attempts and replay by time range or id. URLs are protected against SSRF by blocking private, loopback, link-local and metadata addresses at resolution and at connect time, disallowing redirects and sending through a dedicated egress proxy with fixed IPs; every delivery is signed with rotatable secrets over HTTPS to verified endpoints, and events carry stable ids and schema versions under a documented at-least-once, unordered contract.

Background to this question

A webhook platform is a small product of its own. It has to fan out 50 million events a day reliably to thousands of endpoints we do not control, let customers see and replay what happened, and do all of this while making outbound HTTP requests to URLs that customers type in, a classic way for attackers to reach internal systems. In this answer, we will size the system, walk through the event flow from services to endpoints, design storage and replay, deal with SSRF in depth, add signing and endpoint verification, and finish with the delivery contract.

1Requirements and Rough Numbers

50 million events a day is about 580 per second on average; with a peak factor of 5, we should plan for about 3,000 per second. Each event may match several subscriptions, so deliveries might be 1.5 times that, around 4,500 per second at peak. With a median endpoint latency of 300 milliseconds, Little's law gives about 1,350 deliveries in flight at peak, so a worker fleet with a few thousand concurrent HTTP connections, using non-blocking clients or virtual threads, is enough.

Storage: if an event averages 2 KB, a day is about 100 GB of event payloads, and attempts add small records. With 30 days of retention for replay, that is roughly 3 TB of events, which suits a partitioned database or an object store with an index, not a single hot table.

2How Events Flow From Services to Endpoints

Producing services publish domain events, such as invoice.paid, to Kafka, using an outbox so publishing is atomic with their own transactions. Each event has a stable event id, a type, a tenant id, a schema version and a payload.

A dispatcher consumes the topic, looks up the tenant's subscriptions for that event type, and writes the event to the event store and one delivery task per matching endpoint into per-endpoint queues. Separate queues per endpoint, with a concurrency cap per endpoint, mean a slow or failing customer only delays its own deliveries. Delivery workers take tasks fairly across endpoints, sign and send the request through the egress proxy with a short timeout, and record each attempt. Failures are retried with exponential backoff and jitter over hours to days, for example after 5 seconds, 1 minute, 10 minutes, 1 hour and then every few hours for up to 3 days, after which the task is marked failed and the customer is notified. A per-endpoint circuit breaker pauses endpoints that keep failing.

Step throughWebhook platform
  1. Domain servicespublish events via outbox, with id, type, tenant, schema version
  2. Kafkadurable event log, partitioned by tenant
  3. Dispatchermatch subscriptions, store event, create delivery tasks
  4. Per-endpoint queuesbackoff schedule, concurrency cap, circuit breaker
  5. Delivery workerssign, send with short timeout, record attempt
  6. Egress proxyfixed IPs, SSRF checks at connect time, no redirects
  7. Customer endpointsHTTPS only, verified ownership

7 layers, from the top down. Step through them one at a time.

Each delivery channel is a stage; storage of events and attempts sits beside the dispatcher and workers.

3Storing Events and Attempts, and Replay

Every event and every delivery attempt is stored: for attempts, the endpoint, time, status code, latency, a truncated response body and the error, if any. Events are kept for the replay window, for example 30 days, in daily partitions or in object storage with an index by tenant, type and time, so expiry is a cheap drop of old partitions.

Customers get an API and a UI to see this. They can list recent deliveries for an endpoint, see why one failed, and replay: a single event by id, or all events of chosen types in a time range, to one endpoint. A replay creates new delivery tasks with the same event ids, so receivers that deduplicate by id can safely accept replays of events they already processed. Replays go through the same per-endpoint queues and caps, so a customer replaying a week of events cannot flood their own server or our workers.

4Protecting Against SSRF

SSRF, server-side request forgery, is the main risk of customer-supplied URLs. An attacker registers http://169.254.169.254/latest/meta-data/ (a cloud metadata service) or http://10.0.3.7:8080/admin and lets our delivery workers, which run inside our network, send requests there. Responses or errors shown in the delivery log could then leak internal data or credentials.

Defence needs several layers. At registration and before each delivery, we resolve the hostname and reject addresses in private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), loopback (127.0.0.0/8, ::1), link-local (169.254.0.0/16, fe80::/10, which includes the metadata service), unique local IPv6 (fc00::/7) and other special ranges. Checking only at registration is not enough because of DNS rebinding: an attacker's domain can resolve to a public IP when we check and to 10.0.3.7 a minute later. So the check is repeated at connect time, on the IP we actually connect to, ideally by pinning the resolved IP for the connection. We disallow redirects, since a redirect can point inside. We restrict ports to 443 (and perhaps a short allow-list).

The strongest layer is network placement: all deliveries go through a dedicated egress proxy in an isolated network segment that has no route to internal systems at all, and that sends from a small set of fixed public IPs. Customers can then allow-list those IPs in their firewalls, which also answers a common customer request.

Step throughChecks before each delivery
  1. Scheme is https and port allowed?
    YesContinueNoReject delivery
  2. Resolve host: any private, loopback, link-local or metadata IP?
    YesReject and flag endpointNoPin resolved IP
  3. Connect via egress proxy to the pinned IPproxy repeats the IP check
  4. Response is a redirect?
    YesTreat as failure, do not followNoRecord status and latency

4 steps in order. Play them, or step through them one at a time.

5Signing, Secrets and Endpoint Verification

Every delivery is signed with an HMAC-SHA256 over the event id, timestamp and raw body using a per-endpoint secret, so receivers can verify the sender and reject replays. Secrets can be rotated with an overlap during which deliveries carry signatures from both the old and new secret. We require HTTPS so payloads are encrypted in transit.

When an endpoint is registered, we verify that the customer controls it, for example by sending a challenge request with a random token that the endpoint must echo back, before any real events are delivered. This stops anyone from using us to flood a third party's server.

6The Delivery Contract

Finally, we document honestly what the platform promises. Every event has a stable id and a schema version, so receivers can deduplicate and handle schema changes. Delivery is at least once: the same event may arrive more than once, especially after retries or replays. Delivery is unordered: events for the same object can arrive in any order, so receivers should use event timestamps or versions, or fetch the current state. Retries follow a published schedule for up to 3 days, and events stay available for replay for 30 days.

7Follow-up questions

How would you offer ordered delivery to the few customers who need it?

Ordered delivery means the platform sends events for a given key, for example per object or per endpoint, one at a time and waits for success before sending the next. That limits throughput to one in-flight delivery per key, and one failing event blocks everything behind it, so it should be an opt-in endpoint setting, scoped as narrowly as possible (per object id rather than per endpoint), with a clear warning about head-of-line blocking. Internally it maps to a queue per key with concurrency 1. Many customers who ask for ordering are better served by including a version or timestamp in each event, which lets them order events themselves without the throughput cost.

8Conclusion

In this answer, we sized a webhook platform for 50 million events a day, routed events from services through Kafka to a dispatcher that creates tasks in per-endpoint queues with exponential backoff, and stored events and attempts for inspection and replay. We defended against SSRF with IP range checks at registration and at connect time, pinned IPs, no redirects and an isolated egress proxy with fixed IPs, signed every delivery with rotatable secrets over HTTPS to verified endpoints, and documented an at-least-once, unordered contract with stable ids and schema versions.

What to say in the interviewAbout 90 seconds aloud

Open with

Fifty million events a day is about six hundred a second, maybe three thousand at peak, so the design is mostly about isolation, durability and safety rather than raw scale.

Then, if they want more

Services publish domain events to Kafka through an outbox, each with a stable id, type, tenant and schema version. A dispatcher consumes them, matches subscriptions by tenant and event type, stores the event, and creates a delivery task per endpoint in per-endpoint queues.

Workers send with a short timeout, a concurrency cap per endpoint, and retries with exponential backoff and jitter for up to about three days, with a circuit breaker for endpoints that keep failing.

We store every event and every attempt, status, latency, response code, for thirty days, and give customers an API and UI to inspect attempts and replay by id or time range through the same queues. Security is the hard part.

Customer URLs are an SSRF risk, so I resolve the hostname and block private, loopback, link-local and metadata ranges, check again at connect time on the pinned IP to stop DNS rebinding, refuse redirects, and send everything through an isolated egress proxy with fixed IPs that customers can allow-list.

Every delivery is signed with an HMAC, secrets rotate with overlap, HTTPS is required, and endpoints are verified with a challenge at registration. And I document at-least-once, unordered delivery.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design the webhook platform, including how events flow from services to endpoints...": https://scrivio-interview-library.netlify.app/architecture/api-design-at-scale/0f8ef58400/