The master records the installed version in Redis ({prefix}version) and, on the first torque:start after a deploy, runs the data steps for every version between the recorded one and the installed one. Nothing is required from you unless a section below says so. A stored version below 1.4.0 refuses to start (since 2.0.0). torque:status shows the recorded data version next to the installed one.
To preview cleanup of leftovers from older versions before restarting the fleet:
php artisan torque:prune --deep --dry-runphp artisan torque:prune --deep
2.4.0
- PHP
^8.6is required; PHP 8.5 is no longer supported. - The event loop is
webpatser/fledge-loop(Fledge\Loop) instead ofrevolt/event-loop(Revolt\EventLoop), which Torque no longer requires and which cannot be installed next to it. Code of your own that callsRevolt\EventLoop(job classes, listeners, service providers) has to move toFledge\Loop: same static methods, no alias layer. Drain queues whose serialized payloads reference Revolt classes before deploying. webpatser/fledge-fiber^13.43.0.3is required.- New
event_loopconfig key (FLEDGE_EVENT_LOOP). See Configuration. - A Composer path repository, Torque as the root package, a branch and
1.0.0+no-version-setnow count as a dev install: the upgrade steps run, nothing is recorded in{prefix}version. A key that already holds a bogus1.0.0keeps refusing until you runSET {prefix}version 1.4.0. - Workers that die within 10 seconds of spawning are respawned with a backoff. See Deployment.
2.3.0
Fleet metrics per host
No data step and no config change. The Redis layout of the fleet aggregate and the cluster gauges changes; only tooling that reads those keys directly has to follow.
redis.read_timeout_seconds(default 30) now also applies to the master's own Redis reads.{prefix}metricsis no longer written. Each master writes its host's aggregate to{prefix}metrics:live:{host}(a hash, 30 second TTL) and adds the host to the sorted set{prefix}metrics:live, scored by the publish epoch.- Cluster gauges in
{prefix}metrics:gauge:{tier}are written per host foravg_latency_ms,concurrent,memory_mbandworker_memory_peak_mb, in fields{bucket}:{host}:{metric}.pendinganddelayedkeep the unscoped field. {prefix}metrics:hosts:firstis a new sorted set scored by the epoch a host was first seen.- The rollup and gauge prune takes a
SET NXclaim,{prefix}metrics:prune:{key without prefix}:{bucket}, so one master prunes each shared hash per bucket. - New key
{prefix}metrics:workers: a sorted set of worker ids scored by last heartbeat, with a 60 second TTL refreshed on every publish. - Redis Cluster users must set
redis.cluster(TORQUE_CLUSTER=true). Job events now go through one script that touches the event stream and both dashboard indexes; without the flag it is rejected with CROSSSLOT.
External tooling that read HGETALL {prefix}metrics should run ZRANGEBYSCORE {prefix}metrics:live <now - 30> +inf and then HGETALL {prefix}metrics:live:{host} for each member, or call MetricsPublisher::readAggregate($redis, $prefix) in PHP. Tooling that scanned {prefix}worker:* can read ZRANGE {prefix}metrics:workers 0 -1 and HGETALL {prefix}worker:{id}.
Rolling deploy: with old and new masters side by side only the upgraded hosts' aggregates are summed, so the overview undercounts until the last host is upgraded; it never double counts. Hosts that go away drop out of the sums 30 seconds after their last publish.
Prune, flush and autoscaler behaviour
No data step and no config change.
torque:prune --deepkeeps recent consumers. Without--consumer-idleit deletes only consumers without pending work idle for 3600 seconds. Pass--consumer-idle=0for the old sweep. The option must be a whole number of seconds, 0 or more.torque:prunefollowsdead_letter.max_entries:--dead-letter-maxno longer defaults to 100000.torque:flushis scoped to the queues it flushes and no longer deletes every{prefix}job:*key. An empty or invalid--queuesvalue exits with an error.- The autoscaler grows the fleet to
min_workers, one worker per decision, subject to the cooldown. Setworkersto at leastmin_workersif you did not intend that.
1.4.x to 2.0.0
No data step, but not a drop-in upgrade. 2.0.0 refuses to start on data older than 1.4.0, changes when jobs fail for every install, and changes defaults that reach you only in part, depending on your published config/torque.php.
Before you upgrade
- Get onto 1.4.x first. The master refuses to start when
{prefix}versionholds a release below 1.4.0: it logsRefusing to start: ...and exits non-zero. Check before the deploy withredis-cli GET {prefix}version. The path: deploy any 1.4.x, start a master once, then deploy 2.0.0. - The check passes when nothing is stored, when the stored value is
dev, and when Redis is unreachable at start. SET {prefix}version 1.4.0is the escape hatch. It skips the removed 0.16.0 cleanup and the 1.0.0 delete of{prefix}metrics:buckets; runphp artisan torque:prune --deepandDEL {prefix}metrics:bucketsafterwards.- Install
laravel/slack-notification-channel3.6 or newer if you have it at all. Composer now conflicts with anything below. - Decide about published config, and run
php artisan config:cacheagain if you cache config.
New config keys
All optional.
| Key | Default | What it does |
|---|---|---|
release_limit_seconds |
86400 |
Env TORQUE_RELEASE_LIMIT. Seconds a job may keep releasing itself; 0 is off |
streams.<name>.release_limit_seconds |
none | Per-stream override; 0 opts that stream out |
reload_pause_seconds |
10 |
Env TORQUE_RELOAD_PAUSE. Was part of drain_grace_seconds |
timeouts.release_delay_seconds |
10 |
Minimum delay of a job released after its timeout. Was part of drain_grace_seconds |
timeouts.settle_seconds |
5 |
Budget of interrupted() and the timeout listeners |
New env variables on the shipped default stream: TORQUE_QUEUE, TORQUE_RETRY_AFTER, TORQUE_MAX_RETRIES, TORQUE_BACKOFF, TORQUE_STREAM_TIMEOUT. A published file keeps its literal streams block and ignores them. With TORQUE_QUEUE set, a connection in config/queue.php with a literal 'queue' => 'default' dispatches to a stream nothing consumes, so use env('TORQUE_QUEUE', 'default') there too.
Changed defaults
A key your published file contains keeps its value. A key it lacks takes the new default, and so does an app with no published file. A file published from 1.3 or 1.4 contains all of the keys below, so it flips none of them until you act.
| Key | 1.x default | 2.0 default | To adopt in a 1.4.x published file | To keep 1.x where it would flip |
|---|---|---|---|---|
strict_attempts |
false |
true |
TORQUE_STRICT_ATTEMPTS=true |
TORQUE_STRICT_ATTEMPTS=false |
timeouts.enabled |
false |
true |
TORQUE_TIMEOUTS=true |
TORQUE_TIMEOUTS=false |
memory_limit |
0 |
512 |
TORQUE_MEMORY_LIMIT=512 |
TORQUE_MEMORY_LIMIT=0 |
loop_stall_kill_seconds |
0 |
null, derived |
Copy the shipped line, or TORQUE_LOOP_STALL_KILL=300 |
TORQUE_LOOP_STALL_KILL=0 |
drain_grace_seconds |
10 |
null, derived |
Copy the shipped line and unset the env variable | TORQUE_DRAIN_GRACE=10 (logs a WARN) |
dashboard.enabled |
true |
false |
Set false if you want it off |
TORQUE_DASHBOARD=true |
Copy the shipped lines rather than only dropping the fallback: (int) env('TORQUE_DRAIN_GRACE') is a grace of 0, not a derived one. Merge by hand instead of vendor:publish --force, which overwrites your streams. The release limit is the exception: no 1.x file has the key, so it applies to every install on the first deploy.
Renamed config keys
Rename these in config/torque.php now. In 2.x the old key still works: its value moves to the new key at boot, the old key wins if the file has both, and the master logs WARN Renamed config keys in use. Torque 3.0 makes this a boot failure.
| Old key | New key | Env |
|---|---|---|
coroutines_per_worker |
slots_per_worker |
TORQUE_COROUTINES to TORQUE_SLOTS_PER_WORKER |
block_for |
poll_interval_ms |
TORQUE_BLOCK_FOR to TORQUE_POLL_INTERVAL_MS |
redis.read_timeout |
redis.read_timeout_seconds |
unchanged |
takeover_ready_timeout |
takeover_ready_timeout_seconds |
unchanged |
job_streams |
job_events |
none |
job_limits (job or stream) |
honour_job_limits (bool, stream maps to false) |
TORQUE_JOB_LIMITS to TORQUE_HONOUR_JOB_LIMITS |
Old env variables keep working silently in the shipped file through 2.x. A published file still on an old key reads only the old env variable. Code that reads config('torque.coroutines_per_worker') now gets null. A queue connection's own block_for in config/queue.php and the --coroutines CLI flag keep their names.
Behaviour changes
- Strict attempts: leave headroom in
$tries. Jobs are checked before they run and fail without running once past their tries orretryUntil. A delivery after a worker went away counts too and ends with reasonredelivery_limit. - Job timeouts: audit every
$timeoutin your job classes before enabling. Those values were ignored until now. A job with no$timeouton a stream with notimeoutstill has no limit. A job past its limit is failed or retried, which counts as a try, and its whole worker rotates (exit 1). - Memory limit: check the ini value of the process running workers. A worker at 512 MB real memory drains and exits with status 12. When ini
memory_limitis lower, PHP fatals first, taking every slot with it; the bootWARN PHP memory_limit is ...is the only signal. The CLI default of 128M triggers it. - Release limit:
$triesno longer ends a releasing job, time does. On every install self-releases stop counting against tries and count againstrelease_limit_seconds. Past the limit the job fails withMaxAttemptsExceededException, runsfailed()and reaches the dead letter with reasonrelease_limit. Check jobs that poll with$triesplusrelease(): add aretryUntil, or count in the job. Opt out with$tries = 0,release_limit_seconds = 0orstreams.<name>.release_limit_seconds = 0. Drain rate-limited queues on 1.4.x first, since a job released under 1.x can fail on its first delivery after the upgrade. Many jobs reaching the deadline together can trip the circuit breaker; set'circuit_breaker' => falseon a stream where that is unwanted.WithoutOverlappingwith its defaultreleaseAfter = 0still spins; give it areleaseAfter. - Drain: regenerate your Supervisor config.
drain_grace_secondsused to do four jobs and is split into grace, reload pause, release delay and settle. Null grace derivesmin(300, longest stream timeout or retry_after), 60 at package defaults, instead of 10. Runphp artisan torque:supervisor --path=...after the upgrade, thensupervisorctl reread && supervisorctl update. An oldstopwaitsecsof 60 SIGKILLs a 60-second drain. A pinned grace is not corrected for you; every worker logsWARN drain_grace_seconds is 10s, below the 60s derived ...once at boot. cache:clearno longer drains workers. When theilluminate:queue:restartkey goes from set to gone a worker logs one line and keeps running. Callqueue:restartortorque:reloadin deploy scripts, and runqueue:restartafter any cache clear.- Stall watchdog: decide whether you accept it. Blocking PDO queries, CPU-bound fibers and sync clients block the loop, so they kill their worker and every sibling slot.
WARN Loop stall watchdogappears at boot on database-cache apps, because worker timers read the default cache synchronously. - Dashboard off by default. Without a published config the dashboard routes are gone after the upgrade; set
TORQUE_DASHBOARD=trueto keep them. A published file has the literaltrue, which does not flip.
API changes
The public API is the Torque facade, Stream\Streamable, JobStream, JobStreamRecorder, Support\StreamQueueResolver, Contracts\Silenced, Events\*, the torque connection through Queue::, the torque:* commands and the config keys. Everything else may change without a major version.
StreamQueue,StreamJobandWorkerProcessare now@internal.UpgradeRunner:LEGACY_BUCKETS_SUFFIXand the 0.16.0 and 1.0.0 steps are removed, the constructor lost itsStreamHousekeeperargument, andMINIMUM_STORED_VERSIONandassertUpgradePath()are new.WorkerId::parse()no longer reads the{host}-{pid}form.- The legacy Slack branch in
LongWaitNotificationis removed. - New
StreamJob::triesUsed(),releases(),releaseDeadline(),retryAfterFailure();StreamQueue::retryAfterFailure(),releaseLimitSeconds();Support\DrainSettings;Support\LegacyConfig.
After the first deploy, look in the log for Refusing to start, WARN Renamed config keys, WARN Loop stall watchdog, WARN PHP memory_limit and WARN drain_grace_seconds.
Rollback to 1.4.x should work but is reasoned, not tested: the extra payload fields look harmless to 1.x. Revert config/torque.php with the code. Jobs that released under 2.0 keep their high attempts, so under 1.x with strict_attempts on they can fail on delivery.
1.3.x to 1.4.0
No data step. Upgrade promptly: the dashboard's viewTorque gate was not checked on Livewire update requests in v0.12.0 through v1.3.0, so a user holding a valid page snapshot could keep calling dashboard actions, including dead-letter retry and purge. 1.4.0 checks the gate on every mount and update and fails closed.
New optional keys: waits, silenced, silenced_tags. The Batches page needs php artisan make:queue-batches-table.
- A self-release no longer records
completed. A job failed withfail()no longer recordscompletedafterfailed. A permanently failed job's status isfailedrather thanexception. - A job waiting longer than the job event TTL loses its
queuedevent. - Tags exist only on jobs dispatched after the upgrade.
- Long-wait alerts run in a child process. Register
LongWaitDetectedlisteners in a service provider.
1.2.x to 1.3.0
No data step. New optional keys: timeouts.enabled (then false), streams.<name>.timeout, loop_stall_kill_seconds (then 0).
- Entries returned at drain go to the tail of the stream, so processing order changes, in every mode.
- Redelivery bookkeeping runs in every mode; counting and the dead-letter reason apply only under
strict_attempts. Queue::popUsing('torque', ...)is supported; register undertorque.
1.1.x to 1.2.0
No data step. New optional keys: job_limits (now honour_job_limits), strict_attempts (then false), memory_limit (then 0), force, redis.read_timeout.
- While the app is down (
artisan down), slots stop polling and claiming. Setforcetotrue(TORQUE_FORCE) to keep processing. - A job's
retryUntil,$tries,maxExceptionsand$backofftake over from the stream'smax_retriesandbackoff;$tries = 0means unlimited. Exponential retries (2**attempts) are capped at 1 hour. size()is now waiting plus delayed plus reserved, andpendingSize()is waiting only, as in the stock Redis queue. Autoscalers and alerts built on these numbers see new values.JobExceptionOccurredfires afterJobFailedon the fail path.- New events:
WorkerStarting,WorkerStopping,WorkerIdle,WorkerQueuePaused,WorkerQueueResumed,JobPopping,JobPopped,JobReleasedandJobReleasedAfterException.JobPoppingfires on every poll, about 25 per second at 50 slots, so keep its listeners cheap. - Per-attempt isolation grew:
Logcontext,Authguards andCache::memo().
0.18.x to 1.0.0
1.0.0 is the first stable release. Coming from 0.15.x or older, upgrade to any 0.16, 0.17 or 0.18 release first and start the master once. A 1.0.0 data step deletes {prefix}metrics:buckets on the first torque:start. StreamHousekeeper::deepClean() returns a worker_hashes count in place of legacy_keys.
0.17.x to 0.18.0
- Requires
illuminate/*^13.34andwebpatser/fledge-fiber^13.38. #[CountCrashesAsExceptions]is honoured. Set each stream'sretry_afterlonger than its longest job, or a job stolen throughXAUTOCLAIMwhile still running is counted as a crash.push()andlater()return?string: null for anafterCommitjob dispatched inside a transaction.- igbinary payloads are only decoded when
torque.serializerisigbinary. Drain the queues before switching serializers. - The dashboard redacts more, the master refuses a symlinked
storage/torque.lock, and queue enumeration usesSCANinstead ofKEYS.
0.16.x to 0.17.0
Nothing to migrate. New optional key dashboard.default_range (1h). The dashboard has one time range for every screen, picked in the topbar and remembered for the session; the workers screen is grouped by host, and the queues screen is range-scoped.
0.15.x to 0.16.0
A one-off cleanup of leftovers runs on the first start. Ongoing housekeeping runs every dead_letter.prune_interval seconds. New keys: dead_letter.max_entries, dead_letter.prune_interval, circuit_breaker.*, metrics.retention (was 3600), metrics.rollups.*, dashboard.gauge_max. Dead-letter entries beyond max_entries are evicted oldest first; schedule queue:prune-failed --hours=168 for the failed_jobs table. Set maxmemory and maxmemory-policy noeviction on the Redis instance.
Coming from Horizon
| Horizon | Torque |
|---|---|
horizon |
torque:start |
horizon:status |
torque:status, torque:monitor for a live view |
horizon:pause / horizon:continue |
torque:pause / torque:pause continue |
horizon:terminate |
torque:stop (graceful), torque:reload (zero-downtime takeover) |
horizon:forget {id} --all |
torque:forget {id?} {--all} {--queue=} {--force} |
horizon:clear |
queue:clear |
horizon:supervisor |
None; one master runs the fleet. torque:supervisor generates a Supervisor config for the master |
horizon:snapshot |
None; the master publishes metrics itself |
Supervisors, maxProcesses |
workers processes, each with slots_per_worker Fiber slots |
balance / autoscaling |
Slot-pressure autoscaling, per-stream max_concurrency |
tries, backoff |
A job's own properties, then streams.<q>.max_retries and backoff |
timeout |
Job $timeout, then streams.<q>.timeout |
memory |
memory_limit |
trim / failed job retention |
dead_letter.ttl and max_entries, metrics.retention |
Tags, silenced, long-wait waits |
Tags, silenced, silenced_tags and waits |
| Environments | env() in config/torque.php and prefix |
Jobs need no change. Torque is a queue connection (QUEUE_CONNECTION=torque), so dispatching, batches and chains work as before.