Scaling
Scaling webhook processing
Webhook processing should be fast at the edge and reliable in the background.
RelayKit accepts the request quickly, stores a delivery record, and dispatches the handler to a queue.
Use a dedicated queue
'queue' => 'webhooks',
Run a dedicated worker:
php artisan queue:work --queue=webhooks
Keep handlers idempotent
Providers may send the same event more than once. Handlers should be safe to run multiple times.
if ($order->webhooks()->where('event_id', $event->id())->exists()) {
return;
}
Avoid long running work
A webhook handler should update local state and dispatch separate jobs for slow work.
SyncCustomerBilling::dispatch($customerId);
Monitor dead deliveries
Dead deliveries usually point to missing data, invalid assumptions, or provider changes. Review them regularly.