Backpressure

Backpressure is a signal that tells a producer to slow down when consumers cannot keep up. If workers finish 1,000 jobs/s, a full buffer of 100,000 jobs makes the last job wait 100 s. A small buffer that rejects the excess keeps each accepted job on time.

Play a level

See it on the board

The same traffic runs on two boards. The simulator measured both when this page was built.

Board to show
AMQPHTTP/2UsersWorker1 vCPU · 1 GBMessage bro…1 vCPU · 1 GB
AMQPHTTP/2UsersWorker1 vCPU · 1 GBMessage bro…1 vCPU · 1 GB
Buffer of 100,000 jobs, no backpressure: misses a goal
AMQPHTTP/2UsersWorker1 vCPU · 1 GBMessage bro…1 vCPU · 1 GB
AMQPHTTP/2UsersWorker1 vCPU · 1 GBMessage bro…1 vCPU · 1 GB
Buffer of 400 jobs with backpressure on: meets the goals
See it on the board
Measure Goal Buffer of 100,000 jobs, no backpressure Buffer of 400 jobs with backpressure on
p99 latency under 150 ms 47 ms Pass 47 ms Pass
Queue lag under 3 s 32.1 s Fail 1.8 s Pass
Error rate under 95% 0% Pass 79.3% Pass
Lost writes none 0 Pass 0 Pass
Completion time under 38 s 40 s Fail 31.23 s Pass
Monthly cost 8 USD/mo 8 USD/mo
Level rules none broken Board is not complete Fail Pass

Key numbers

Default part values from the catalog. The simulator uses the same values.
NumberValue
Queue buffer size, default10,000 jobs
Queue memory for each held job64 KB
Jobs per second, one queue20,000 ops/s
Worker pool size, one worker, default64 workers
A buffer with a valveDrag or use arrow keys to change the buffer size

Buffer 1,000 jobs · last job waits 1.0 s · 17% turned away

How it works

A buffer absorbs short bursts. When the arrival rate stays above the service rate, the buffer only grows. Each new job waits longer than the one before, uses memory, and can time out at the caller before a worker starts it. The caller then retries, which adds more work.

Backpressure stops this growth at the edge. When the queue is full, it refuses the new job at once, or tells the producer to wait. The producer can slow down, try later with backoff, or show the user a clear busy message. The jobs that the system accepted still finish within their target.

The buffer size sets the longest wait. Divide the buffer size by the rate at which workers finish jobs: 400 jobs at 200 jobs/s is a wait of 2 s. Choose the size from the wait that you can accept, not from the memory that you have.

A rejection must be cheap and clear. If callers retry at once and without a limit, the rejections become a new overload. Use backpressure together with retry limits and backoff at the caller.

In the levels you make a large buffer small, turn on backpressure and keep every accepted job safe.