Skip to content

Benchmarks

bunqueue includes a comprehensive benchmark suite for performance testing, stress testing, and production validation.

Quick Results

Push Throughput

1.2M+ ops/sec

With batch operations (1000+ jobs)

Process Rate

494,000 ops/sec

Full cycle with 16 workers

Scale Tested

1 Million Jobs

Verified data integrity at scale

Memory Efficient

~100 bytes/job

At scale with removeOnComplete: true


Live Benchmark Results

These results were measured on Mac Studio M1 Max, 32GB RAM, Bun 1.3.8.

Throughput by Operation

Throughput benchmark chart
OperationThroughputNotes
PUSH579,603 ops/secSingle job insertion
PULL420,835 ops/secSingle job retrieval
ACK464,857 ops/secSingle job acknowledgment
BATCH(100)1,259,234 ops/secBatch push, 100 jobs
BATCH(1000)1,452,193 ops/secBatch push, 1000 jobs

Batch Size Scaling

Batch size scaling chart
Batch SizeThroughputSpeedup vs Individual
Individual579,603/s1x
1001,259,234/s2.2x
1,0001,452,193/s2.5x
5,0001,393,745/s2.4x

Worker Benchmark (Realistic Workload)

Worker benchmark chart
ScalePush RateProcess RateTotal Events
10,000 jobs519,445/s217,980/s✅ 10,000
50,000 jobs604,918/s243,945/s✅ 50,000
100,000 jobs611,819/s232,613/s✅ 100,000

Million Jobs Benchmark

Million jobs benchmark chart
MetricResult
Total Jobs1,000,000
Push Rate1,210,654 ops/sec
Process Rate494,805 ops/sec
Overall Rate351,247 ops/sec
Total Time2.85 seconds
Data Integrity✅ PASSED (100%)

Stress Test Results

Stress test results chart
TestConfigurationThroughputStatus
High Volume100K jobs, single queue140,032/s✅ PASS
Concurrent Queues10 queues × 10K jobs138,336/s✅ PASS
Large Payloads5K jobs × 10KB each384,781 MB/s✅ PASS
Priority Stress50K jobs, random priorities179,983/s✅ PASS
Retry Storm10K jobs, 50% fail rate-✅ PASS
Batch Operations100K jobs, batch=1000266,619/s✅ PASS

Benchmark Suite Overview

bunqueue includes 6 specialized benchmarks:

BenchmarkPurposeJobsDuration
throughput.bench.tsIndividual operation speeds10K-50K~30s
worker.bench.tsRealistic worker simulation10K-100K~60s
stress.bench.tsProduction validation (7 tests)5K-100K~3min
million-jobs.bench.tsHigh-volume integrity test1M~5min
10million-jobs.bench.tsExtreme stress test10M~15min
completed-events.bench.tsEvent delivery verification10K~30s

Running Benchmarks

Terminal window
# Clone and install
git clone https://github.com/egeominotti/bunqueue.git
cd bunqueue
bun install
# Individual benchmarks
bun run src/benchmark/throughput.bench.ts
bun run src/benchmark/worker.bench.ts
bun run src/benchmark/stress.bench.ts
bun run src/benchmark/million-jobs.bench.ts
bun run src/benchmark/10million-jobs.bench.ts
bun run src/benchmark/completed-events.bench.ts

Detailed Benchmark Documentation

File: src/benchmark/throughput.bench.ts

Measures raw throughput of individual queue operations with warmup.

Operations Tested

OperationDescriptionMeasured Speed
PUSHSingle job insertion579,603/s
PULLSingle job retrieval420,835/s
ACKSingle job acknowledgment464,857/s
FULL CYCLEPush → Pull → Ack182,822/s
BATCH PUSH (100)Batch insertion1,259,234/s
BATCH PUSH (1000)Batch insertion1,452,193/s

How It Works

// 1. Warmup (100 iterations)
for (let i = 0; i < 100; i++) {
await fn();
}
// 2. Timed execution
const start = performance.now();
for (let i = 0; i < totalJobs; i++) {
await fn();
}
const durationMs = performance.now() - start;
// 3. Calculate throughput
const jobsPerSecond = (totalJobs / durationMs) * 1000;

Performance Tuning Guide

Batch Size Recommendations

ScenarioPush BatchPull Batch
Low latency (real-time)100-50010-50
High throughput1,000-5,000500-1,000
Extreme volume5,000-10,0001,000+

Worker Count Tuning

Optimal Workers = min(CPU cores, shard count)

bunqueue uses 16 shards by default:

  • 4-core machine: 4-8 workers
  • 8-core machine: 8-16 workers
  • 16+ core machine: 16 workers

Memory Optimization

removeOnComplete: true

Maximum throughput (~495K/s)

  • Jobs removed after completion
  • No result storage
  • Best for fire-and-forget

removeOnComplete: false

~25% slower (~370K/s)

  • Jobs tracked after completion
  • Results queryable
  • Required for dependencies

Why bunqueue is Fast

Native SQLite

Direct FFI bindings via bun:sqlite. WAL mode for concurrent reads/writes. Memory-mapped I/O.

16 Shards

Minimizes lock contention. Each shard handles ~6% of queues. Parallel processing by design.

Batch Optimization

Single transaction for bulk operations. Prepared statements reused. ackBatchWithResults for throughput.

Efficient Structures

Skip lists for O(log n) priority. MinHeap for delayed jobs. Bounded collections prevent leaks.


Benchmark Environment

For reproducible results, note your environment:

Terminal window
# System info
uname -a
bun --version
# CPU info (macOS)
sysctl -n machdep.cpu.brand_string
# CPU info (Linux)
cat /proc/cpuinfo | grep "model name" | head -1

Reference hardware (used for these results):

  • Mac Studio, Apple M1 Max, 32GB RAM
  • macOS 26.2 (Tahoe)
  • Bun 1.3.8
  • SSD storage

Pass Criteria Summary

BenchmarkPass ConditionResult
ThroughputOperations complete
Workerevents === jobs
Stress: High Volumeevents === jobs
Stress: Concurrentevents === totalJobs
Stress: PriorityorderViolations === 0
Stress: Retrycompleted + dlq === jobs
Million JobsData integrity 100%
EventscompletedEvents === jobs

Submit Your Results

Run benchmarks on your hardware and share results via GitHub Discussions to help others compare.

Include:

  • CPU model
  • RAM
  • Bun version
  • OS
  • Benchmark output