Rails Implementation Guide

Background Jobs in Rails

Reliable async work with Active Job and Solid Queue.

Moving work out of a request is easy. The harder part is making sure it still happens when enqueueing fails, a job runs twice, or a worker stops halfway through.

PDF, EPUB, HTML, Rails reference app, and Agent Companion

Cover of Background Jobs in Rails by Rob Race

From the first enqueue to the failed job you have to recover

Follow a Rails 8.1 app as it generates reports, delivers reminders, imports large CSVs, and handles an external operation whose result can be uncertain.

  1. What Actually Belongs in a Job?
  2. The Durable Handoff
  3. Failure Is Part of the Interface
  4. Make It Safe to Run Twice
  5. Concurrency and Ordering
  6. Queues, Priorities, and Backpressure
  7. Recurring and Long-Running Work
  8. Testing and Operating Background Work

What’s included

The guide

Eight chapters covering durable handoffs, retries, idempotency, queue isolation, scheduling, checkpoints, and recovery.

Reference app

A runnable Rails 8.1 app with PostgreSQL and Solid Queue, plus tests for the failure cases behind the examples.

Agent Companion

Contracts, recipes, and review checklists for changing background jobs in an existing Rails app.

The Durable Handoff

Read the chapter on what happens between committing the application record and publishing the job.

Read the free chapter →

Also included in the Developer Library.