Skip to content

Throughput and benchmarks

The repository has a benchmark, drain: it publishes a backlog of no-op jobs, starts the workers, and measures how fast they empty the queues. No-op jobs measure MassiveJobs and the broker, not your jobs: real jobs are usually slower than the machinery around them, and then the parallelism you give them matters more.

100,000 no-op jobs, MassiveJobs’ defaults (4 immediate queues, 1 job per worker, batches of 250), one app, RabbitMQ 4.4 in a container on the same 4-vCPU machine:

Broker Jobs per second Allocated per job
RabbitMQ 4.4 about 95,000–100,000 1.7 KB
In memory about 800,000 0.7 KB

The job is a JobAsync that finishes at once, so these numbers are MassiveJobs’ own overhead. A synchronous job (Job<…>, or a plain class with a synchronous Perform) runs on the thread pool, so that an explicit timeout can abandon it: that costs about 0.7 KB more per job, and on RabbitMQ about 15% more CPU per job at the same throughput.

Single runs on RabbitMQ vary by up to 15%. Compare setups in alternating rounds, on the same machine.

The same 4 jobs at once, arranged differently (RabbitMQ, same machine):

Queues × jobs per worker Jobs per second
4 × 1 (the default) about 95,000
2 × 2 about 72,000
1 × 4 about 44,000

For short jobs, the queues set the throughput: each queue is consumed in order, and more queues spread the work over more of the broker. For jobs that mostly wait, more jobs per worker are the cheaper lever. See Queues and workers.

The batch size (the prefetch) matters too. In an earlier measurement, on an older layout, a batch of 1 drained 500 jobs/s, 8 drained 3,000, 200 drained 40,000 and 1,000 drained 65,000: with a small batch the workers wait for the broker between jobs. Acknowledging finished jobs together rather than one by one added about a third.

Terminal window
git clone https://github.com/enadzan/massivejobs && cd massivejobs
docker run -d --name mj-rabbit -p 5672:5672 -e RABBITMQ_DEFAULT_VHOST=massivejobs.tests rabbitmq:4-management
dotnet build MassiveJobs.Benchmarks -c Release
dotnet MassiveJobs.Benchmarks/bin/Release/net10.0/MassiveJobs.Benchmarks.dll drain --rabbitmq
dotnet MassiveJobs.Benchmarks/bin/Release/net10.0/MassiveJobs.Benchmarks.dll drain --runs 7 # in memory
docker rm -fv mj-rabbit

--jobs, --runs, --workers, --parallelism and --batch-size change the setup.