~/VibeHandbook
$39

Cloudflare

developers.cloudflare.com

Queues

What it is

Cloudflare Queues is a managed message queue for Workers. One Worker pushes messages onto a queue (the producer); another Worker is invoked with batches of those messages to process them (the consumer). This lets you decouple 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 for failures.
  • 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 idempotent (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, 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 agent 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