Outbound webhook dispatchers sit at the boundary between your internal state machines and third-party endpoints you do not control. With internal microservices you set the network topology, retry budgets and load shedding. A webhook engine has to cope with consumer endpoints that hang, return intermittent 502 Bad Gateway responses, or reject valid signatures because of clock drift.

When a webhook pipeline has an incident, ordinary service metrics often mislead. Ingress APIs return healthy 200 OK rates and CPU looks fine, while customers report missing payment or state-change events. Diagnosing these silent failures means moving from service-level metrics to queue forensics, worker lease telemetry, and timestamp and signature auditing.

This guide covers three failure domains:

  1. Zombie worker leases and stalled heartbeats: telling a dead dispatcher from a long pause or a network partition without triggering duplicate deliveries.
  2. Predictive queue alerting: going beyond total queue length to slot saturation, lease duration, heartbeat lag and dead-letter queue (DLQ) growth velocity.
  3. Clock skew and timestamp drift: debugging signature-verification failures caused by replay-protection windows, using chrony telemetry and per-delivery offset logging.

1. Zombie Worker Leases and Stalled Heartbeats

To get at-least-once delivery without sending every event from several workers at once, dispatchers commonly use lease-based mutual exclusion. A worker that polls a broker or a transactional outbox table takes a time-bounded lease (a visibility timeout) on a batch of events. While it keeps renewing that lease with heartbeats, no other worker should claim those events.

Distributed systems rarely fail cleanly, though. Instead of crashing and closing its sockets, a dispatcher often ends up half-dead: the process is alive, but its heartbeat loop is stalled or cut off from the coordinator.

Anatomy of a half-dead dispatcher

Common triggers include:

  • Long pauses in managed runtimes. Pause behavior depends heavily on the runtime and collector. Modern concurrent collectors, including those in Go and recent JVMs, aim for very short pauses. Even so, heap pressure, swapping, a full collection or a badly sized heap can still stall a worker long enough to miss heartbeats, especially with large JSON payloads in memory.
  • CPU throttling. Under Linux CFS bandwidth control, which Kubernetes CPU limits use, a cgroup that spends its quota within a period is throttled until the next period begins. The default period is 100 ms, so a single throttle event is short. A worker that is repeatedly throttled during bursts can still see its heartbeat timer run late.
  • Asymmetric network partitions. The worker loses its path to the state store (PostgreSQL, Redis, etcd) but keeps outbound routing to customer endpoints.
  • Event-loop starvation. Synchronous signing or regex-heavy redaction blocks the main thread and keeps async heartbeat timers from firing.

The danger of naive lease stealing

Suppose Worker A leases event_9921 with a 30-second TTL and a 10-second heartbeat. It starts a TLS handshake to the customer endpoint at t = 5 s and then stalls (a long GC pause, swapping, or a frozen VM) until t = 31 s. The coordinator sees the lease expire at t = 30 s. If it lets Worker B steal the lease right away, two problems follow when Worker A wakes up:

  1. Duplicate delivery. Worker A finishes its HTTP POST and reports success, possibly overwriting Worker B’s state or delivering the same event twice.
  2. Load amplification. If the stall came from a struggling consumer or a shared database, aggressive stealing multiplies concurrent outbound traffic to an endpoint that is already in trouble.

Tuning lease TTLs and heartbeat intervals

Separate liveness detection from lease expiration, and measure time locally with monotonic clocks.

Use monotonic clocks for local lease tracking

A worker must not compute remaining lease time from wall-clock time. If NTP or an operator steps the clock backward, the worker will believe it holds a valid lease long after the coordinator has expired it. Measure elapsed time with a monotonic source such as CLOCK_MONOTONIC, time.Since() in Go (which uses the monotonic reading embedded in time.Now()), or System.nanoTime() in Java.

A common timing ratio: 1 : 2 : 4

A widely used rule of thumb, not a standard, relates the three timers like this:

  • Heartbeat interval (H): 5 s.
  • Suspect threshold: two missed heartbeats (2H = 10 s) before marking a worker SUSPECT.
  • Lease TTL (T): 4H (20 s) or more, and always longer than your outbound HTTP timeout plus network jitter.

Match the HTTP timeout to the TTL. The Standard Webhooks specification suggests request timeouts of 15–30 seconds, so a 20-second TTL is too tight for a 30-second timeout. Either raise the TTL or lower the timeout. A worker should also never start a request that cannot finish before its lease expires: with 8 seconds of lease left and a 15-second request timeout, it should renew the lease first or skip the request.

Safe lease stealing with fencing tokens

Timeouts alone cannot prove a partitioned worker is dead or just slow. Fencing tokens, described by Martin Kleppmann in his analysis of distributed locking, address this. Each time the coordinator grants or steals a lease, it increments a monotonically increasing fencing_token and stores it with the lease owner. Every later state change must present the token it was issued.

-- Atomic conditional lease steal in a PostgreSQL-backed outbox/queue UPDATE webhook_deliveries SET status = 'LEASED', worker_id = :new_worker_id, fencing_token = fencing_token + 1, lease_expires_at = NOW() + INTERVAL '30 seconds', last_heartbeat_at = NOW() WHERE delivery_id = :delivery_id AND ( status = 'PENDING' OR (status = 'LEASED' AND lease_expires_at < NOW()) ) RETURNING delivery_id, fencing_token, payload; 

When Worker A wakes up and tries to record an outcome, its update carries the token it was originally given:

-- Worker A's stale update affects zero rows once the token has been incremented UPDATE webhook_deliveries SET status = 'DELIVERED', delivered_at = NOW() WHERE delivery_id = :delivery_id AND worker_id = :worker_id AND fencing_token = :original_fencing_token; 

Fencing protects your own state store. It does not stop Worker A from sending the HTTP request it already had in flight, because the customer’s server knows nothing about your tokens. At-least-once delivery therefore still means receivers must be idempotent. The Standard Webhooks specification defines webhook-id as an identifier that stays the same across every retry of the same event, so receivers can use it as an idempotency key. Do not append an attempt number to webhook-id. That would defeat deduplication. If you want attempt-level forensics, log the fencing token and attempt number on your side, or send them in a separate custom header.

2. Pending vs. Leased vs. Dead-Lettered: Queue Depth Alerts That Predict Outages

The default queue alert is almost always total depth (for example, pending_messages > 10,000). In webhook systems, raw depth is a lagging and noisy signal. It can raise false alarms during legitimate bursts and miss real outages.

Why raw queue length misleads

Two illustrative scenarios:

  • Scenario A (false positive). A large customer runs a nightly import and enqueues 250,000 events in a minute. Your autoscaled fleet drains them at about 8,000 events per second and finishes in roughly half a minute with no SLO breach. A static pending > 50,000 alert pages someone for nothing.
  • Scenario B (silent outage). A downstream gateway browns out and connections hang for 29 seconds before timing out. Your 500 workers each lease one event and block on the socket. PENDING depth stays near zero, but throughput has fallen by more than 98% compared with a typical 150–400 ms request, and events are breaching latency targets.

To catch this, split queue state into Pending, Leased (in flight) and Dead-lettered, and alert on rates and ratios instead of static counts.

Three predictive signals

Signal Definition What it catches early Example alert threshold
Leased slot saturation Count(LEASED) ÷ max concurrent worker slots Endpoint latency spikes, thread starvation and pool exhaustion while PENDING still looks low Above 85% for more than 2 minutes, with falling ACK rate
Heartbeat lag (P99) NOW() − last_heartbeat_at across active leases GC thrashing, CPU throttling or database contention before leases expire Above 1.5× the heartbeat interval for 60 seconds (7.5 s at H = 5 s); page near the 2H suspect threshold
DLQ growth velocity Rate of DLQ insertions, split by failure class Schema changes, expired consumer TLS certificates, rotated secrets More than 5× the 15-minute baseline, or more than 1% of egress entering the DLQ

The thresholds above are starting points. Tune them against your own baselines.

1. Slot saturation and the lease duration ratio

A worker pool has a concurrency ceiling, Cmax = workers × max in-flight tasks per worker. Comparing the number of LEASED messages with Cmax gives you egress saturation.

The lease duration ratio is more sensitive. It compares the 95th-percentile time a message spends leased with the configured TTL:

Lease Duration Ratio=P95(Tleased)Tttl\text{Lease Duration Ratio} = \frac{P_{95}(T_{\text{leased}})}{T_{\text{ttl}}}Lease Duration Ratio=Tttl​P95​(Tleased​)​

If healthy requests take 150–400 ms and the TTL is 30 s, the ratio sits around 0.005–0.015. When an endpoint degrades and P95 climbs to 15–25 s, the ratio rises to roughly 0.5–0.8. Alerting on it can flag a downstream slowdown before the pool saturates and PENDING starts to grow.

2. Heartbeat lag

Do not wait for lease expirations (a spike in a lease_steal_total counter) to learn that workers are unhealthy. By then duplicate deliveries may already be happening.

Query the age of each active lease’s last heartbeat every 10 seconds or so. With a 5-second heartbeat, the age of a healthy lease cycles between 0 and about 5 seconds, so a healthy fleet’s P99 sits just above the interval. If P99 climbs to 8–9 s, workers are missing renewals because of throttling, GC pressure or database queueing. That gives you a warning window before the 10-second suspect threshold and the 20-second TTL.

3. DLQ growth velocity

Total DLQ size is a poor signal because historical failures accumulate for weeks. Alert instead on the derivative of DLQ insertions over a rolling window (for example, 5 minutes), split by failure class such as 4xx, 5xx, tls_handshake_failed and timeout. Pair it with queue age (the P99 age of PENDING messages):

  • High queue age and low DLQ velocity: the fleet is under-provisioned, or backoff and rate limits are holding events back.
  • Low queue age and high DLQ velocity: dispatchers are fast but deliveries are failing outright, for example because of expired certificates or rejected payloads.

3. Clock Skew and Timestamp Drift: Debugging Signature Failures

A customer reports that a fraction of your webhooks fail signature verification while the rest succeed, and the secret has not changed. Clock skew is a prime suspect, but it is not the only one. Check the other common causes first:

  • The receiver re-serializes parsed JSON before verifying. The Standard Webhooks specification calls this a very common failure, because the signed bytes must match the sent bytes exactly.
  • The secret was rotated on one side only.
  • The receiver is verifying against the wrong endpoint’s secret.

If the failures cluster on particular worker nodes or retries, look at timestamps.

How replay protection creates timestamp sensitivity

To stop an attacker from capturing a valid webhook and replaying it later, common schemes put a Unix timestamp inside the signed content:

  1. The sender generates a timestamp. Under Standard Webhooks this is the webhook-timestamp header, in seconds. Under Stripe it is the t= value in Stripe-Signature.
  2. The sender signs the timestamp together with the raw body. Standard Webhooks signs msg_id.timestamp.payload. Stripe signs timestamp.payload.
  3. The sender computes an HMAC-SHA256 with the shared secret and sends the signature and timestamp in headers.
  4. The receiver checks that the timestamp is within a tolerance window of its own clock, in the Standard Webhooks case in either direction, before verifying the signature:

∣Tverifier−Theader∣≤Δtolerance|T_{\text{verifier}} - T_{\text{header}}| \le \Delta_{\text{tolerance}}∣Tverifier​−Theader​∣≤Δtolerance​

Standard Webhooks defines the timestamp as the time of the attempt, and it updates on every retry. Stripe’s guidance likewise says to generate a fresh timestamp and signature for each retry.

Tolerance windows vary

  • Stripe: its libraries default to 5 minutes, and you can change it.
  • Slack: the documentation says to reject requests whose X-Slack-Request-Timestamp is more than five minutes from local time.
  • Standard Webhooks and Svix: the specification requires a tolerance but leaves the value to the implementation. Svix’s and Stripe’s libraries both ship with 5 minutes, and most providers fall between one and ten minutes.
  • Linear: it recommends, but does not enforce, a 60-second window. The webhookTimestamp field is in the JSON body, in milliseconds, not in a header.
  • Paddle: its SDKs default to a 5-second tolerance. The check is optional if you verify manually.

With a window as tight as Paddle’s SDK default, a sender whose clock is only a few seconds off can be rejected. For a receiver that checks in both directions, a sender running 6 seconds fast fails a 5-second window on every delivery from that node. Some SDKs check only age, and others check both directions, so skew in either direction can matter depending on the receiver’s library.

Practical causes of timestamp drift

  1. Suspend, resume and snapshot restore. A VM or microVM restored from a snapshot can come back with a stale guest clock until time synchronization corrects it. For Firecracker, restoring the clock is only partially handled, and guests are generally expected to run a time-sync client such as chrony or use the KVM PTP clock.
  2. Blocked NTP traffic. Strict egress rules on new nodes can block UDP port 123. With no synchronization, a clock drifts at the rate of its oscillator. A commonly cited range is tens of parts per million, which is on the order of a few seconds per day (10 ppm is about 0.9 s/day, and 50 ppm is about 4.3 s/day). chrony’s documentation uses 10 ppm as a typical figure for a low-quality clock.
  3. Slew versus step. By default, chronyd corrects offsets by slewing the clock instead of stepping it. On Linux its default maximum slew rate is 83,333 ppm (one twelfth), though chronyd normally corrects more gently than that. The time it takes depends on the correction time ratio, so a multi-second error can still persist for a while. Other daemons or configurations that slew at much lower rates, such as 500 ppm, would take over an hour to remove a 2-second error (2 s ÷ 500 ppm ≈ 66 minutes).
  4. Signing at enqueue time. If a producer signs the payload before putting it in a retry queue, the embedded timestamp is already old when a worker finally sends it. After a few minutes in a PENDING queue it can fall outside even a 5-minute window. Sign at the moment of dispatch, never at enqueue.

Auditing clock offset with chrony

On a Linux host running chronyd, check synchronization with:

chronyc tracking 

An illustrative healthy output on a cloud instance syncing to a nearby time source (the Amazon Time Sync address 169.254.169.123 is shown here as an example):

Reference ID : A9FEA97B (169.254.169.123) Stratum : 3 Ref time (UTC) : Sat Nov 28 02:45:12 2026 System time : 0.000142819 seconds fast of NTP time Last offset : +0.000031204 seconds RMS offset : 0.000210455 seconds Frequency : 14.210 ppm fast Residual freq : +0.002 ppm Skew : 0.045 ppm Root delay : 0.001120 seconds Root dispersion : 0.000480 seconds Update interval : 64.2 seconds Leap status : Normal 

Key fields:

  • System time: the remaining offset correction that chronyd has yet to apply. A large or persistent value, or Leap status : Not synchronised, means the clock is not tracking its source.
  • Root delay and Root dispersion: accumulated delay and dispersion back to the reference clock. chrony combines them as root distance = delay ÷ 2 + dispersion, which estimates the maximum error of the time source.
  • makestep: by default chronyd only slews. The makestep threshold limit directive makes it step the clock when the offset exceeds the threshold, but only during the first limit clock updates after chronyd starts. With makestep 1.0 3, a step is allowed only in the first three updates after start. That helps at boot but does not help after a VM resume hours later. A negative limit removes the cap, and chronyc makestep steps the clock on demand. chrony’s own documentation notes that on most systems it is preferable to step only at boot, because programs expect time to advance monotonically. Weigh that against your resume scenario, and prefer restarting chronyd or running chronyc makestep from a resume hook.

On Kubernetes fleets, the Prometheus node_exporter timex collector exposes node_timex_offset_seconds (offset between the local system clock and the reference clock) and node_timex_sync_status (whether the clock is synchronized). Alert when the sync status drops to 0 or when the absolute offset exceeds a threshold that makes sense against the tightest receiver window you must satisfy. A 5-second SDK default calls for a much tighter threshold, such as 0.25 s, than a 5-minute window does.

Logging clock offset in delivery timelines

When a customer disputes a signature failure, host graphs are not enough. You want per-delivery evidence in your own logs.

For each outbound POST, record your signing timestamp and the Date response header from the receiving side. The Date header is defined in RFC 9110, which supersedes RFC 7231, and it has one-second resolution. If you subtract half the round-trip time (RTT) from the response, you can estimate the offset for that attempt:

Observed Offset≈(Tsigned+RTT2)−Tresponse_date\text{Observed Offset} \approx \left(T_{\text{signed}} + \frac{\text{RTT}}{2}\right) - T_{\text{response\_date}}Observed Offset≈(Tsigned​+2RTT​)−Tresponse_date​

Treat the result as accurate to roughly a second. The Date header comes from whichever server generated the response, which may be an edge proxy and not the customer’s application, and its clock may differ from the application’s.

{ "event": "webhook_delivery_attempt", "delivery_id": "del_01JDR9X8M2K7V4N", "webhook_id": "msg_2KWPBgLlAfxdpx2AI54pPJ85f4W", "worker_node": "edge-worker-ap-south-1b-04", "fencing_token": 14, "attempt": 2, "http_status": 401, "timing": { "signed_at_unix": 1795834568, "receiver_date_header": "Sat, 28 Nov 2026 02:55:59 GMT", "receiver_date_unix": 1795834559, "rtt_ms": 42, "estimated_clock_offset_sec": 9.021, "local_ntp_sync_status": "synchronized" } } 

Here the estimated offset is about +9 seconds: the dispatcher’s clock appears 9 seconds ahead of the responding server’s Date header, which would put a timestamp 9 seconds in the future from that server’s point of view. The sign of the offset matters. A positive value means the sender looks ahead, which a receiver that rejects future timestamps would refuse.

Which side is wrong is not obvious from one log line. If your node reports healthy synchronization and the offset is stable across your whole fleet, that points toward the receiver or its edge. If the offset appears only for one worker node, that points toward the node, and automation can drain it from the dispatcher pool. In both cases a second source, such as node_timex_offset_seconds for the sender, helps settle it.

Summary Checklist for Webhook Reliability Engineering

  1. Protect leases with monotonic clocks and fencing tokens. Measure local lease time with monotonic clocks, keep outbound timeouts shorter than the remaining lease, require the fencing token on every state transition, and keep webhook-id stable across retries so receivers can deduplicate.
  2. Replace naive queue-depth alerts. Alert on leased slot saturation, the lease duration ratio, P99 heartbeat lag relative to the heartbeat interval, and DLQ growth velocity split by failure class.
  3. Sign at dispatch, not enqueue. Compute the HMAC and timestamp immediately before sending each attempt, as Standard Webhooks and Stripe both expect.
  4. Instrument clock forensics. Monitor node_timex_offset_seconds and node_timex_sync_status on every worker host, plan for clock correction after resume, and log an estimated offset from the response Date header on every attempt.

Originally published at https://instawebhook.com/blog/webhook-delivery-timelines-queue-forensics-and-worker-health-a-distributed-syste