sellCompute
queue

Queues

One Worker drops messages into a queue and replies instantly; another Worker picks them up later, in batches, with automatic retries — no message gets lost.

5,000Messages / sec per queue
100Messages per batch
128 KBMax message size
$0Egress fees
lightbulb

What are Queues?

Cloudflare Queues is a message queue: a reliable waiting line where one Worker drops off messages and another Worker picks them up to process later. It guarantees delivery, so nothing is lost even if the receiver is busy or briefly fails.

A "message" is just a small chunk of data — for example "send a welcome email to user 123" or "resize this uploaded photo." Instead of doing that slow work while the user waits, you put a message in the queue and respond immediately. The work happens in the background.

local_post_office

Think of it like…

A queue is like a restaurant's order rail. The waiter (one Worker) clips order tickets on the rail and goes back to serving customers. The kitchen (another Worker) grabs tickets when ready and cooks them in batches. Nobody waits at the counter for their food to be made.

help

Why use it?

If your Worker tries to do everything during a single request, slow tasks make users wait and a single failure loses the work. A queue decouples "accepting the work" from "doing the work," making your app faster and far more reliable.

rocket_launch

Respond instantly

Acknowledge the request in milliseconds, then do the heavy lifting in the background.

verified

Guaranteed delivery

Messages are stored until successfully processed — they survive crashes and restarts.

replay

Automatic retries

If processing fails, the message is retried automatically. No custom retry code needed.

inventory

Batching

Process up to 100 messages at once for big efficiency gains on bulk work.

payments

No egress fees

You're never charged for bandwidth moving messages out of the queue.

trending_down

Smooths spikes

A sudden flood of work piles up safely in the queue instead of overwhelming your system.

target

When should you use it?

Use Queues whenever work can happen later instead of right now, or when one part of your system needs to hand a job to another safely.

mail

Sending emails

Queue a welcome or receipt email so the user's request returns instantly.

image

Media processing

Resize images or transcode video in the background after an upload.

webhook

Webhooks

Accept incoming webhooks fast, then process them reliably with retries.

swap_horiz

Worker-to-Worker

Pass jobs between Workers without them having to call each other directly.

analytics

Batch ingestion

Buffer events and write them to storage in efficient batches.

notifications

Notifications

Fan out push or in-app notifications without blocking the original request.

rocket_launch

How do you get started?

You create a queue with Wrangler, then wire one Worker as the producer (sends messages) and another handler as the consumer (processes them). A single Worker can be both.

  1. Create a queue

    Make a new queue by name. This is where messages will wait.

    bash
    npx wrangler queues create my-queue
  2. Add bindings in config

    In wrangler.jsonc, declare the queue as a producer (so the Worker can send to it) and as a consumer (so the Worker is invoked to process batches).

    jsonc
    {
      "queues": {
        "producers": [
          { "queue": "my-queue", "binding": "MY_QUEUE" }
        ],
        "consumers": [
          {
            "queue": "my-queue",
            "max_batch_size": 10,
            "max_batch_timeout": 5
          }
        ]
      }
    }
  3. Deploy

    Publish your Worker. Use wrangler tail to watch messages being consumed live.

    bash
    npx wrangler deploy
    npx wrangler tail
jssrc/index.js — producer + consumer in one Worker
export default {
  // PRODUCER: runs on each HTTP request and sends a message
  async fetch(request, env, ctx) {
    await env.MY_QUEUE.send({
      url: request.url,
      time: Date.now(),
    });
    return new Response("Queued!");
  },

  // CONSUMER: runs in the background with a batch of messages
  async queue(batch, env, ctx) {
    for (const message of batch.messages) {
      console.log("Processing:", message.body);
      // ...do the slow work here...
      message.ack(); // mark this message as done
    }
  },
};
done_all

ack and retry

Call message.ack() when a message is handled successfully. If your consumer throws an error or calls message.retry(), Queues will redeliver that message later — up to the retry limit — so failures heal themselves.

school

Key concepts

outbox

Producer

The Worker that sends messages into the queue with env.QUEUE.send().

inbox

Consumer

The queue() handler that Cloudflare invokes with batches of messages to process.

inventory

Batch

A group of up to 100 messages delivered together for efficient processing.

done_outline

Acknowledge (ack)

Marking a message as successfully done so it won't be delivered again.

replay

Retry

Redelivery of a message that failed, automatically, up to 100 attempts.

report

Dead Letter Queue

A separate queue where messages go after exhausting all retries, so you can inspect them.

tips_and_updates

Tips & pricing

report

Always set a Dead Letter Queue

Configure a dead letter queue so messages that keep failing don't vanish — they land somewhere you can inspect and fix later, instead of being dropped after the retry limit.

Good limits to remember

  • Up to 10,000 queues per account
  • Max message size: 128 KB
  • Max batch: 100 messages (or 256 KB total)
  • Max batch wait: 60 seconds
  • Throughput: up to 5,000 messages/second per queue
  • Retries: up to 100; retention configurable up to 14 days
savings

Free to start, no egress

Queues is available on both Free and Paid plans, and never charges egress (bandwidth) fees. On the Free plan, message retention is fixed at 24 hours.