Deploy with Redis polling
Store runs in Redis or Valkey and let workers claim work directly.
Choose this lane when you already operate Redis or Valkey and want workers to poll it directly. Use Postgres polling when Postgres is your preferred system of record. Both lanes support the same task APIs.
Deployment shape
producer -- writes runs ----------> Redis / Valkey
worker -- polls and claims -----> Redis / Valkey
Redis -- best-effort signal ---> worker
maintenance -- advances due work ----> Redis / ValkeyRedis stores runs, leases, waits, history, and queue capacity. A worker claims work through an atomic storage commit. Pub/sub hints wake idle workers sooner; ordinary polling covers a lost hint.
Prepare Redis
Use a standalone primary, Sentinel, or Cluster. A namespace lives on one primary, including in Cluster. More workers share that primary's memory and execution capacity. Use separate namespaces and lanes to spread independent workloads across primaries.
Use noeviction; an observed allkeys-* policy fails startup. Give the runtime permission to run the storage scripts and commands. Review startup checks, the durability boundary, and deployment requirements before choosing an endpoint.
Choose an explicit namespace, such as billing-jobs. Producers, workers, and maintenance must use the same namespace, environment, and queue definitions. A new namespace must be empty. Startup creates a format marker after its admission checks pass. There is no Redis migration CLI; an incompatible marker fails startup.
Install the packages
npm install @runlane/core @runlane/lane-redis-polling zodUse Node.js 22.18 or later. Set REDIS_URL to a primary endpoint before loading the runtime module. For TLS, use a rediss:// URL. See connection options for Sentinel, Cluster, and client ownership.
Put task code in its own module
import { task } from '@runlane/core'
import * as z from 'zod'
export const countItems = task({
id: 'items.count',
schema: z.object({ items: z.array(z.string()) }),
output: z.number(),
run: ({ items }) => items.length,
})Create one runtime module
import { createRunlane, RunRetention, queue } from '@runlane/core'
import { redisPollingLane } from '@runlane/lane-redis-polling'
import * as z from 'zod'
import { countItems } from './tasks/count-items.js'
const { REDIS_URL } = z.object({ REDIS_URL: z.url() }).parse(process.env)
export const jobs = queue({ name: 'jobs', default: true })
export const runlane = createRunlane({
retention: {
succeeded: RunRetention.deleteAfter('7d'),
cancelled: RunRetention.deleteAfter('7d'),
failed: RunRetention.deleteAfter('30d'),
expired: RunRetention.deleteAfter('7d'),
},
lane: redisPollingLane({ url: REDIS_URL, namespace: 'billing-jobs' }),
queues: [jobs],
tasks: { countItems },
})All three process roles import this module. redisPollingLane() takes flat storage options, plus name, runHints, and emptyPollDelay. See polling lane options.
Start a worker
Use this as the worker service's entry point. It starts maintenance and closes the runtime cooperatively on SIGTERM or SIGINT or worker failure.
import { runlane } from './runlane.js'
const worker = await runlane.createDeliveryWorker({ concurrency: 8, handleSignals: true })
try {
await worker.waitUntilClosed()
} finally {
await runlane.close()
}Set the supervisor's termination window above shutdownGrace, leaving time to save results. Restart the process when the worker fails. See worker shutdown.
How idle workers wake
With workHints enabled, a long-running polling worker opens a dedicated pub/sub listener. That listener is shared with run-progress hints on the same storage driver. Producers and maintenance do not open it just to start. Scheduled drains do not open a work listener.
Hint failures are reported through storage background failures and project telemetry. They cannot fail a committed write. Listener readiness wakes existing waits so workers read storage again. A later wait can reopen a lost listener. If hints are unavailable, workers keep polling.
emptyPollDelay controls the first wait after an empty scan. Further idle waits use the shared polling backoff. Hints only lower latency; polling guarantees progress while storage and worker capacity are available. Delays, retries, schedules, and lease expiry always depend on polling and maintenance.
workHints defaults to contractDefaults.delivery.workHints (true). Set workHints: false in redisPollingLane() when workers cannot keep a pub/sub connection. This stops work publications and opens no work subscription. Commits in the same runtime still wake idle workers immediately; other runtimes' work waits for polling. Run-progress subscriptions remain separate: disable runHints too when no pub/sub connection is available.
runHints defaults to contractDefaults.realtime.runHints. Set it to false for scheduled functions and other serverless producers or readers. It controls run-progress hints, independently of the polling worker's work hints. Readers retain their polling fallback.
Run workers on a schedule
For a timer-driven function, set runHints: false in the lane and export:
import { runlane } from './runlane.js'
export const handler = runlane.createDeliveryHandler({ maxDuration: '50s', concurrency: 8 })An invocation starts the runtime, runs a maintenance pass, and drains due work. Leave room below the host timeout for cleanup and result writes. Keep the runtime outside the handler so warm invocations reuse it. See scheduled polling workers for the shared budget and cancellation rules.
Run maintenance
The worker above runs maintenance. If another service owns it, set maintenance: false on createDeliveryWorker() in the worker and run start({ maintenance: true }) in that service. A scheduled deployment can export runlane.createMaintenanceHandler() instead.
Maintenance advances schedules, retries, waits, cancellations, and recovery. Keep an owner running for every declared schedule. See run maintenance.
Check the deployment
In an isolated namespace:
- Start the worker and confirm startup checks pass.
- Trigger
runlane.trigger(countItems, { items: ['one', 'two'] })from a producer importing the same runtime and task. - Confirm the run succeeds with output
2through the run API or CLI. - Exercise a token-backed wait and confirm maintenance resumes it.
- Stop a worker during an attempt and confirm another worker recovers it after lease expiry.
If a run stays queued, check the namespace, environment, queue filter, task catalog, and maintenance owner. Follow change tasks safely before deploying incompatible handlers, and make external effects safe to repeat.