Engineering Resilient Webhook Systems: Retries, Backoff, and Queue Mechanics
Webhook delivery sits at the boundary between decoupled distributed systems. Basic queue-and-retry tutorials cover exponential backoff and dead-letter queues. Production webhook infrastructure fails at the edges: system clocks that disagree across containerized workers, batched payloads that fail partially, and retry schedules that outlive the business windows they exist to serve. Provider…
Webhook delivery connects decoupled distributed systems but can fail at the edges due to system clock disagreements, partially failed batched payloads, and overly long retry schedules. Different providers have varying practices; GitHub requires manual redelivery or scripts, Stripe retries live-mode events with exponential backoff for up to three days, and Svix publishes a fixed schedule spanning roughly 27.5 hours.
When building a sender, one must choose where on this spectrum to sit, with consequences beyond the backoff formula. Clock skew and drift in delayed webhook schedulers rely on time-ordered data structures like Redis sorted sets or relational scheduled_at indexes. However, mixing timestamps produced by different machines assumes machines agree on time, leading to premature retries, stalled retries, and lease expiry issues in homegrown lease queues.
To mitigate these issues, it's crucial to stop using uncoordinated node wall clocks as the source of truth for retry scheduling. Instead, use scheduling primitives that are resilient to clock skew. For Redis-backed schedulers, compute the score inside a Lua script from Redis's own clock, TIME, and then write it to the sorted set. This ensures that the retry scheduling is not affected by clock discrepancies across nodes.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to