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

Torque 2.x

Configuration

Every key in config/torque.php with its environment variable and default.

Publish the file with php artisan vendor:publish --tag=torque-config. Laravel merges only top-level keys over the package file: a key your published file contains keeps its value, env() fallback included, and a key it lacks takes the package default. Run php artisan config:cache again after changes if you cache config.

Defaults below are the values at release 2.4.0.

Fleet and workers

Key Env Default Description
serializer TORQUE_SERIALIZER json Envelope encoding. igbinary needs ext-igbinary. Decoding sniffs the first byte, so flipping it is safe with in-flight payloads. igbinary payloads are only decoded when the setting is igbinary
workers TORQUE_WORKERS 4 Worker processes the master forks. With autoscale.enabled this is the starting size
slots_per_worker TORQUE_SLOTS_PER_WORKER, then TORQUE_COROUTINES 50 Concurrent job slots per worker
event_loop FLEDGE_EVENT_LOOP auto auto picks poll (PHP 8.6 Io\Poll on kqueue or epoll) where available, otherwise select. poll requires kqueue or epoll. select (stream_select) is the rollback, limited to descriptors below FD_SETSIZE (usually 1024) per process. torque:start refuses any other value. A value set in the process environment wins over cached config
max_jobs_per_worker TORQUE_MAX_JOBS 10000 The worker drains and the master starts a replacement after this many jobs
max_worker_lifetime TORQUE_MAX_LIFETIME 3600 Seconds before a worker restarts gracefully
max_worker_lifetime_jitter TORQUE_MAX_LIFETIME_JITTER 0.1 Ratio of the lifetime each worker subtracts at random, so the fleet does not rotate in lockstep. 0.0 disables
drain_grace_seconds TORQUE_DRAIN_GRACE null Ceiling in seconds for in-flight jobs to finish on rotation or stop. null derives min(300, longest stream timeout or retry_after), 60 at package defaults. An idle worker exits at once. Regenerate the Supervisor config after changing it
reload_pause_seconds TORQUE_RELOAD_PAUSE 10 Seconds a reload waits for the fleet to go idle before workers are told to stop
takeover_ready_timeout_seconds TORQUE_TAKEOVER_READY_TIMEOUT 30 Seconds a takeover replacement waits for its workers' first heartbeat before aborting the reload
stall_warn_seconds TORQUE_STALL_WARN 300 The watchdog logs a WARN every 30 seconds for any slot whose job has run longer than this
loop_stall_kill_seconds TORQUE_LOOP_STALL_KILL null SIGKILL a worker whose heartbeat file is older than this. null derives max(300, longest stream retry_after); 0 is off; 1 counts as 2
memory_limit TORQUE_MEMORY_LIMIT 512 Megabytes of real memory (memory_get_usage(true)) at which a worker drains and exits with status 12. Checked once a second. 0 is off. Keep PHP's ini memory_limit above it; a worker logs a boot WARN when it is not
force TORQUE_FORCE false Keep processing during artisan down, like queue:work --force
poll_interval_ms TORQUE_POLL_INTERVAL_MS, then TORQUE_BLOCK_FOR 2000 How long an idle slot waits before polling its stream again. Not the connection's block_for
consumer_group TORQUE_CONSUMER_GROUP torque Consumer group every worker joins on each stream

Redis

Key Env Default Description
redis.uri TORQUE_REDIS_URI redis://127.0.0.1:6379 Redis or Valkey connection string
redis.prefix TORQUE_PREFIX torque: plus the slug of APP_NAME with _, plus : Prefix of every key Torque writes
redis.cluster TORQUE_CLUSTER false Redis Cluster hash tag support
redis.read_timeout_seconds TORQUE_REDIS_READ_TIMEOUT 30 Seconds a Redis read waits for a reply before the client reconnects. Also applies to the master's own reads. Zero or less waits forever

Streams

'streams' => [
env('TORQUE_QUEUE', 'default') => [
'priority' => 0,
'retry_after' => (int) env('TORQUE_RETRY_AFTER', 60),
'max_retries' => (int) env('TORQUE_MAX_RETRIES', 3),
'backoff' => env('TORQUE_BACKOFF', 'exponential'),
'timeout' => env('TORQUE_STREAM_TIMEOUT') === null ? null : (int) env('TORQUE_STREAM_TIMEOUT'),
],
],

A published config replaces the whole streams block, so the stream env variables apply only to the unpublished file. Streams with other names live as literal entries in your file.

Key Env Default Description
name of the stream TORQUE_QUEUE default The shipped stream's name
priority none 0 Processing order when several streams have work
retry_after TORQUE_RETRY_AFTER 60 Seconds a delivered job may stay unacknowledged before another worker claims it (XAUTOCLAIM). Set it longer than the longest job
max_retries TORQUE_MAX_RETRIES 3 Counts runs: 3 is three runs, 0 or 1 is one run and no retry. Applies to jobs that declare no limit of their own
backoff TORQUE_BACKOFF exponential exponential (2, 4, 8, ...), seconds, or a list or "1,5,10" per attempt, the last step repeating. Anything else logs a WARN and is exponential
timeout TORQUE_STREAM_TIMEOUT null Seconds a job without its own $timeout may run. Keep it below retry_after
max_concurrency none unset Optional. Caps how many of the stream's jobs one worker runs at once; approximate under bursts
release_limit_seconds none unset Optional. Overrides the global value; 0 opts the stream out
warn_strict_attempts none true Optional. false silences the boot WARN about max_retries of 1 or lower under strict_attempts
circuit_breaker none unset Optional. Array merged over circuit_breaker, or false to opt out

Job limits

Key Env Default Description
honour_job_limits TORQUE_HONOUR_JOB_LIMITS, then TORQUE_JOB_LIMITS (stream maps to false) true true: a job's retryUntil, $tries, maxExceptions and $backoff win over the stream. false: kill switch, only max_retries and 2**attempts count, with no strict check and no release limit; a WARN is logged at every boot
strict_attempts TORQUE_STRICT_ATTEMPTS true Check tries and retryUntil before a job runs and count redeliveries. Self-releases do not use up tries; they count against release_limit_seconds
shared_scoped_bindings TORQUE_SHARED_SCOPED_BINDINGS (comma-separated) [] Scoped bindings that are safe to share between slots, left out of the boot WARN. They are still shared
release_limit_seconds TORQUE_RELEASE_LIMIT 86400 Seconds a job may keep calling release(), from its first release. Past it the job dead-letters with reason release_limit. 0 is off; retryUntil replaces it and $tries = 0 opts out

Timeouts

Key Env Default Description
timeouts.enabled TORQUE_TIMEOUTS true Enforce $job->timeout() ?? stream timeout for jobs that declare one
timeouts.release_delay_seconds none 10 Minimum delay when a timed-out job is released
timeouts.settle_seconds none 5 Budget for interrupted() and the timeout listeners, at most half of drain_grace_seconds

Pools

Note: At 2.4.0 only pools.redis.size takes effect (the worker's internal Redis pool). The MySQL and HTTP sizes and all idle_timeout values are not read.

Key Env Default Description
pools.mysql.size TORQUE_MYSQL_POOL 20 Maximum open connections per worker
pools.mysql.idle_timeout none 60 Seconds an unused connection is kept
pools.redis.size TORQUE_REDIS_POOL 30 Maximum open connections per worker
pools.redis.idle_timeout none 60 Seconds an unused connection is kept
pools.http.size TORQUE_HTTP_POOL 15 Maximum open connections per worker
pools.http.idle_timeout none 30 Seconds an unused connection is kept

Autoscaling

Key Env Default Description
autoscale.enabled TORQUE_AUTOSCALE false Master adds and removes workers on slot pressure
autoscale.min_workers TORQUE_MIN_WORKERS 2 Lower bound; a smaller fleet is grown back to it
autoscale.max_workers TORQUE_MAX_WORKERS 8 Upper bound
autoscale.scale_up_threshold none 0.85 Slot utilisation above which a worker is added
autoscale.scale_down_threshold none 0.20 Slot utilisation below which a worker is removed
autoscale.cooldown none 30 Seconds between two scaling decisions

Delayed jobs and dead letter

Key Env Default Description
delayed.check_interval none 1 Not read at 2.4.0; the timer period is intervals.delayed_check_seconds
dead_letter.ttl none 604800 Seconds an entry is kept (XTRIM MINID)
dead_letter.max_entries TORQUE_DEAD_LETTER_MAX 100000 Hard cap enforced on every write (XADD MAXLEN ~). 0 is TTL only
dead_letter.prune_interval TORQUE_PRUNE_INTERVAL 300 Seconds between the master's housekeeping runs. 0 disables them

Long-wait alerts

Key Env Default Description
waits none [] Per-queue threshold in seconds for the oldest waiting job, for example ['emails' => 60]. Unlisted queues, 0 and absent are off
long_wait_alert_seconds TORQUE_LONG_WAIT_ALERT_SECONDS 60 Seconds one alert may take, booting the app included, shared across the event and notifications

Circuit breaker

Key Env Default Description
circuit_breaker.enabled TORQUE_CIRCUIT_BREAKER true Pause a stream whose jobs fail permanently at a high rate
circuit_breaker.window none 100 Outcomes per stream in the sliding window
circuit_breaker.min_samples none 20 Never trip below this many outcomes
circuit_breaker.threshold none 0.9 Permanent-failure ratio that opens the breaker
circuit_breaker.cooldown none 300 Seconds the stream stays paused before half-open
circuit_breaker.half_open_max none 5 Probe jobs allowed while half-open
circuit_breaker.retention none 3600 TTL on the outcome window keys

Job events, tags and silencing

Key Env Default Description
job_events.enabled none true Record per-job lifecycle events. false also skips tag inspection
job_events.ttl none 300 Seconds a job stream lives after a terminal event
job_events.max_events none 1000 Events kept per job
silenced none [] Job class names whose successful runs are left out of the dashboard records
silenced_tags none [] Tags that silence a job; encrypted jobs have none

Metrics

Key Env Default Description
metrics.enabled none true The master publishes the fleet metrics
metrics.publish_interval none 1 Seconds between publishes
metrics.retention none 86400 Seconds of per-minute history
metrics.rollups.hourly_days none 90 Days of hourly rollups
metrics.rollups.daily_days none 730 Days of daily rollups. 0 keeps them forever

The shipped file documents the storage cost: about 4300 fields cluster-wide at the defaults (roughly 430 KB), the same again per stream and per job class, and roughly 3 MB per host. Hosts share one hash per tier, but storage grows with the number of distinct hostnames seen inside the retention window; on Kubernetes the hostname is the pod name and changes on every rollout.

Dashboard

Key Env Default Description
dashboard.enabled TORQUE_DASHBOARD false Serve the dashboard
dashboard.path none torque URL path
dashboard.middleware none ['web', 'auth'] Route middleware. The viewTorque gate still applies
dashboard.poll_intervals none [0, 1000, 2000, 5000, 10000, 30000] Milliseconds offered by the refresh picker; 0 is paused
dashboard.default_poll_interval none 1000 Interval the picker opens on
dashboard.default_range none 1h Range the dashboard opens on: 1h, 24h, 7d or 90d
dashboard.gauge_max none null Ceiling of the throughput gauge in jobs per minute. null fits it to the busiest minute of the last hour

Internal intervals

intervals exists so the test suite can run real workers without waiting out real timers. Leave it alone in production.

Key Default Controls
intervals.stop_check_seconds 1.0 Stop, job and lifetime limits, memory limit, drain end
intervals.down_check_seconds 1.0 Reads artisan down
intervals.paused_poll_seconds 1.0 How soon a slot polls again after a pause or artisan down
intervals.pause_check_seconds 2.0 queue:pause, circuit breaker and Torque's own pause key
intervals.watchdog_check_seconds 2.0 Master gone, and queue:restart
intervals.delayed_check_seconds 1.0 Moves ripe delayed jobs to their stream
intervals.drain_slack_seconds 15 Added to pause plus grace by torque:stop and torque:reload (at least 1)
intervals.reload_signal_slack_seconds 5 Added to torque:reload's explicit --timeout (at least 0)

Renamed keys

These 1.x keys still work in 2.x: the value moves to the new key at boot and the master logs WARN Renamed config keys in use. Torque 3.0 makes them a boot failure. See Upgrade.

Old key New key
coroutines_per_worker slots_per_worker
block_for poll_interval_ms
redis.read_timeout redis.read_timeout_seconds
takeover_ready_timeout takeover_ready_timeout_seconds
job_streams job_events
job_limits honour_job_limits

igbinary

Install the extension, then set the serializer:

pecl install igbinary
TORQUE_SERIALIZER=igbinary

torque:start prints Serializer: igbinary on boot when active and a one-line install hint when the extension is missing. Payloads become binary, so redis-cli XRANGE output is unreadable; keep JSON while debugging. Drain the queues before switching back from igbinary to JSON: igbinary entries still queued then go to the dead-letter stream with reason serializer_mismatch.