In a new Rails 8.1 app, which Active Job backend runs jobs in production, where does it keep them, and what starts its workers?
answer
- the Rails 8 default, no Redis
- rows in a separate queue database
- the installer edits production.rb
- bin/jobs starts the supervisor
- or Puma, when SOLID_QUEUE_IN_PUMA is set
basics
~20 sSolid Queue: rails new installs it, stores jobs as rows in a separate queue database and sets it as the production adapter. bin/jobs starts its supervisor, or Puma starts it through plugin :solid_queue when SOLID_QUEUE_IN_PUMA is set.
solid answer
~40 sA new Rails 8.1 app gets **Solid Queue**, a database-backed backend that needs no Redis. `rails new` adds the gem and runs `solid_queue:install`, which writes `config/queue.yml`, `config/recurring.yml`, `db/queue_schema.rb` and `bin/jobs`, and sets `config.active_job.queue_adapter = :solid_queue` plus `config.solid_queue.connects_to = { database: { writing: :queue } }` in `production.rb` only. Jobs are rows in `solid_queue_*` tables of that separate `queue` database, and workers claim them with `FOR UPDATE SKIP LOCKED` so two workers never take the same job. Nothing runs them until a **supervisor** starts: `bin/jobs` (or `bin/rails solid_queue:start`) as its own process, or Puma via `plugin :solid_queue`, which the generated `puma.rb` loads only when `SOLID_QUEUE_IN_PUMA` is set. Development keeps the in-process `:async` adapter unless you configure otherwise.
go deeper
Know that Solid Queue is the Rails 8 default, keeps jobs in database tables, runs only in production by default and needs bin/jobs or the Puma plugin running.
Explain what the installer writes, why connects_to points at a separate queue database, and how FOR UPDATE SKIP LOCKED lets workers share a table.
Diagnose jobs that never run, decide between bin/jobs and Puma, and keep the queue database's growth in check.
Judge when a database-backed queue is enough and when job volume or isolation justifies a separate broker.
## The default backend since Rails 8 **Solid Queue** is the Active Job backend a new Rails app uses in production. Its defining choice is storage: jobs live in ordinary **database tables**, so the deploy-it-yourself stack needs no Redis server just for background work. A newsletter platform running on one server can send its nightly digests and run its hourly clean-ups with nothing but the app and its databases. ## What `rails new` sets up `rails new` adds `gem "solid_queue"` to the Gemfile and, after bundling, runs the gem's installer (`bin/rails solid_queue:install`). That generator, not a Rails template, writes: | File | Purpose | |---|---| | `config/queue.yml` | workers and dispatchers for each environment | | `config/recurring.yml` | cron-like recurring tasks | | `db/queue_schema.rb` | the `solid_queue_*` tables | | `bin/jobs` | the binstub that starts the supervisor | It also rewrites `config/environments/production.rb`: ```ruby config.active_job.queue_adapter = :solid_queue config.solid_queue.connects_to = { database: { writing: :queue } } ``` Two consequences are worth stating in an interview: - **Only production uses it.** Development sets no adapter and falls back to Active Job's in-process `:async`; tests use `:test`. Running Solid Queue locally is an opt-in change. - **It uses its own database.** `connects_to` points Solid Queue's models at a database named `queue`, declared next to the primary one in `config/database.yml`. Keeping it separate stops app code from accidentally depending on jobs sharing the app's transactions. ## How jobs are stored and claimed 1. `perform_later` inserts a row into `solid_queue_jobs` plus a **ready** execution, or a **scheduled** execution when the job has a delay. 2. A worker polls the ready executions with `SELECT ... FOR UPDATE SKIP LOCKED`, ordered by priority and id. `SKIP LOCKED` lets several workers poll at once without blocking each other or claiming the same row. SQLite has no such clause, and writes there are sequential anyway. 3. The claimed job runs in one of the worker's threads. On success the job row is marked finished; on failure a failed execution is recorded. 4. Finished rows are kept for a day by default, and the generated `recurring.yml` clears them every hour. ## What lives in the queue database The installer's `db/queue_schema.rb` creates one table per state a job can be in, which is also how you read the system when debugging: | Table | Holds | |---|---| | `solid_queue_jobs` | one row per job, with its class, arguments and `finished_at` | | `solid_queue_ready_executions` | jobs waiting for a worker | | `solid_queue_scheduled_executions` | delayed jobs not yet due | | `solid_queue_claimed_executions` | jobs a worker is running right now | | `solid_queue_blocked_executions` | jobs held back by concurrency limits | | `solid_queue_failed_executions` | jobs that raised, with the error | | `solid_queue_processes` | live supervisors, workers and dispatchers, with heartbeats | A job moves between these execution tables as its state changes; the `solid_queue_jobs` row stays put. ## What actually runs the jobs Rows in a table do nothing on their own. A **supervisor** process reads `config/queue.yml` and starts the workers, dispatchers and scheduler. There are two standard ways to start it: - **`bin/jobs`**, a separate process (equivalent to `bin/rails solid_queue:start`). This is what a dedicated job server or container runs. - **Inside Puma**, through `plugin :solid_queue`. The generated `config/puma.rb` contains `plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]`, and the generated Kamal `deploy.yml` sets `SOLID_QUEUE_IN_PUMA: true`, so a default single-server deploy runs jobs in the web container. If neither runs, `perform_later` still succeeds and jobs simply pile up in the table, which is the classic "my jobs never run" report after a first deploy. ## Common misconceptions - **"Solid Queue needs Redis."** It does not; that is the point of it. - **"Development uses Solid Queue too."** Not unless you configure it; the installer edits `production.rb` only. - **"perform_later runs the job."** It only writes rows; a supervisor has to be running. - **"The version in Rails' own lockfile is what new apps get."** The generated Gemfile does not pin `solid_queue`, so a new app resolves the newest release (1.7 at this run), not the older version Rails' own repository locks for its tests.
- A first production deploy enqueues digest jobs that never run, with no errors; what do you check first?Whether a supervisor is running at all. Jobs are just rows until `bin/jobs` or Puma's `plugin :solid_queue` starts workers. With the generated `puma.rb`, the plugin loads only if `SOLID_QUEUE_IN_PUMA` is set, so a deploy that drops that variable, or a container that runs only the web server, leaves every job sitting in the ready table.
- How do you validate the Solid Queue configuration in CI or a deploy script without starting workers?Run `bin/jobs check` or `bin/rails solid_queue:check`. Both load the current environment's `queue.yml` and `recurring.yml`, print the errors and exit non-zero when something is wrong, such as an invalid recurring task or no processes configured, and warn when the worker threads exceed the database pool. They tolerate a missing database connection.
- Solid Queue stores its jobs in Redis like Sidekiq
- rails new switches development to Solid Queue as well
- Calling perform_later is enough to get the job executed
- Solid Queue's tables live in the primary database by default
- Workers claim jobs with plain SELECT and hope for no collisions