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

Torque 2.x

Introduction

Torque is a coroutine-based queue worker for Laravel that runs many jobs per process on PHP Fibers and Redis Streams.

Torque replaces the one-job-per-process model of Horizon with N jobs per process, using PHP 8.6 Fibers. When a job waits on I/O, the scheduler switches to another job, so a few processes carry the throughput that otherwise takes dozens. This documentation covers release 2.4.0 of the 2.x line.

2 workers x 25 fibers in about 120 MB RAM (Apple M-series, PHP 8.5.5, loopback Redis 7)

The numbers behind this, with the machine they were measured on, are on the benchmarks page. They were measured on PHP 8.5.5, before 2.4.0 raised the requirement to PHP 8.6.

Warning: Torque only wins when jobs spend their time waiting. If they compute, the Fiber scheduler has nothing to switch to and you pay overhead for nothing.

When to use Torque

  • HTTP fan-out: calling N external APIs per job
  • Slow external services (more than 50 ms latency per call)
  • Webhook delivery to many endpoints
  • Bulk operations against rate-limited APIs
  • Search index updates, cache warming, notification fan-out
  • Any I/O-bound workload where you currently scale by adding more Horizon processes

When to use Horizon instead

  • CPU-bound jobs (image processing, PDF generation, encoding, ML inference)
  • Jobs that use sync-blocking calls (curl_exec, usleep, PDO without an async wrapper)
  • Setups that depend on mature Horizon operations tooling
  • Workloads where memory per worker is not a concern

What is in the box

  • A torque queue connection backed by Redis Streams with consumer groups, XACK and work stealing through XAUTOCLAIM.
  • A master process that forks workers, each running the Fledge event loop with a configurable number of Fiber slots.
  • Per-job event timelines in Redis Streams, tailed with torque:tail.
  • A Livewire 4 dashboard, off by default.
  • A dead-letter stream, a circuit breaker per stream, long-wait alerts, tags and silenced jobs.
  • Async pool classes (MysqlPool, HttpPool, RedisPool) you can type-hint in handlers once MysqlPool and RedisPool are bound in your app.
  • Zero-downtime reload and a Supervisor config generator.
  • Autoscaling based on slot pressure.

Dependencies

Required, installed by Composer: webpatser/fledge-loop (Fledge Loop) as the event loop and webpatser/fledge-fiber (Fledge Fiber) for async primitives and non-blocking Redis.

MysqlPool and HttpPool use the MySQL and HTTP clients in webpatser/fledge-fiber, which is already required. Only ext-igbinary (igbinary serializer) is optional.

Fledge's async layer started as a port of amphp and its event loop as a port of Revolt, both MIT licensed. Fledge has since gone its own way and is maintained independently.

Next