Why does a Cloudflare Queues email consumer keep hitting provider 429s during a backlog even though it retries them with delaySeconds, and how do you cap it?
answer
- more invocations, not slower ones
- autoscaler reads backlog and failures
- retry() is not a failure
- max_concurrency caps the fleet
basics
~20 sQueues autoscales push consumers on backlog growth, and explicit retry() calls do not count as failed invocations, so concurrency keeps rising and more batches hit the provider at once. Set max_concurrency to what the provider can absorb.
solid answer
~40 sConsumer concurrency is on by default: after each batch Queues decides whether to run more concurrent invocations, based on the backlog and its growth, the ratio of failed invocations, and `max_concurrency`; as of 2026-10-10 the ceiling is 250. `msg.retry()` and `retryAll()` do not count as failures, so they never make it scale down. A growing backlog therefore adds invocations, each one sending another batch at the provider, which answers with more 429s. The fix is `max_concurrency` on the consumer (or `--max-concurrency`, or the dashboard's maximum consumer invocations), sized to the provider's rate, while keeping per-message delayed retries. The cost is a longer backlog, so check it drains well inside the message retention period.
code
json · 12 lines{
"queues": {
"consumers": [
{
"queue": "emails",
"max_concurrency": 4,
"retry_delay": 120,
"dead_letter_queue": "emails-dlq"
}
]
}
}go deeper
Know that a Queues consumer can run several invocations at once by default, and that max_concurrency limits how many.
Explain the autoscaler's inputs, backlog and growth, failed invocations and max_concurrency, and that it re-evaluates after each batch.
Diagnose why explicit retries keep the fleet growing against a rate-limited provider, size a max_concurrency cap from the provider's rate, and check the backlog drains inside retention.
Treat a concurrency cap as a per-downstream exception with an owner, not a blanket default, since a fixed number ignores the platform's rising maximum.
This is a production diagnosis. A **Cloudflare Queues** consumer Worker sends emails through a provider with a fixed rate limit. Under normal load it is fine. During a campaign the backlog grows, the provider starts answering **429 Too Many Requests**, the consumer correctly calls `msg.retry({ delaySeconds })` on each rate-limited message, and yet the 429s do not let up. The cause is **consumer concurrency**. ## Consumer concurrency is on by default A push-based consumer is not one Worker invocation at a time. Queues runs **several invocations of the consumer concurrently** to keep up with the backlog, and every queue has this enabled by default. As of 2026-10-10 the ceiling for a push-based consumer is **250 concurrent consumer invocations**, and Cloudflare says that maximum rises over time. After each batch, Queues decides whether to adjust the number of concurrent consumers. The documented inputs are: - the number of messages in the backlog and how fast it is growing; - the ratio of **failed** to successful invocations, where a failed invocation is one whose `queue()` handler throws instead of returning; - the `max_concurrency` value set for that consumer. ## Why explicit retries do not help The docs are explicit: retrying messages with `retry()` or `retryAll()` does **not** count as a failed invocation and will **not** cause the consumer to autoscale down. From the autoscaler's point of view, the email consumer is healthy: its invocations succeed, and the backlog is growing. So it adds invocations. Each new invocation sends another batch at the provider, which returns more 429s, which become more delayed retries, which feed the backlog. The per-message delay spaces out each message, but the number of senders hitting the provider at once keeps rising. | What the consumer does on a 429 | Effect on the batch | Effect on autoscaling | |---|---|---| | Throws | Whole batch retried, sent emails re-sent | Counts as a failed invocation | | `msg.retry({ delaySeconds })` | Only that message retried, later | Not a failure; scaling continues | | `msg.retry()` plus a `max_concurrency` cap | Only that message retried | Capped at the configured number | Throwing is not the answer: it re-runs the whole batch, re-sending emails already delivered, and leaving scaling to a failure signal is not a control you can set. ## The fix: cap concurrency for a rate-limited downstream Set `max_concurrency` on the consumer to a number the provider can absorb. A rough sizing: if the provider allows *R* sends per second and one invocation sends a batch of *B* emails in about *T* seconds, each invocation produces about *B / T* sends per second, so a cap near *R × T / B* keeps the fleet under the limit. Leave headroom, because retries come back on top of new messages. It can be set in three places: 1. `max_concurrency` in the consumer's entry under `queues.consumers` in the Wrangler file (see the code example), deployed with `wrangler deploy`. 2. `--max-concurrency` on `wrangler queues consumer add`. 3. The dashboard's **Maximum consumer invocations**, a value from 1 to 250, or **auto (recommended)** to remove the cap. Keep the per-message `retry({ delaySeconds })` with a backoff from `msg.attempts` for the 429s that still happen; the cap and the delay solve different halves of the problem. ## What the cap costs - **Latency and backlog.** With fewer senders, the backlog grows during peaks instead of being cleared quickly. That is the deliberate trade: the provider's limit, not Queues, sets the throughput. - **Retention.** A message that sits on the queue until its retention period ends is deleted. The default is four days; it can be raised to 14 days on paid plans and is capped at 24 hours on the Workers Free plan. Size the cap so a realistic peak drains well inside that window. - **A frozen ceiling.** Cloudflare recommends leaving `max_concurrency` unset otherwise, because a fixed number stays fixed even as the platform's supported maximum grows. Set it only where a downstream is genuinely limited, and remove the key and redeploy to return to automatic scaling. - **Cost is not the lever.** Billing follows the Workers usage model per invocation, so processing every message costs the same overall whether it happens concurrently or slowly; concurrency only brings the cost forward. ## Telling this apart from other "not scaling" stories The opposite complaint, a consumer that will not scale up, has its own documented causes: `max_concurrency` set to 1, a consumer that is throwing instead of processing, or long-running batches, since Queues only re-evaluates after a whole batch finishes. Reading which way the scaling went, and why, is most of the diagnosis.
- Why not just throw on a 429 so the autoscaler sees failures and backs off?A throw fails the whole batch, so every email already sent in it goes out again, and a failure ratio is not a number you control. A `max_concurrency` cap is explicit and leaves per-message `retry()` free to delay only the rate-limited messages.
- How do you return a capped Queues consumer to automatic scaling?Remove `max_concurrency` from the consumer's entry in the Wrangler file and run `wrangler deploy`, or select auto in the dashboard's maximum consumer invocations setting. Cloudflare recommends leaving it unset unless a downstream is limited, since a fixed value ignores later increases to the platform maximum.
- When does a Queues consumer fail to scale up at all?The documented causes are `max_concurrency` set to 1, a consumer that throws instead of processing messages, and long-running batches, because Queues only re-evaluates concurrency after a whole batch has been processed.
- A Queues consumer runs one invocation at a time by default.
- Calling msg.retry() tells the autoscaler to scale the consumer down.
- A longer delaySeconds alone keeps the provider under its rate limit.
- Running more concurrent consumers makes processing the backlog cost more overall.
- max_concurrency should be set on every consumer as a safety default.
As of 2026-10-10 push-based Queues consumers autoscale to at most 250 concurrent invocations; Cloudflare states the maximum rises over time, which is why a fixed max_concurrency is advised only for a limited downstream.