~/docs
Resonate
Resonate
2.x 2.4.0, current
Torque
Toggle sidebar
Torque
webpatser/torque 2.4.0

Torque 2.x

Benchmarks

Throughput of Torque against plain queue:work, the workload profiles, memory at equal throughput and how to reproduce the run.

The numbers below come from the repository's BENCHMARKS.md. They are from a single test machine: Apple M-series, PHP 8.5.5, Redis 7 on loopback, 2 OS processes per side. That run used PHP 8.5.5, before 2.4.0 raised the requirement to PHP 8.6. The numbers are illustrative, not absolute. Run the recipe on your hardware against your workload before drawing conclusions.

Throughput

Same hardware, same Redis, 2 OS processes each, 1000 jobs per run, median of 3 measured runs after a 100-job warmup. Each job emits one XADD to a results stream, so measurement overhead is symmetric.

Workload Laravel queue:work (2 procs) Torque (2 workers x 25 fibers) Ratio
cpu (5000x xxh3 hash per job) 782/s 560/s 0.72x
mixed (sync I/O + CPU) 490/s 410/s 0.84x
io (usleep 2 ms, blocking) 387/s 387/s 1.0x
payload-large (64 KiB JSON) 337/s 535/s 1.6x
async-io (Fledge\Async\delay 2 ms) 378/s 910/s 2.4x
fanout (100 ms async wait) 18/s 281/s 15x

Torque wins when handlers yield to I/O and loses when handlers occupy the OS thread. On Torque, async-io and fanout suspend the Fiber; on queue:work they collapse to blocking sleeps.

Memory at equivalent throughput

To match Torque's 280 jobs/sec on fanout, the repository extrapolates linearly from the 2-process measurement (280 / (18/2), about 31) to roughly 30 queue:work processes.

The Horizon-side RAM figures are extrapolated from process counts, not measured.

Workload Horizon procs for ~280 jobs/sec Torque procs Memory savings
fanout (100 ms async wait) ~30 (~2.5 GB RAM) 2 (~120 MB) ~95%
async-io (2 ms wait) ~5 (~400 MB RAM) 2 (~120 MB) ~70%

Workload profiles

Profile What it does
cpu 5000x hash('xxh3', random_bytes(64)) per job
io usleep(2 ms) per job
async-io Fledge\Async\delay(2 ms) on Torque, usleep on Horizon
fanout 100 ms async wait, or blocking on Horizon
mixed 80% io, 20% cpu interleaved
payload-small 256-byte blob in the constructor
payload-large 64 KiB blob

igbinary

Torque side only, same 1000-job, 3-run method:

Workload JSON igbinary Change
mixed ~393 ~393 0%
payload-large ~498 ~833 +67%
io ~370 ~370 0%
cpu ~540 ~540 0%

The gain is concentrated in large payloads.

Run it on your workload

torque:bench produces jobs per second and p50, p95 and p99 latency. The v1 command requires a running fleet:

php artisan torque:start
php artisan torque:bench --use-running-master --workload=payload-large --jobs=10000

Compare serializers with JSON output. --serializer only labels the run in its metadata; the running fleet's TORQUE_SERIALIZER decides the encoding, so restart the fleet (and the bench process) with TORQUE_SERIALIZER=json or igbinary for each run:

php artisan torque:bench --use-running-master --workload=payload-large --serializer=json --json=baseline.json
php artisan torque:bench --use-running-master --workload=payload-large --serializer=igbinary --json=igbinary.json
jq -s '.[0].results.throughput_per_sec, .[1].results.throughput_per_sec' baseline.json igbinary.json

To reproduce the comparison with queue:work, assuming a Laravel app with Redis on 127.0.0.1:6379:

# Horizon / queue:work side
composer require laravel/horizon --dev
php artisan horizon:install
cp <torque-package>/bench/horizon-comparison/HorizonBenchJob.php app/Jobs/
 
redis-cli FLUSHDB
QUEUE_CONNECTION=redis php artisan queue:work redis --sleep=0 --tries=1 --memory=512 &
QUEUE_CONNECTION=redis php artisan queue:work redis --sleep=0 --tries=1 --memory=512 &
 
php <torque-package>/bench/horizon-comparison/run-horizon-bench.php fanout 1000 100
 
# Torque side (separate shell, same Redis)
QUEUE_CONNECTION=torque php artisan torque:start --workers=2 --concurrency=25 &
php artisan torque:bench --use-running-master --jobs=1000 --warmup=100 \
--workload=fanout --workers=2 --coroutines=25

Run each workload three times per side, drop the cold first run and take the median.

What it does not measure

  • Cold-start latency (workers are warmed up).
  • Failure recovery (no retries, no failed-job tracking).
  • Memory growth under load (steady-state RSS only).
  • Real-world payload variance.
  • Network-bound Redis (assumes fast loopback Redis).
  • Per-stage timings (serialize, xadd, xreadgroup, handle, xack), which the repository lists as not yet captured.