skip to content

Solid Queue Workers

Solid Queue, the Rails 8 default backend, keeps jobs in a database and claims them with FOR UPDATE SKIP LOCKED, run by bin/jobs or the Puma plugin. Interviewers probe its workers and limits.

part ofRuby on Railsread it →
on this pageshow

explore

questions

6

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?

level: juniorimportance: must knowfreq 55%

answer

  1. the Rails 8 default, no Redis
  2. rows in a separate queue database
  3. the installer edits production.rb
  4. bin/jobs starts the supervisor
  5. or Puma, when SOLID_QUEUE_IN_PUMA is set

basics

~20 s

Solid 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 s

A 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

for a junior

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.

for a middle

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.

for a senior

Diagnose jobs that never run, decide between bin/jobs and Puma, and keep the queue database's growth in check.

for a principal

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
open as a page

With Solid Queue, what do the workers and dispatchers entries in config/queue.yml do, and what do threads, processes and polling_interval control?

level: middleimportance: must knowfreq 48%

basics

~20 s

In Solid Queue, workers poll their queues for ready jobs and run them in a thread pool; dispatchers move due scheduled jobs to ready and maintain concurrency limits. threads sizes each pool, processes forks worker copies, polling_interval spaces the polls.

open as a page

With Solid Queue, how do you declare a nightly job in config/recurring.yml, and which process enqueues it when it is due?

level: middleimportance: should knowfreq 40%

basics

~20 s

Add a task under the environment key with class: (or command:), optional args:, queue: and priority:, and a schedule: such as every day at 6am. Solid Queue's scheduler process, started by the supervisor, enqueues the job each time it falls due.

open as a page

With Solid Queue, how does limits_concurrency on a job class work, and what do its key:, to:, duration: and on_conflict: options do?

level: seniorimportance: should knowfreq 30%

basics

~20 s

limits_concurrency lets Solid Queue run at most to: jobs with the same computed key at once; extras are blocked until one finishes, or dropped with on_conflict: :discard. duration: (3 minutes by default) is a failsafe for semaphores nobody released.

open as a page

In a Rails 8.1 app, what does plugin :solid_queue in config/puma.rb do when SOLID_QUEUE_IN_PUMA is set, and when should jobs move to a separate bin/jobs process?

level: seniorimportance: should knowfreq 35%

basics

~20 s

With SOLID_QUEUE_IN_PUMA set, Puma loads the plugin, which forks the Solid Queue supervisor after boot and stops it with Puma, so one container serves web and jobs. Move jobs to bin/jobs once you add servers or jobs compete with requests.

open as a page

In a Rails 8.1 app on Solid Queue, how do you add the Mission Control Jobs dashboard, and how is it protected by default?

level: middleimportance: nice to knowfreq 25%

basics

~20 s

Add the mission_control-jobs gem and mount MissionControl::Jobs::Engine in config/routes.rb. It ships with HTTP basic authentication enabled and closed: until credentials are configured every request gets 401, and base_controller_class lets it use your app's own login instead.

open as a page