Handling `429 Too Many Requests` and `Retry-After` Headers Without Starving Other Endpoints
Learn how outgoing and incoming webhook engines parse Retry-After delay-seconds and HTTP-date headers, isolate per-destination rate limits, and prevent noisy-neighbor worker pool starvation.

Handling 429 Too Many Requests and Retry-After Headers Without Starving Other Endpoints
Webhook systems sit between bursty event producers and unpredictable HTTP consumers. Whether your platform sends millions of webhook deliveries to customer endpoints or ingests high-volume webhooks from third-party providers, HTTP 429 Too Many Requests and the Retry-After header are part of normal operation.
A naive retry loop is a problem. So is a shared worker queue where one throttled endpoint blocks everyone else. Either can turn a local rate limit into a platform-wide delivery backlog. On the receiving side, blunt global rate limits, or a cache that stores 429 responses, can reject valid events or trigger retry storms across unrelated senders.
This article covers what the standards say, how to parse Retry-After defensively, how to isolate rate-limit state per destination, and how popular providers behave when your endpoint is the one that fails.
What the Standards Say About 429 and Retry-After
RFC 6585 defines status code 429 to indicate that the user has sent too many requests in a given amount of time (“rate limiting”). RFC 9110 (HTTP Semantics), Section 10.2.3 defines the Retry-After response header. It tells the client how long to wait before making a follow-up request. RFC 9110 describes its use with 503 Service Unavailable and with 3xx redirects. In the redirect case it indicates the minimum time the client is asked to wait. The pairing with 429 comes from RFC 6585.
Several rules from the specifications shape how senders and receivers should behave:
Retry-Afteris optional on429. RFC 6585 says the response may include it. Many APIs omit it, use vendor-specific quota headers instead, or return429for quota exhaustion that waiting won’t fix.429responses must not be cached. RFC 6585 states that responses with status429must not be stored by a cache. If a CDN or reverse proxy stores one anyway, unrelated clients or routes can receive false rate-limit errors.429is not mandatory for servers. RFC 6585’s security considerations note that answering every request from an abusive client with a429still consumes resources. Under heavy load, dropping connections may be more appropriate than responding.Retry-Afteris a floor, not a schedule. RFC 9110 says the client ought to wait at least that long. If a client has its own reason to wait longer, such as its backoff policy or a circuit breaker,Retry-Afterdoesn’t override it.
A Note on Emerging RateLimit Headers
Many APIs also expose quota state through headers such as X-RateLimit-Remaining and X-RateLimit-Reset. These are vendor conventions, and their semantics vary between providers. The IETF HTTPAPI working group is standardizing RateLimit and RateLimit-Policy header fields so servers can advertise quotas and clients can avoid being throttled. As of the May 2026 revision (draft-ietf-httpapi-ratelimit-headers-11), it is still an Internet-Draft, not a published RFC. Treat these headers as hints and never as a replacement for honoring Retry-After.
Parsing Retry-After: delay-seconds vs. HTTP-date
A valid Retry-After value takes one of two forms:
delay-seconds: a non-negative decimal integer, such asRetry-After: 120orRetry-After: 0. It is the number of seconds to wait after the response is received.HTTP-date: an absolute timestamp, such asRetry-After: Wed, 21 Oct 2015 07:28:00 GMT. Servers are expected to generate the IMF-fixdate format, but RFC 9110 requires recipients parsing HTTP dates to also accept the obsolete RFC 850 andasctimeformats.
Edge Cases and Defensive Parsing Rules
Production webhook engines should never assume that Retry-After is well formed or that clocks agree:
- Validate integer values strictly. Trim whitespace and accept only digit strings. Negative numbers, floats, and
NaNshould count as unparseable, so the header is ignored rather than causing a timer error. - Handle past dates and clock skew. For an
HTTP-date, computetargetEpochMs - nowMs. If the result is zero or negative, clamp the wait to0plus a small jittered floor, so jobs never sleep for a negative duration. Keep your own fleet’s clocks synchronized (for example with NTP), because the delta depends on your clock matching the server’s. - Don’t retry before the requested time. Retrying early usually earns another
429and can count against your own retry budget. Add a small positive jitter on top of theRetry-Afterfloor so many deliveries to one destination don’t wake simultaneously. - Decide what to do with absurdly long delays. Clamping a one-day
Retry-Afterdown to your five-minute maximum means retrying early on purpose. If the requested delay exceeds your ceiling, either schedule the retry at the requested time or pause the endpoint and alert the owner. Don’t silently retry sooner. - Distinguish rate limits from hard quota exhaustion. If the destination documents separate error codes for throttling versus an exhausted quota or suspended billing, inspect the body or error code before scheduling a retry. Retrying a hard limit wastes capacity and delays the alert the customer needs.
- Fall back to exponential backoff with jitter when
Retry-Afteris missing or unparseable, bounded by a maximum delay and a maximum number of attempts.
export interface RetryDecision {
shouldRetry: boolean;
delayMs: number;
source:
| "retry-after-seconds"
| "retry-after-date"
| "backoff-fallback"
| "exceeds-max-delay"
| "none";
}
export function computeRetryDelay(options: {
retryAfterHeader?: string | null;
attempt: number; // 0-indexed retry attempt
maxAttempts?: number;
baseDelayMs?: number;
maxDelayMs?: number;
jitterRatio?: number; // extra delay added on top of Retry-After
nowMs?: number;
}): RetryDecision {
const maxAttempts = options.maxAttempts ?? 8;
const baseDelayMs = options.baseDelayMs ?? 1000;
const maxDelayMs = options.maxDelayMs ?? 300_000;
const jitterRatio = options.jitterRatio ?? 0.1;
const nowMs = options.nowMs ?? Date.now();
if (options.attempt >= maxAttempts) {
return { shouldRetry: false, delayMs: 0, source: "none" };
}
// Jitter is only ever added, so we never retry earlier than requested.
const withJitter = (ms: number) =>
ms + Math.floor(Math.random() * Math.max(1, ms * jitterRatio));
const raw = options.retryAfterHeader?.trim();
if (raw) {
let requestedMs: number | null = null;
let source: RetryDecision["source"] = "retry-after-seconds";
if (/^\d+$/.test(raw)) {
// 1. delay-seconds: non-negative integer
const seconds = Number.parseInt(raw, 10);
if (Number.isSafeInteger(seconds)) {
requestedMs = seconds * 1000;
}
} else if (/[A-Za-z]{3}/.test(raw)) {
// 2. HTTP-date (the letter check keeps Date.parse from
// interpreting stray numeric strings as dates)
const parsedMs = Date.parse(raw);
if (!Number.isNaN(parsedMs)) {
requestedMs = Math.max(0, parsedMs - nowMs);
source = "retry-after-date";
}
}
if (requestedMs !== null) {
if (requestedMs > maxDelayMs) {
// Don't retry early: let the caller pause the endpoint or
// reschedule at the requested time.
return { shouldRetry: false, delayMs: requestedMs, source: "exceeds-max-delay" };
}
return { shouldRetry: true, delayMs: withJitter(requestedMs), source };
}
}
// 3. Fallback: exponential backoff with full jitter
const cap = Math.min(maxDelayMs, baseDelayMs * 2 ** options.attempt);
return {
shouldRetry: true,
delayMs: Math.floor(Math.random() * cap),
source: "backoff-fallback",
};
}
How Real Providers Handle Your Failures
If you receive webhooks, the sender’s retry policy determines how long your handler has to recover. If you send them, these policies are a useful reference for your own design. The details below come from provider documentation, and they change, so confirm them before depending on them.
- Svix retries on a schedule with exponential backoff: immediately, then after 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, and 10 hours, with a final 10-hour wait. It treats a delivery as failed if there is no
2xxresponse within 15 seconds. If every attempt to an endpoint fails for five days, the endpoint is disabled by default. Svix’s retry documentation describes this. - Stripe retries live-mode events with exponential backoff for up to three days. In test mode it makes three attempts over a few hours. After three days of continuous failures in live mode, it disables the endpoint. Stripe does not guarantee that events arrive in the order they were generated, and the same event can be delivered more than once. Third-party write-ups list exact retry intervals, but Stripe’s own documentation describes only the three-day exponential-backoff window.
- GitHub expects a
2xxresponse within 10 seconds on github.com. It does not automatically redeliver failed deliveries. You redeliver them manually or through the REST API, and a redelivery keeps the sameX-GitHub-Deliveryheader as the original.
The lesson is that retry behavior varies widely. Some senders retry for days, and others leave recovery to you. Neither case lets you assume a 429 from your receiver will be retried the way you’d like.
Outgoing Webhook Engines: Preventing Worker Pool Starvation
Consider an outgoing webhook engine where Customer A’s endpoint starts returning 429 with Retry-After: 60. The same problem is worse when the 429 has no Retry-After, because workers then have nothing to schedule against.
Why Shared Queues and Naive Workers Fail
- Head-of-line blocking: If one FIFO queue feeds a fixed worker pool and workers sleep inline while waiting out a delay, slots sit idle or get consumed by repeated retries to the same throttled endpoint.
- Noisy-neighbor starvation: If one tenant or destination generates thousands of events and gets throttled, aggressive retries in a shared queue can crowd out deliveries to healthy endpoints.
- Thundering herds on expiry: If 500 deliveries for one endpoint are all scheduled for the same
Retry-Aftertimestamp, they wake simultaneously and likely trigger another429.
Architectural Patterns for Per-Destination Isolation
To keep one throttled endpoint from starving the rest of the fleet, separate scheduling and rate state from worker execution:
- Key rate state by destination. Use a key such as
(tenant_id, endpoint_url)so cooldowns apply only to that target. Even if two customers point at the same third-party host, per-endpoint or per-credential state keeps one misconfigured customer from penalizing another. - Use delayed queues instead of sleeping workers. When a delivery gets a
429, computenext_attempt_at = now + retry_after_delayplus jitter, and persist the updated attempt metadata. Then put the job in a delayed set, such as a Redis sorted set scored by timestamp, a database table indexed onnext_run_at, or a queue with native delay support. Workers pull only jobs that are due and never hold a throttled job while sleeping. - Keep a per-destination cooldown. Store a
rate_limited_untiltimestamp, or token-bucket state, per destination in a fast shared store such as Redis. If a worker pops a job for a destination still in its cooldown window, it reschedules the job without making an outbound request that is certain to fail. - Schedule fairly across destinations. Instead of draining all ready jobs for one hot endpoint first, use round-robin or weighted fair queuing. Also consider per-destination concurrency caps, such as at most
Nin-flight deliveries to one URL. Healthy endpoints keep receiving timely deliveries while a throttled one backs off. - Cap retries and surface failures. Limit the total number of attempts or the total retry window. Endpoints that keep failing or throttling should move to a dead-letter queue or a paused state, with clear metrics and alerts for your operations team and for the customer. Svix’s five-day auto-disable and Stripe’s three-day disable are examples of this pattern.
| Failure mode in outgoing webhooks | Root cause | Isolation and mitigation |
|---|---|---|
| Worker pool exhaustion | Workers block or sleep on 429, or retry in tight loops | Move delayed retries to a timestamped schedule; never sleep workers inline |
| Noisy-neighbor starvation | One high-volume or throttled endpoint fills shared retry capacity | Scope rate state and concurrency limits per destination; schedule fairly across endpoints |
Repeat 429 storm on wake-up | All delayed jobs share the same wake timestamp | Add bounded jitter on top of Retry-After; enforce per-endpoint max concurrency |
| Infinite retry drag | No cap on retry count or total retry age | Enforce a max attempts or window, route exhausted jobs to a dead-letter queue, and notify or pause if the failure persists |
Incoming Webhook Engines: Protecting Ingestion and Isolating Senders
Rate limiting matters on the receiving side too. If you ingest events from payment gateways, CI/CD systems, or customer integrations, sudden spikes can overwhelm your ingestion servers, database, or downstream event bus.
Decouple Ingestion from Heavy Processing
The most effective protection is a fast, lightweight HTTP handler:
- Verify the signature and basic schema, then enqueue the raw event durably with an idempotency or event ID. Return
202 Accepted, or200 OKif the provider expects it, before running slow business logic. Provider timeouts are short, such as GitHub’s 10 seconds and Svix’s 15, so slow handlers produce failures and retries on their own. - Isolate noisy senders. If you receive webhooks from multiple tenants, integrations, or event types, apply rate limits per sender or source. One bursty source then can’t exhaust the whole ingestion pool.
Returning 429 and Retry-After From a Receiver
When your receiver truly cannot accept more traffic, for example because queue depth is over a safe bound or one sender exceeded its allowance:
- Return
429with an accurateRetry-After, asdelay-seconds(such asRetry-After: 30) or anHTTP-datein GMT. - Keep
429responses out of caches. RFC 6585 already forbids caches from storing them. SendingCache-Control: no-storeas well protects against misconfigured intermediaries. - Know the sender’s retry behavior. As shown above, Svix and Stripe retry over hours or days, while GitHub leaves redelivery to you. Monitor
429rates per sender and tune limits to absorb normal bursts rather than throttle legitimate baseline traffic. - Make consumers idempotent. Retries, timeouts, and
429s produce duplicate deliveries. Stripe, for example, says the same event can arrive more than once. Deduplicate on a unique event or delivery ID, such as Stripe’sevent.id, Svix’ssvix-id, or GitHub’sX-GitHub-Delivery. - Don’t rely on ordering. Late retries can arrive after newer events. Stripe explicitly doesn’t guarantee delivery order, so handlers should tolerate out-of-order events.
- Plan for reconciliation. After an outage longer than a sender’s retry window, events may be lost or the endpoint may be disabled. Periodically reconcile against the provider’s events API or redeliver missed deliveries.
Operational Checklist for Production Webhook Engines
Before shipping changes to a dispatcher or receiver, verify these essentials:
- Parser tests for both
Retry-Afterformats. Cover0, small and large integers, values above your ceiling, valid dates in the future and past, obsolete date formats, missing headers, negative numbers, floats, and malformed strings. - Per-destination isolation. Confirm that throttling
https://customer-a.example.com/webhooksdoes not delay deliveries tohttps://customer-b.example.com/webhooks. - No worker blocking on backoff. Verify that delayed retries sit in a scheduled store and don’t hold worker threads or event-loop slots.
- Jitter that never undercuts
Retry-After. Test that jittered delays are always greater than or equal to the requested delay. - Observability and alerting. Track
429counts, parsedRetry-Afterdistributions, per-destination queue depths, the age of the oldest undelivered event, and dead-letter transitions.