Download the PHP package webpatser/torque without Composer

On this page you can find all versions of the php package webpatser/torque. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package torque

Torque

The queue that keeps spinning. Coroutine-based queue worker for Laravel.

Torque replaces Horizon's 1-job-per-process model with N-jobs-per-process using PHP 8.5 Fibers. When a job waits on I/O, the scheduler switches to another job, so a handful of processes deliver the throughput Horizon needs dozens of processes for.

[!NOTE] Numbers from the fair benchmark. On long-running async I/O (HTTP fan-out, slow external APIs) Torque delivers up to 15x throughput at 95% lower memory footprint. On pure CPU work it is comparable or slightly slower than Horizon, by design.

[!TIP] Live job progress, built in. Every job records a per-job event timeline (queued / started / exception / completed) to a Redis Stream. Tail it from the CLI with torque:tail --job=<uuid>, read it programmatically, or stream it to the dashboard / your own UI. Custom progress events are a one-line $this->emit('...', progress: 0.42) away. No log scraping, no separate progress table, no extra Redis keys to manage.

When to use Torque

When to use Horizon instead

[!IMPORTANT] Torque only wins when your jobs spend time waiting. If they spend time computing, the Fiber scheduler has nothing to switch to and you pay overhead for nothing. Use the right tool for the workload.

Requirements

Installation

Publish the config:

Add the queue connection to config/queue.php:

Set it as default in .env:

Usage

Starting the worker

Options:

Dispatching jobs

Standard Laravel dispatching works unchanged:

Async jobs with TorqueJob

Regular Laravel jobs work fine; they run synchronously within their coroutine slot. For full async I/O, extend TorqueJob and type-hint the pools you need:

Working with databases (avoid the Eloquent trap)

[!WARNING] Eloquent uses PDO, which is sync-blocking. One User::find($id) in a handler stalls the entire worker (and every other Fiber on it) until the round-trip completes. On a 25-coroutine worker that's effectively concurrency 1 for the duration of that call, which destroys the fanout advantage Torque is built around.

The fix is to either keep Eloquent out of the handler, or use the async MysqlPool for the queries that matter:

When sync Eloquent is fine:

When sync Eloquent is a footgun:

Same pattern applies to other sync clients: curl_exec, Guzzle without a non-blocking handler, usleep, blocking file I/O. Replace with HttpPool, Fledge\Async\delay(), or pre-compute outside the handler.

Per-Fiber state isolation

Use CoroutineContext when you need per-job isolated state (e.g., request-scoped data):

State is automatically cleaned up when the Fiber completes (backed by WeakMap).

Live job progress (built in)

Every job automatically records a lifecycle timeline to a per-job Redis Stream: queued, started, exception, completed, plus any custom events you emit. Watch it live from the CLI, the dashboard, or your own UI without instrumenting each job by hand.

Custom progress events

Add the Streamable trait to emit progress from inside your job:

Reading streams programmatically

Streams auto-expire after 5 minutes (configurable via job_streams.ttl).

Redis Cluster Support

Torque supports Redis Cluster out of the box. Enable it in your .env:

When cluster mode is enabled, all Redis keys for a given queue are wrapped in hash tags ({queue-name}) so they land on the same cluster slot. This ensures Lua scripts and multi-key operations work correctly across the stream, delayed set, and notification keys.

If your queue names already contain hash tags (e.g., {myqueue}), Torque will not double-wrap them.

CLI Commands

Command Description
torque:start Start the master + worker processes
torque:stop Graceful shutdown (SIGTERM). Use --force for SIGKILL
torque:status Show worker metrics, throughput, and queue depths
torque:monitor Live htop-style terminal dashboard
torque:tail Tail a job's event stream in real-time
torque:pause Pause job processing (in-flight jobs complete). Dispatches WorkerPausing to any registered listener
torque:pause continue Resume processing. Dispatches WorkerResuming
torque:supervisor Generate a Supervisor config file

Configuration

All options are in config/torque.php. Key settings:

Setting Default Description
workers 4 Number of worker processes
coroutines_per_worker 50 Concurrent job slots per worker
max_jobs_per_worker 10000 Restart worker after N jobs (prevents memory leaks)
max_worker_lifetime 3600 Restart worker after N seconds
drain_grace_seconds 10 Seconds Fibers get to finish in-flight jobs before the worker hard-exits on rotation
stall_warn_seconds 300 Watchdog logs a WARN for any slot whose current job has been running longer than this
block_for 2000 Poll interval in ms (how often idle Fibers check for new jobs)
redis.cluster false Enable Redis Cluster hash tag support

Autoscaling

Connection pools

Dashboard

Torque includes a Livewire 4 + Flux UI Pro dashboard at /torque (configurable).

Features:

Styling the dashboard

The dashboard uses Flux UI Pro + Tailwind utilities, which are compiled from your application's own Vite build. Two things must be in place:

  1. Install Flux Pro in your host app (you almost certainly already have it):

  2. Add Torque's views to Tailwind's source scan in resources/css/app.css:

Without the @source line, Tailwind won't generate the classes used inside the dashboard and you'll get an unstyled page.

Authorization

The gate viewTorque is checked on the dashboard route and on every Livewire action (retry, purge, navigate), so the action endpoints cannot be reached by users who would fail the gate. Define it in your AuthServiceProvider:

If you don't define a gate, Torque falls back to app()->environment('local'); the dashboard shows up in development but stays locked in production until you define the gate explicitly.

Retries from the failed-jobs page only accept targets that exist in config('torque.streams'), so a compromised session cannot inject jobs into arbitrary Redis streams.

Dashboard middleware

Default: ['web', 'auth']. Override in config:

Failed jobs

Jobs that exhaust all retries are moved to a dead-letter Redis Stream. You can:

Architecture

How it works

  1. Master spawns N worker processes via pcntl_exec() (php artisan torque:worker)
  2. Each worker runs a Revolt event loop with M Fiber slots
  3. Each Fiber polls for messages with non-blocking XREADGROUP (no BLOCK). When no work is available, the Fiber yields to the event loop with a configurable delay (block_for / 1000 seconds). This ensures timers (delayed job migration, metrics, pause checks) always fire reliably
  4. Fiber startup is staggered across the poll interval so polling is evenly distributed
  5. Work-stealing: idle Fibers claim stale messages from dead consumers via XAUTOCLAIM (per-queue retry_after as idle threshold)
  6. On completion: XACK + XDEL. On failure: retry with exponential backoff or dead-letter
  7. A shared pause flag (updated by a timer) replaces per-Fiber Redis checks, reducing overhead from 50 EXISTS calls per cycle to 1

Queue backend: Redis Streams

Redis Streams (not LISTs like Horizon) provide:

Compatibility

Feature Horizon Torque
Queue backend Redis LIST Redis Streams
Concurrency 1 job/process N jobs/process (Fibers)
I/O model Blocking (PDO, curl) Non-blocking (fledge-fiber)
PHP extensions None None (igbinary optional)
Eloquent in jobs Full support Works, but blocks Fibers; use MysqlPool for fan-out
Laravel Queue contract Full Full
Job batches Yes Yes
Delayed jobs Redis sorted set Redis sorted set
Redis Cluster Yes Yes
Dashboard Blade + polling Livewire 4 + Flux UI
Autoscaling Balancing strategies Slot-pressure based
Per-job event timeline Logs + failed-job retry First-class, live-tailable per UUID
Live job progress Custom code per job $this->emit(...) via Streamable
Worker pause/resume events WorkerPausing / WorkerResuming (13.8) Same events, dispatched on torque:pause flips
Queue inspection (all*) allPendingJobs / allReservedJobs / allDelayedJobs (13.8) Same API on StreamQueue

Production deployment

Generate a Supervisor config:

This creates storage/torque-supervisor.conf. Copy it to your Supervisor config directory:

Performance

Fair comparison vs Laravel queue:work / Horizon

Same hardware, same Redis, same number of OS processes (2 each), 1000 jobs per run, median of 3 measured runs after a 100-job warmup. Each job emits one XADD result-event so measurement overhead is symmetric on both sides. Full reproduction recipe in BENCHMARKS.md.

Workload Laravel queue:work (2 procs) Torque (2 workers x 25 fibers) Δ vs Laravel
cpu (5000x xxh3 hash per job) 782/s 560/s 0.72x slower
mixed (sync I/O + CPU) 490/s 410/s 0.84x slower
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

[!TIP] The pattern is consistent: Torque wins when handlers yield to I/O, loses when handlers occupy the OS thread. The fanout row is the workload Torque was built for. Pure CPU is not.

Memory at equivalent throughput (the production framing):

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%

For a queue dominated by external API calls and webhooks, that translates directly to fewer servers, less memory pressure, and headroom to absorb traffic spikes without provisioning ahead of time.

Benchmarking your own workload

Torque ships with a torque:bench command that produces reproducible numbers (jobs/sec, p50/p95/p99 latency) on your actual hardware. Run it before tuning anything: serializer choice, worker count, coroutines per worker. Optimization without numbers is guesswork.

Workload profiles:

Profile What it simulates
cpu Tight hash loop, measures handler-side CPU under Fibers
io usleep(2 ms) per job, simulates Redis/HTTP/DB wait
mixed (default) 80% I/O, 20% CPU, realistic web-app queue
payload-small 256 B blob, baseline for serializer overhead
payload-large 64 KiB blob, where serializer choice actually shows

Flags: --workers, --coroutines, --jobs, --warmup, --serializer, --json, --force. See php artisan torque:bench --help for the full list.

[!NOTE] The v1 bench command requires --use-running-master. Start a torque worker fleet first (php artisan torque:start), then run the bench against it. Self-spawning workers from inside the bench command lands in a follow-up release.

For deeper profiling, use XHProf or Excimer on a running worker. The bench output tells you whether to bother.

igbinary: ~2x faster payload encoding

Torque can encode its Redis Streams envelope with igbinary instead of JSON. Roughly 2x faster on encode and decode, smaller on the wire. Recommended once you have a baseline benchmark to compare against.

Install (PECL):

Or via your distro: apt install php8.5-igbinary on Debian/Ubuntu, brew install [email protected] style packages on macOS.

Enable in your .env:

Verify with the bench command:

torque:start prints Serializer: igbinary on boot when active, and a one-line install hint when the extension is missing.

[!TIP] Safe to flip while running. Torque sniffs the first byte of every payload ({/[ for JSON, \x00\x00\x00\x02 for igbinary), so in-flight messages decoded with the old format keep working. New messages come out as igbinary. Both coexist until the stream organically drains.

[!WARNING] Igbinary payloads are binary, not human-readable. redis-cli XRANGE torque:default - + returns gibberish for the payload field once you flip the switch. Stick with --serializer=json (the default) during debugging sessions.

[!TIP] Setting igbinary.compact_strings = On in php.ini also speeds up Laravel's session and cache serialize() calls globally, even without flipping the torque serializer. Free win across your whole app.

Dependencies

Required (installed automatically):

Optional (install when needed):

License

MIT


All versions of torque with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
illuminate/queue Version ^13.8
illuminate/console Version ^13.8
illuminate/support Version ^13.8
revolt/event-loop Version ^1.0
livewire/flux Version ^2.0
webpatser/fledge-fiber Version ^13.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webpatser/torque contains the following files

Loading the files please wait ...