Handling 429s in Delivery Error Alerts
In this article
Yes, marketplace delivery error alerts can handle 429 (Too Many Requests) responses without hiding failures, provided the alerting system is designed to distinguish between a temporary rate-limit and a genuine delivery failure. The key is to treat 429s as a distinct state—retryable and time-shifted—rather than collapsing them into a binary success/failure model.
What a 429 Actually Means
A 429 status code is defined by RFC 6585 as "Too Many Requests." It means the client has sent more requests in a given time window than the server allows. Unlike a 5xx server error or a 4xx client error like 404, a 429 is not a statement about the request's content—it's a statement about the request's rate. The server is telling you: "I understood your request, but I need you to slow down."
For marketplace delivery systems, 429s typically arise from webhook deliveries, API polling, or batch status updates. A delivery service might send a callback to your server for each package update; if your endpoint responds slowly or your infrastructure makes parallel calls, the provider's rate limiter kicks in. The response usually includes a Retry-After header specifying seconds to wait, or a RateLimit-Reset header with a Unix timestamp.
The Failure-Hiding Trap
Many alerting systems are built with a simple rule: if a delivery attempt returns a non-2xx status, log it as a failure and alert. That approach hides 429s in one of two ways:
- Silently swallowing: The code catches the 429, retries immediately (which fails again), and eventually gives up without ever creating an alert. The delivery is lost, but no one is paged.
- Flooding as failures: The system treats every 429 as a permanent failure, generating a page for each retry. This creates alert fatigue, and real failures get buried under noise.
Both are forms of hiding failures—one hides the event entirely, the other hides the signal under spam. The correct design is to model 429s as a separate, observable state.
How to Model Retryable States
The robust pattern is a three-state state machine for each delivery attempt: pending, delivered, or failed. A 429 should not move the attempt to failed; it should keep it in pending but record the retry count and the next allowed time.
- On receiving a 429, parse the
Retry-Afterheader (or compute fromRateLimit-Reset). - Store the attempt with a status of
rate_limitedand a scheduled retry timestamp. - Use a background job or scheduler to retry only after that timestamp, with exponential backoff (e.g., 1s, 2s, 4s, 8s) as a fallback if the header is missing.
- After a maximum retry count (commonly 5–10), transition to
failedand trigger an alert. - Per-delivery failure alert: Fires only when a delivery exhausts its retries and becomes permanently failed. This is the "your webhook is broken" alert.
- Rate-limit health alert: Fires when the volume of 429s exceeds a threshold (e.g., more than 10% of deliveries in a 5-minute window). This indicates your integration is misconfigured—maybe you removed a delay, or the provider changed their limits.
- Idempotency keys: Always include a unique delivery ID in the request headers so retries don't create duplicate records on the provider's side.
- Clock skew: If using
RateLimit-Reset, compare it to your server's UTC time, not local time. A misconfigured server clock can cause premature retries. - Queue depth: If you're storing retries in a database, ensure the retry timestamp is indexed. A query for "due now" on an unindexed column will become the bottleneck during a rate-limit storm.
- Logging: Log the 429 response body—it often contains the limit and window size, which helps diagnose whether you need to reduce batch sizes.
- Fail fast: Treat 429 as a failure immediately. This is simple but generates false alerts and may cause you to lose deliveries that would have succeeded on retry.
- Retry forever: Keep retrying with backoff indefinitely. This hides failures because the delivery never surfaces as failed—it just sits in limbo.
- Retry with a cap and visibility: The recommended approach above. It bounds the retry, surfaces the rate-limit state, and escalates to failure after N attempts.
This way, a 429 is neither hidden nor treated as a final failure. It's a visible intermediate state that operators can query: "How many deliveries are currently rate-limited?"
Alerting on Rate Limits vs. Failures
You should have two separate alerting thresholds:
This separation prevents hiding: a single 429 is normal and expected; a flood of 429s is a problem worth investigating. The per-delivery alert still fires if the retry loop fails, so no genuine failure is lost.
Practical Implementation Details
When building this, pay attention to a few specifics:
Common Misconception: 429 Is Always a Client Bug
A frequent assumption is that 429s are always your fault—you made too many requests. While true in most cases, there are legitimate server-side triggers: a provider may rate-limit a specific endpoint during peak hours, or a shared API key may be throttled by another tenant. Also, some providers return 429 instead of 503 when their own upstream is degraded. This means you should not blindly increase retry speed; instead, check the provider's status page and your request volume history.
Another misconception: "If I just wait 60 seconds, the limit resets." Rate limits are often sliding windows, not fixed resets. The Retry-After header is authoritative; if absent, exponential backoff is safer than a fixed delay.
Comparing Approaches: Swallowing vs. Retrying vs. Failing Fast
Three common strategies exist in the wild:
The third option is the only one that fully answers the question: it handles 429s without hiding failures.
Frequently Asked Questions
Should I alert on every 429?
No. A single 429 is a normal control signal. Alert only when the rate-limit rate crosses a threshold (e.g., >5% of deliveries) or when a specific delivery exhausts retries and becomes permanently failed.
What if the provider doesn't send a Retry-After header?
Use exponential backoff starting at 1 second, doubling each attempt (1s, 2s, 4s, 8s) up to your max retry count. This is a safe default that respects most rate limiters.
How many retries should I allow before alerting?
A common range is 5–10 attempts. Fewer than 5 may fail on transient spikes; more than 10 delays the alert unnecessarily. Choose based on your delivery SLA—if a delivery must be within 5 minutes, cap retries at a duration that respects that.
Can a 429 hide a permanent failure?
Yes, if your retry logic doesn't distinguish between a 429 and a 4xx like 403 or 404. A 403 means "you're not authorized" and retrying will never succeed. Always check the status code before retrying: retry only on 429 and 5xx, not on other 4xx codes.
Should I use a queue or a database for retries?
Either works. A queue with delayed messages (e.g., RabbitMQ TTL or SQS delay) is simpler for time-based retries. A database with a scheduled job gives you easier visibility and querying. Choose based on your existing infrastructure.
How do I test my 429 handling?
Simulate a 429 response in your integration tests by mocking the provider endpoint. Verify that the delivery stays in a pending state, retries after the specified delay, and eventually either succeeds or triggers a failure alert. Also test that the rate-limit health alert fires when you simulate a high volume of 429s.