Webhook Fanout Is a Scheduling Problem

- Name
- Abhi Vaidyanatha
Webhook fanout is delivering one event to every endpoint subscribed to it. You can get the loop that does this working pretty fast. The trouble starts later, when thousands of deliveries that fail and retry on their own share one pool of workers, and a single slow endpoint makes every other customer's webhooks late. That's a scheduling problem.
At Svix, sending webhooks for other companies is the product. They hand us an event and we get it to every endpoint that asked for it, so we've run into most of the ways fanout breaks.
When fanout goes wrong, the customer with the broken endpoint doesn't notice. The customer with a healthy endpoint gets their payment webhook late, and they're the one who files the ticket.
If you're after the definition or a build walkthrough, our resources page on webhook fan-out has both.
Do the multiplication first
A single payment might emit four events. Each one goes to every endpoint subscribed to it, and every failed delivery comes back as a retry.
We ran the numbers in The Product Manager's Guide to Sending Webhooks. 100 API requests per second at four events each is 400 webhooks per second before any retries, and a major customer going down can spike that to somewhere between 11,000 and 22,000 per second.
Your outbound traffic ends up bigger and spikier than your inbound traffic. It's also frustrating to plan for, because your customers' outages set the spikes and you find out when they happen.
Track each delivery separately
The v1 is a loop over endpoints with a status column on the event. That status stops meaning anything once one endpoint fails and two succeed, and retrying the event sends duplicates to the two that already got it.
So track the delivery: one event to one endpoint, with its own attempt count and next retry time. Fanning out is then a write. Persist the event, then enqueue one delivery per subscribed endpoint, in that order, so a crash partway through picks up where it stopped.
Stop slow endpoints from blocking
You've heard about noisy neighbors in every multi-tenancy talk, so I'll keep this short. Fanout has a nasty version of it, because the neighbor is a server you don't run.
Some customer endpoints answer in milliseconds and some hang until the timeout, which at Svix is 30 seconds. If deliveries come off one shared queue in order, a burst of events for a hanging endpoint can hold every worker for the full timeout. That's head-of-line blocking, and everything queued behind it is late.
The fix is to stop serving the queue first in, first out across endpoints. Cap how many deliveries one endpoint can have in flight, schedule so every endpoint gets a turn, and put a circuit breaker on the ones that keep failing. I think this is the most important part of the whole system, since it decides whether a healthy customer ever finds out about someone else's outage.
The tradeoff is ordering. Once deliveries retry independently, two events for the same object can arrive in either order. We've written about why you can't guarantee webhook ordering, and about the FIFO endpoints we built for customers who need it anyway.
Throttle the retries
When an endpoint recovers from an outage, its whole backlog comes due at the same moment as live traffic. Send all of it at full speed and you've pointed a thundering herd at a server that just came back up.
What matters is how much the endpoint can absorb, and your own sending capacity doesn't tell you that. At Svix you can set a throttling rate per endpoint. The retry schedule spreads eight attempts over a bit more than a day, and an endpoint gets disabled once every attempt to it has failed for five days.
Filter before fanning out
A delivery you skip costs nothing, so let each endpoint subscribe to the event types it handles. Channels narrow that further by who a message is for. Without filtering, customers receive everything and drop most of it, and you've still paid for each request, its retries, and its log entry.
Decide who runs it
Yes, this is the part where the webhooks company tells you to buy webhooks. It's the usual build vs. buy, and the argument is short.
You can get a fanout v1 out pretty fast. It's cheap to fan out to the 99% of endpoints that answer quickly, and nontrivial to stop the other 1% from deciding when everyone else's webhooks arrive.
If you build it, model deliveries per endpoint from day one. Switching from an event-level status later means migrating live data while webhooks are still going out. If you'd rather not run a scheduler, that's what Svix does. You make one API call per event, and the fanout, isolation, retries, and delivery logs are on us.
Ready to send webhooks?
Svix is the enterprise ready webhooks service. Build a secure, reliable, and scalable webhook platform in minutes.