Queues
What it is
Think of a coffee shop: you place your order at the counter and walk away, and a barista works through the order tickets one by one. A is that line of tickets. Cloudflare Queues is a managed message queue for Workers built on this idea. One Worker drops messages onto the queue (the producer, like the cashier taking orders); another Worker is handed batches of those messages to work through (the consumer, like the barista). This lets you separate slow or unreliable work from the request that triggered it — accept the request fast, do the work in the background.
Strengths
- Decouples producers from consumers, smoothing traffic spikes.
- Automatic batching, retries, and a dead-letter queue (a holding area for messages that keep failing) so nothing is silently lost.
- Pure Workers integration — producer and consumer are both Workers with bindings.
- No infrastructure to run; scales with your traffic.
- Guarantees at-least-once delivery so messages aren't silently lost.
Trade-offs
- At-least-once delivery means consumers should be — that is, safe to run twice on the same message without doing harm (handle duplicates).
- Not for instant, synchronous responses — work happens asynchronously.
- Ordering is best-effort, not a strict global order.
- Throughput and message size have limits to design around.
When to use it
Use Queues for background jobs: sending emails, processing uploads, calling slow third-party APIs (Application Programming Interfaces — the endpoints used to talk to other services), fanning out webhooks, or buffering writes — anything you'd rather not make the user wait for.
Vibe coding fit
Queues are a clean way for an to add background processing without standing up a broker. Ask it to make the consumer idempotent (use a message key) and to set a dead-letter queue so failures are visible. The config wires one Worker as both producer and consumer of a queue.
# wrangler.toml
[[queues.producers]]
queue = "jobs"
binding = "JOBS"
[[queues.consumers]]
queue = "jobs"
max_batch_size = 10
dead_letter_queue = "jobs-dlq"
npx wrangler queues create jobs
npx wrangler deploy