Solid Queue, Solid Cache and Solid Cable: the Rails 8 defaults in production
TL;DR
Difficulty: Intermediate
For a shop with a few thousand orders a month, Rails 8's database backed defaults replace Redis for jobs, cache and live updates.
- Give jobs their own Kamal role and separate fast work (emails, webhooks) from slow work (imports, exports) in different workers.
- Do the connection sum: four databases times every thread adds up, and PostgreSQL allows 97 ordinary connections by default.
- Solid Queue never retries on its own: declare retry_on, and make every retried job safe to run twice.
- Set shutdown_timeout below Kamal's stop_timeout and use Rails 8.1 continuations for long jobs.
- Queue, cache and cable tables hold personal data too, so choose their retention on purpose.
- Redis and Sidekiq still make sense at very high volume or when the database is already the bottleneck.
What to read first
Rails 8 moved jobs, the cache and live updates into the database, and for most shops Redis can go. The defaults that work on a laptop are not the ones that carry Black Friday, though. This chapter follows an invented homeware shop in Leeds as it moves from Sidekiq and Redis to Solid Queue, Solid Cache and Solid Cable, with the configuration, the capacity sums, the failure modes and the numbers it measured.
The short answer: for most shops, Redis can go
Until Rails 8, a typical Rails shop ran three things in production: the application, a PostgreSQL database and a Redis server. Redis is an in memory data store, and Rails used it for three jobs. It held the queue of background jobs (usually through Sidekiq), it held the cache, and it relayed live updates to browsers through Action Cable, the part of Rails that keeps a WebSocket open to the page.
Rails 8.0, released on 7 November 2024, moved all three jobs into the database. The Rails team called the three new libraries "a trifecta of new database backed adapters": Solid Queue for jobs, Solid Cache for the cache and Solid Cable for live updates1. They are the defaults in every new Rails 8 application. Rails 8.1, released in October 2025, added Active Job Continuations, which let a long job stop at a deploy and carry on where it left off2.
So the question in the title has a short answer. For a shop with a few thousand orders a month, you no longer need Redis, and one fewer server is one fewer thing to patch, back up, pay for and wake up to. The long answer is the rest of this chapter: how the three libraries actually behave in production, which defaults to change, what the database pays for it, how they fail, and the cases where Redis and Sidekiq are still the right call.
This chapter assumes you deploy with Kamal. If you do not yet, start with the previous chapter, deploying Rails 8 with Kamal. For the design of the jobs themselves (small, independent, safe to run twice), the earlier article on background workers in Rails goes deeper. Here I go further into operations: queues, threads, connections, retries, deploys, monitoring, data protection and migration.
Example: what Redis did at Wrenfield Home
The example in this series is Wrenfield Home, an invented online homeware shop in Leeds (wrenfieldhome.example). Priya owns it, Callum is the developer and data engineer and looks after operations part time. The shop runs Ruby on Rails and Solidus with about 1,400 products and 1,980 orders a month. It is hosted on two application servers and one managed PostgreSQL database at a European cloud provider, deployed with Kamal. It serves about 3.6 million requests a month, with a peak of 40 requests a second on Black Friday, and the database is 38 GB.
Before the Rails 8 upgrade (an invented history, for this example), Wrenfield also ran a small managed Redis instance. Callum listed everything it did:
- Sidekiq kept the job queue there: order emails, payment webhooks, stock updates, the product feed for Google and the nightly export to BigQuery.
Rails.cacheused it as the cache store for product page fragments.- Nothing else. No live updates, no sessions, no rate limits.
Every one of those three uses has a Solid replacement, so the decision was easy in principle: move jobs to Solid Queue, the cache to Solid Cache, add Solid Cable for the one live admin panel Priya wanted, and switch Redis off. The rest of this chapter is how Callum did it without losing a job, and what he measured.
Three libraries, one idea: let the database do it
The idea behind all three is in the Rails 8 announcement: "Disks have gotten fast enough that we don't need RAM for as many tasks"1. A modern SSD is fast enough that a queue table, a cache table and a message table in a database are good enough for most applications, and they come with the database's durability, backups and tools for free.
| Library | Replaces | Stores its data in | Notable default |
|---|---|---|---|
| Solid Queue | Sidekiq, Resque or Delayed Job with Redis | solid_queue_* tables | No automatic retries, finished jobs kept 1 day |
| Solid Cache | Redis or Memcached as Rails.cache | solid_cache_entries | Entries expire after 2 weeks, generated config caps size at 256 MB |
| Solid Cable | Redis as the Action Cable pub/sub | solid_cable_messages | Polls every 0.1 seconds, keeps messages 1 day |
The defaults in the table come from the gems' own documentation, at the versions current in November 2026: Solid Queue 1.7.23, Solid Cache 1.0.104 and Solid Cable 4.1.05. The 256 MB cap is in the config/cache.yml that the installer generates6.
The Rails team states that Solid Queue runs "20 million jobs per day for HEY alone" and that Solid Cache stores 10 terabytes for Basecamp with a 60 day retention window1. Those are 37signals' own figures about their own products, not independent benchmarks, but they tell you the design was not built for toy loads.
Example: where each library shows up in the shop
At Wrenfield Home, each library has one visible job for a customer or for Priya:
- Solid Queue sends the order confirmation. When an order completes, Solidus publishes an
order_finalizedevent, and its subscriber callsconfirm_email(order).deliver_laterand marks the order asconfirmation_delivered7.deliver_laterputs a job in the queue instead of talking to the mail provider during the customer's checkout request. - Solid Cache keeps the rendered HTML of product pages and category listings, so a busy page is built once and served many times.
- Solid Cable pushes each new order into the "orders today" panel in the admin that Priya keeps open on Black Friday, without her pressing reload.
How Solid Queue finds and runs a job
Solid Queue has four kinds of process, and naming them makes every later section easier[^sq]:
- Workers pick jobs that are ready and run them, in a pool of threads.
- Dispatchers move jobs that were scheduled for later into the ready list when they are due, and do some housekeeping for concurrency limits.
- The scheduler enqueues recurring tasks, the replacement for cron.
- The supervisor starts the others, watches their heartbeats and replaces any that die.
The clever part is how several workers take jobs from one table without fighting over them. Each worker runs a query like this, straight from the README[^sq]:
-- PostgreSQL: how a Solid Queue worker claims jobs from one queue
SELECT job_id
FROM solid_queue_ready_executions
WHERE queue_name = ?
ORDER BY priority ASC, job_id ASC
LIMIT ?
FOR UPDATE SKIP LOCKED;
FOR UPDATE locks the rows it selects. SKIP LOCKED tells PostgreSQL to skip any row that another worker has already locked instead of waiting for it. The PostgreSQL documentation says it plainly: skipping locked rows "can be used to avoid lock contention with multiple consumers accessing a queue like table"8. That one clause is why a database can be a decent queue. PostgreSQL has had it since version 9.5, and Solid Queue needs it for full speed3.
Example: one order confirmation, row by row
Here is the path of one confirmation email at Wrenfield Home on an ordinary Tuesday, with invented timestamps:
- 14:02:07.310. The customer's payment completes and Solidus finalises order R482113906. The subscriber calls
deliver_later. Active Job turns that into anActionMailer::MailDeliveryJoband Solid Queue inserts one row intosolid_queue_jobsand one intosolid_queue_ready_executions. The argument stored is a reference to the order record (a GlobalID, which looks likegid://wrenfield/Spree::Order/90412), not the customer's email address. - 14:02:07.390. A worker on the
mailersqueue polls (it checks every 0.2 seconds in Callum's setup, see below), claims the row withSKIP LOCKEDand moves it tosolid_queue_claimed_executions. - 14:02:07.395 to 14:02:07.980. A worker thread loads the order, renders the email and hands it to the mail provider. 585 milliseconds.
- 14:02:07.981. The claimed execution is deleted and
finished_atis set on the job row. - About a day later, the recurring task
clear_solid_queue_finished_jobs, which runs at 12 minutes past every hour, deletes the row once it is more than a day old.
The customer's checkout request finished at 14:02:07.320 and never waited for the mail provider. The email arrived about 0.7 seconds after the order. That is the whole point of a job queue, and none of it needed Redis.
The Rails 8 defaults, and what to change for a real shop
A new Rails 8.1 app with PostgreSQL gets four databases in config/database.yml for production: primary for the shop's own data, plus cache, queue and cable, each with its own migrations folder9. They are separate logical databases, but nothing stops them living on the same PostgreSQL server. On a managed database that is what you want: one server, one bill, four databases.
The generated config/deploy.yml for Kamal sets SOLID_QUEUE_IN_PUMA: true10. That runs the Solid Queue supervisor inside the web server process through a Puma plugin. The comment in the template says when to stop: "When you start using multiple servers, you should split out job processing to a dedicated machine."10 The Solid Queue README adds one more limit of the plugin: Puma's phased restarts are not supported3.
My view: inside Puma is fine for a first launch on one server. The day you have two servers, or any job that runs for minutes, give the jobs their own Kamal role. A slow feed import should never compete with a customer's checkout for the same process.
Example: Wrenfield's database.yml and deploy.yml
Callum keeps the four databases on the one managed PostgreSQL server. The connection details come from environment variables, which Kamal injects from its secrets:
# config/database.yml (production part)
production:
primary: &primary_production
adapter: postgresql
encoding: unicode
host: <%= ENV["DB_HOST"] %>
username: wrenfield
password: <%= ENV["WRENFIELD_DATABASE_PASSWORD"] %>
max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 3 } %>
database: wrenfield_production
cache:
<<: *primary_production
database: wrenfield_production_cache
migrations_paths: db/cache_migrate
queue:
<<: *primary_production
database: wrenfield_production_queue
migrations_paths: db/queue_migrate
max_connections: 6
cable:
<<: *primary_production
database: wrenfield_production_cable
migrations_paths: db/cable_migrate
max_connections is the size of each connection pool. Rails 8.1 renamed it from pool, which still works but is deprecated11. In config/deploy.yml, the web role runs on both servers and the job role on the second one only (the connection budget below explains why):
# config/deploy.yml (the parts that matter for jobs)
service: wrenfield
image: wrenfield/shop
servers:
web:
- 10.0.1.11
- 10.0.1.12
job:
hosts:
- 10.0.1.12
cmd: bin/jobs
stop_timeout: 30
env:
clear:
WEB_CONCURRENCY: 2
RAILS_MAX_THREADS: 3
secret:
- RAILS_MASTER_KEY
- WRENFIELD_DATABASE_PASSWORD
SOLID_QUEUE_IN_PUMA is gone, so Puma only serves pages. cmd: bin/jobs starts the Solid Queue supervisor in its own container, and stop_timeout is how long Kamal waits after asking the container to stop before it kills it12. That number matters later, in the section on deploys.
Queues that keep urgent work moving
A queue is a name. You choose it in the job with queue_as :mailers, and in config/queue.yml you decide which workers read which queues. The generated file has one worker that reads every queue (queues: "*") with three threads13. That is fine until two kinds of job meet: a slow one and an urgent one.
The danger is called head of line blocking. If every thread is busy with a six minute import, the confirmation email that arrives next waits, however short it is. Priorities do not help, because a running job is never interrupted to make room.
Solid Queue gives you two tools. A worker reads its list of queues in order, so with [ mailers, webhooks ] "no jobs will be taken from" the second queue while the first has jobs waiting3. And separate workers give each group of queues its own threads, so slow work cannot take the threads of fast work. The README also recommends exact queue names over wildcards like back*, and few paused queues, because those force an extra query on every poll3.
Example: Black Friday at 8am
This is an invented incident, to show the effect. Wrenfield's four supplier feeds were scheduled for 8am every day, each import taking about six minutes, plus the Google product feed refresh at the same time. With the generated config, one worker with three threads read every queue.
At 08:00:00 on Black Friday the scheduler enqueued four imports and the feed. Three threads took three imports. Every job enqueued after them waited in line behind the fourth import and the feed. Orders kept coming, about 40 an hour at that time of day, and their confirmation emails waited until a thread came free at about 08:06. The slowest email that hour took 341 seconds to leave. Customers do not know about threads. They know their confirmation did not arrive and some of them wrote to customer service.
Callum's fix was three workers, one per kind of work:
# config/queue.yml
production:
dispatchers:
- polling_interval: 1
batch_size: 500
workers:
# Fast and customer facing: emails and payment webhooks
- queues: [ mailers, webhooks ]
threads: 3
polling_interval: 0.2
# Normal work: stock updates, image variants, product feed
- queues: [ default, feeds ]
threads: 3
polling_interval: 1
# Slow work: supplier imports, nightly exports, housekeeping
- queues: [ imports, nightly, maintenance, solid_queue_recurring ]
threads: 2
polling_interval: 2
Two details are easy to miss. First, recurring tasks written as a command are enqueued in a queue called solid_queue_recurring3. If you list exact queue names, that one must be in a list, or the hourly clean up never runs. Second, Rails puts mailer jobs on the default queue unless you name one14, so Callum added config.action_mailer.deliver_later_queue_name = :mailers to config/application.rb. He also staggered the supplier imports to 6.00am, 6.20am, 6.40am and 7am.
The chart shows the slowest 5% of email waits (the 95th percentile, written p95) per hour on two Black Fridays, the year before and the year after the change. The numbers are invented for the example.
How many threads you need, and what polling costs the database
Two small formulas answer most capacity questions. The first is the most a worker can do. If a worker has threads and a job takes seconds, it can finish at most jobs a second. The second is how busy that makes it, the utilisation, written (the Greek letter rho). Both are rates, explained in Foundations: ratios and rates.
Here is the maximum throughput in jobs per second, the number of threads, the average seconds one job takes, and (lambda) the number of jobs arriving per second. A near 1 means the threads are always busy and waits grow without limit. Below about 0.5 there is room for bursts.
Polling has a cost too. An idle worker asks the database for work every polling interval, once per queue in its list, because Solid Queue can only filter by one queue at a time to keep its index fast3. A dispatcher polls on its own interval. So the idle query load is:
where is polling queries per second, the number of queues worker reads, its polling interval in seconds, and the interval of each dispatcher . Polling also adds delay: a job that arrives at a random moment waits on average half an interval before an idle worker sees it, so the expected extra wait is , an expected value in the sense of Foundations: expected value.
Example: Wrenfield's numbers on its busiest hour
The fast worker has threads and an email takes seconds:
So emails a second, or 18,000 an hour. On the busiest hour of Black Friday (invented figures) the shop takes 90 orders, which means 90 confirmations, about 40 shipping and refund emails and about 270 payment webhooks at 0.2 seconds each. The work in that hour is seconds, spread over 3,600 seconds and three threads:
A utilisation of , about 1.2%. The fast queue is idle almost all the time even on the busiest hour of the year. The Black Friday problem in the previous section was never about capacity. It was about slow jobs sharing threads with fast ones.
Now the polling cost of Callum's config. The fast worker reads two queues every 0.2 seconds, the normal worker two queues every second, the slow worker four queues every 2 seconds, and the dispatcher polls every second:
That is small indexed queries a second when everything is idle, about 1.3 million a day. It sounds like a lot and is not: each one is a small query that Solid Queue designed to be answered from an index3. The polling delay for emails is seconds on average, which nobody will notice.
Callum also measured real throughput on the staging server before Black Friday (invented numbers): 5,000 test jobs that each wait 0.6 seconds, as an email does while it talks to the mail provider, with three worker shapes. The measured rate comes in between about 7% and 10% under the theoretical one because claiming, polling and writing the finished row take time.
The connection budget nobody calculates
This is the failure I would check first on any Rails 8 shop that moved off Redis. Every Rails process keeps a pool of connections per database it talks to, and with four databases that adds up fast. PostgreSQL's max_connections is "typically 100" by default, and three of those slots are reserved for superusers, so an ordinary application user gets 9715. Managed databases often set their own limit per plan. Check yours.
The Solid Queue README adds a rule for workers: set threads to at most the queue pool size minus 2, "as each worker uses connections for polling and heartbeat"3. A rough upper bound for the whole shop is:
where is the most connections the shop can open at once, the number of Rails processes, the threads in process , the number of databases that process uses, the number of Solid Queue worker processes, and a reserve for consoles, migrations and monitoring. Connections open lazily, so a quiet shop uses far fewer. The bound is what you hit on the worst minute, which is exactly the minute you care about. The arithmetic is plain multiplication and addition, see Foundations: ratios and rates.
Example: one job host or two?
Callum first wanted the job role on both servers, for redundancy. He did the sum.
Web: two servers, two Puma processes each, three threads each. A web process talks to the primary database, the cache, the queue (every deliver_later writes there) and the cable database, so . That is .
Jobs, per host: three workers with 3, 3 and 2 threads, each using primary, cache and queue (), gives . Plus for polling and heartbeats. Plus the supervisor, the dispatcher and the scheduler at one connection each, 3. That is 33 per host.
Reserve: .
| Plan | Web | Jobs | Reserve | Total | Limit |
|---|---|---|---|---|---|
| Job role on both servers | 48 | 66 | 5 | 119 | 97 |
| Job role on one server | 48 | 33 | 5 | 86 | 97 |
With against a limit of 97, the one host plan fits with room for a deploy, when old and new containers briefly overlap. The two host plan would have failed with "too many connections" on the first busy deploy. If server two dies, jobs wait in the database, nothing is lost, and Callum moves the job role to the first server in deploy.yml and deploys. For a shop this size that is a fair trade. A bigger shop would put a connection pooler such as PgBouncer in front of PostgreSQL, which is a topic for the later chapter on PostgreSQL operations.
Retries are your job now
This is the single biggest behaviour change for anyone coming from Sidekiq. Sidekiq retries a failed job on its own, by default 25 times "over approximately 20 days" with a growing wait16. Solid Queue "doesn't include any automatic retry mechanism"3. A job that raises an error becomes a failed execution and stays there until a person retries or discards it. Retries come from Active Job, and only where you declare them with retry_on17.
retry_on takes a wait and a number of attempts, which includes the first run18. With wait: :polynomially_longer, the wait before retry number is seconds plus a random jitter of up to 15% of , so retries spread out instead of hitting a struggling service at the same moment18. Ignoring the jitter, the total time a job keeps trying is:
where is the total wait in seconds, the number of attempts and the count of executions so far. Sums like this are explained in Foundations: ratios and rates.
The other half is discard_on, for errors that will never fix themselves, such as ActiveJob::DeserializationError when the order the job refers to has been deleted18. And whatever you retry must be safe to run twice. The error handling article covers idempotency keys and timeouts in depth, and a later chapter in this series covers webhooks and integrations that must not lose or double an order.
Example: the stock sync with the warehouse
Wrenfield's third party logistics warehouse (the 3PL, the company that stores and ships the goods) has an API that is sometimes slow for an hour. Callum's job that pushes a stock reservation to it:
# app/jobs/warehouse_reservation_job.rb
class WarehouseReservationJob < ApplicationJob
queue_as :default
# The order no longer exists: nothing to reserve, never retry.
discard_on ActiveJob::DeserializationError
# The warehouse API is slow or down: back off, try for about 78 minutes.
retry_on Net::OpenTimeout, Net::ReadTimeout,
wait: :polynomially_longer, attempts: 8
def perform(shipment)
return if shipment.warehouse_reference.present? # already sent, safe to rerun
reference = WarehouseClient.new.reserve(
sku: shipment.line_items.map { |li| li.variant.sku },
idempotency_key: "shipment-#{shipment.id}"
)
shipment.update!(warehouse_reference: reference)
end
end
WarehouseClient and the warehouse_reference column are Wrenfield's own code, not part of Solidus. With the default attempts: 5, the waits would be:
That is seconds, about six minutes, or up to about 415 seconds with full jitter. Too short for an API that disappears for an hour. With attempts: 8, the seven waits are 3, 18, 83, 258, 627, 1,298 and 2,403 seconds:
So seconds, about 78 minutes. That matches the outages Callum has actually seen from this warehouse. A longer outage still ends in a failed execution, which an alert turns into a person looking at it.
Concurrency controls: one feed at a time
Some jobs must not run twice at the same time. Two copies of the product feed writing the same file, or two stock imports for the same supplier, produce a mess. Solid Queue adds limits_concurrency to Active Job[^sq]:
keysays which jobs count as "the same", for example the supplier.tois how many may run at once, 1 by default.durationis a safety net: if a job dies without releasing its lock, others may run after this time. It defaults to 3 minutes.on_conflictdecides what happens to a job that arrives while the limit is reached::block(the default) makes it wait,:discarddrops it.
The README is frank about the cost. Concurrency controls "introduce significant overhead", and for simple throttling a dedicated queue with one thread is the better tool3. It also warns that if the lock is not released, :discard throws away every conflicting job until duration has passed3. So set duration comfortably longer than the job ever takes.
Example: the Google product feed
The feed job builds the product file for Google from 1,400 products and takes about 95 seconds. Priya likes to press "refresh feed" in the admin after a price change, and the schedule also runs it every four hours. A second refresh while one is running is pointless, so it can be discarded:
# app/jobs/product_feed_job.rb
class ProductFeedJob < ApplicationJob
queue_as :feeds
limits_concurrency key: ->(channel) { "feed-#{channel}" },
to: 1,
duration: 15.minutes,
on_conflict: :discard
def perform(channel = "google")
ProductFeedWriter.new(channel: channel).write!
end
end
ProductFeedWriter is Wrenfield's own class. With duration: 15.minutes, a feed that normally takes 95 seconds has more than nine times its usual run time before the lock lapses. For the warehouse API, which allows only a few calls at a time, Callum did not use limits_concurrency at all. He used the README's advice: a warehouse queue read by one worker with a single thread.
Recurring tasks: cron without a cron server
Recurring tasks live in config/recurring.yml. Each task has either a class (a job to enqueue) or a command (Ruby code run inside a job), plus a schedule written in a readable form such as every day at 2am or a cron line3. The scheduler enqueues them at the right time. A schedule without a time zone uses the application's config.time_zone3.
Two operational details matter. If you run a scheduler on several servers, Solid Queue prevents duplicates with a unique index on the task and the run time, but only while finished jobs are kept, which they are by default3. And you can switch recurring tasks off on staging with SOLID_QUEUE_SKIP_RECURRING=true, so a staging server never sends the real nightly export3.
Example: Wrenfield's nightly jobs
# config/recurring.yml
production:
google_product_feed:
class: ProductFeedJob
args: [ "google" ]
schedule: every 4 hours
supplier_import_oakline:
class: SupplierImportJob
args: [ "oakline" ]
schedule: every day at 6am
supplier_import_harrow:
class: SupplierImportJob
args: [ "harrow" ]
schedule: every day at 6:20am
bigquery_orders_export:
class: WarehouseExportJob
queue: nightly
schedule: every day at 2:30am
expire_abandoned_carts:
class: ExpireAbandonedCartsJob
queue: maintenance
schedule: every day at 3:15am
clear_solid_queue_finished_jobs:
command: "SolidQueue::Job.clear_finished_in_batches(sleep_between_batches: 0.3)"
schedule: every hour at minute 12
The last entry comes from the installer13. The schedules are read in Wrenfield's config.time_zone, which is London. Callum kept every nightly job away from 1am to 2am local time, because in the UK the clocks go forward at 1am on the last Sunday in March and back at 2am on the last Sunday in October19. A job at 1.30am would find that hour missing in spring and doubled in autumn. Moving it out of the window costs nothing and removes a question.
Deploys, restarts and long jobs
Every deploy stops the old job container. What happens to a job that is halfway through? The answer is a chain of two timeouts, and most shops never look at either.
Kamal sends the container a stop signal and waits stop_timeout before killing it. For roles without the proxy, such as a job role, the default is the drain_timeout, which is 30 seconds20. The Solid Queue supervisor, on that signal, asks its workers to finish and waits shutdown_timeout, which defaults to 5 seconds. Workers still busy after that are told to quit, and "if workers still have jobs in flight, these will be returned to the queue"3. The job then starts again from the beginning on the new container.
For a 0.6 second email that is harmless. For a 6 minute import it means the work done so far is thrown away on every deploy, and if you deploy often during the day, a long job can be restarted again and again. Two settings fix most of it, and one Rails 8.1 feature fixes the rest:
- Set
config.solid_queue.shutdown_timeouta little below Kamal'sstop_timeout, for example 25 seconds against 30, so short jobs get the chance to finish. - Keep long jobs out of the hours you deploy, or deploy outside the hours they run.
- Use Active Job Continuations for long jobs. A job that includes
ActiveJob::Continuableis split into steps, and each step can record a cursor. When the worker is stopping, the job saves its progress and is retried, and "previously completed steps will be skipped"17. The Solid Queue adapter tells Active Job that it is stopping when a worker shuts down, which is what makes this work21.
Example: a supplier import that survives a deploy
The Oakline supplier sends a file with about 1,400 rows. Callum's import job, rewritten with a continuation:
# app/jobs/supplier_import_job.rb
class SupplierImportJob < ApplicationJob
include ActiveJob::Continuable
queue_as :imports
limits_concurrency key: ->(supplier) { "import-#{supplier}" }, duration: 30.minutes
def perform(supplier)
# Runs on every start, also when the job resumes after a deploy.
@import = SupplierImport.latest_for(supplier)
step :download do
@import.download! unless @import.downloaded?
end
step :apply_rows do |step|
@import.rows.find_each(start: step.cursor) do |row|
row.apply!
step.advance! from: row.id
end
end
step :finish do
@import.finish!
end
end
end
SupplierImport and its rows are Wrenfield's own models. A worked run, with invented timings: the import starts at 6am and applies about four rows a second. Callum deploys at 6.03am, 180 seconds in, when about 720 rows are done. Without the continuation, the job is put back in the queue and starts again from row one: 180 seconds lost, and the whole file is applied a second time, which only works because apply! is written to be safe to repeat. With the continuation, the job records its cursor at the last row id, is retried on the new container, skips the download step and carries on at row 721. The import finishes at about 6.06am instead of about 6.09am, and no row is applied twice.
Seeing what is going on
A database queue has one big advantage for monitoring: everything is a row you can count with SQL. Mission Control Jobs is the Rails team's dashboard for Solid Queue. It lets you "inspect and retry or discard failed jobs" and browse queues22. It ships with HTTP basic authentication switched on and closed, so it is unreachable until you configure credentials or your own authentication22. In a Solidus shop it belongs behind the admin login. Mission Control can also hide sensitive job arguments in its screens with filter_arguments, which works on the top level keys of hash arguments22.
# config/routes.rb
Rails.application.routes.draw do
# Only signed in Solidus admins reach the jobs dashboard.
authenticate :spree_user, ->(user) { user.has_spree_role?(:admin) } do
mount MissionControl::Jobs::Engine, at: "/admin/jobs"
end
mount Spree::Core::Engine, at: "/"
end
# config/environments/production.rb
config.mission_control.jobs.http_basic_auth_enabled = false # the admin login protects it
config.mission_control.jobs.filter_arguments = %w[email phone]
authenticate is Devise's route helper, which the Solidus authentication extension uses for the spree_user scope, and has_spree_role? comes from Solidus' user methods2324. A dashboard only helps when someone looks at it, though. Alerts need numbers, and three queries give you most of them:
-- PostgreSQL, queue database. 1) How long has the oldest ready job waited, per queue?
SELECT queue_name,
count(*) AS ready_jobs,
now() - min(created_at) AS oldest_wait
FROM solid_queue_ready_executions
GROUP BY queue_name
ORDER BY oldest_wait DESC;
-- 2) Failed jobs in the last 24 hours, by job class
SELECT j.class_name, count(*) AS failures
FROM solid_queue_failed_executions f
JOIN solid_queue_jobs j ON j.id = f.job_id
WHERE f.created_at > now() - interval '24 hours'
GROUP BY j.class_name
ORDER BY failures DESC;
-- 3) Processes whose heartbeat is late (the default heartbeat is every 60 seconds)
SELECT kind, name, hostname, last_heartbeat_at
FROM solid_queue_processes
WHERE last_heartbeat_at < now() - interval '3 minutes';
The columns come from the Solid Queue schema that the installer creates. For timing each job, Rails publishes a perform.active_job event with the job and its database time, which any metrics tool can subscribe to25. A later chapter in this series covers logs, metrics and alerts for the whole shop. Here it is enough to know which numbers to watch.
Example: Wrenfield's four alerts
| Signal | Query or source | Alert when | Why that threshold |
|---|---|---|---|
| Email queue wait | Query 1, mailers | Oldest job waits over 60 seconds | Normal wait is under 1 second |
| Slow queue wait | Query 1, imports | Oldest job waits over 30 minutes | Imports are slow but must finish before 8am |
| New failures | Query 2 | Any failure in WarehouseReservationJob or ActionMailer::MailDeliveryJob | Each is a customer order affected |
| Dead processes | Query 3 | Any row | A worker died without saying goodbye |
Callum runs the queries every minute from the monitoring tool with a read only database user. On a normal day none of them fires.
Failure modes to plan for
Moving the queue into the database changes how things break. The README is unusually honest about it, and this table collects what it says, with what to do:
| What happens | What Solid Queue does | What to do |
|---|---|---|
| The queue database is unreachable when the supervisor boots | The supervisor exits, and with the Puma plugin Puma stops too3 | Run jobs in their own role, so the shop keeps serving pages |
| A short database outage while running | Workers and dispatchers fail, are replaced and pick up where they left off3 | Nothing, but alert on it |
| A worker is killed by the operating system, for example out of memory | Its jobs are marked failed with ProcessExitError or, after the heartbeat expires, ProcessPrunedError, and are not retried automatically, because the job might be what killed the process3 | Find the job in Mission Control, fix it, retry by hand |
| A job class is renamed or removed while jobs for it are queued | The job fails with SolidQueue::Job::ClassMissingError3 | Keep the old class for one release, or drain the queue first |
| A job hangs forever but the process is alive | Nothing: heartbeats track processes, not single jobs3 | Put timeouts on every network call inside jobs |
| Failed jobs pile up | They stay until discarded | Review weekly, discard with a reason |
One more belongs on the list, and it is PostgreSQL's, not Solid Queue's. Every job inserts and deletes rows in several tables, and PostgreSQL never overwrites a row in place: a deleted row stays as a dead row version until VACUUM reclaims the space26. A queue table is the busiest table you have. Autovacuum normally keeps up, but it is worth watching n_dead_tup, the "estimated number of dead rows" in pg_stat_user_tables27.
Example: the image job that ran out of memory
An invented Tuesday: Priya uploads a 48 megapixel product photo, and the image variant job uses more memory than the job container allows. The operating system kills the worker process. The supervisor sees its child process die, marks the job as failed with ProcessExitError and starts a fresh worker3. (Had the whole container been killed, the job would have been marked failed with ProcessPrunedError once its heartbeat was more than five minutes old, the default process_alive_threshold.) The query for failures fires.
Callum opens Mission Control, sees the error and the product, and does not press retry, because the same photo would kill the next worker too. He sets a size limit on uploads in the admin, asks Priya to upload a smaller file, and discards the failed job. Total customer impact: one product without a zoom image for 40 minutes. Solid Queue deliberately does not retry these errors on its own, and retry_on cannot catch them3. A queue that retried blindly could have let the same job kill a worker again and again.
Solid Cache: a big cache on disk
Solid Cache is a cache store for Rails.cache that keeps entries in a database table. Its README makes the case that SSDs make "the access time penalty of using disk vs RAM insignificant for most caching purposes", so "you're now usually better off keeping a huge cache on disk rather than a small cache in memory"4. The Rails caching guide makes it the default store for new applications28.
How it behaves:
- It is first in, first out (FIFO). The oldest entries are removed first, not the least recently used. The guide calls this "less efficient" than least recently used, made up for by a cache that can live much longer28.
- It expires entries in the background as you write.
max_agedefaults to 2 weeks.max_sizeandmax_entrieshave no limit unless you set them, but the generatedconfig/cache.ymlsetsmax_sizeto 256 MB46. - It can encrypt entries with Active Record Encryption (
encrypt: true), and it can be sharded over several databases4. - Rails' controller rate limiting (
rate_limit) stores its counters in the cache store by default, so with Solid Cache those counters become database writes29.
Measure before you tune. Rails publishes a cache_read.active_support event for every read, with a hit flag in the payload25. The share of reads that are hits is the hit rate , and from it you get the expected time to render a cached page, an expected value as in Foundations: expected value:
where is the average render time, the hit rate between 0 and 1, the time when the fragment comes from the cache and the time when it has to be built.
# config/initializers/cache_hit_rate.rb
# Counts cache reads and hits per minute and writes one log line per minute.
CACHE_STATS = Concurrent::Map.new
ActiveSupport::Notifications.subscribe("cache_read.active_support") do |event|
minute = Time.current.beginning_of_minute.to_i
stats = CACHE_STATS.compute_if_absent(minute) do
{ reads: Concurrent::AtomicFixnum.new, hits: Concurrent::AtomicFixnum.new }
end
stats[:reads].increment
stats[:hits].increment if event.payload[:hit]
end
The block receives an ActiveSupport::Notifications::Event. Concurrent::Map and Concurrent::AtomicFixnum come from the concurrent ruby gem, which Rails already depends on, and keep the counts correct when several threads read the cache at once. A small recurring task can then write the previous minutes' totals to the log and delete them.
Example: sizing Wrenfield's cache
Callum estimated what a full set of Wrenfield's cached HTML weighs (invented sizes):
| What is cached | Count | Size each | Total |
|---|---|---|---|
| Product page fragments | 1,400 | 28 KB | 39.2 MB |
| Product cards (listing, search, recommendations) | 4,200 | 3 KB | 12.6 MB |
| Category listing pages (90 categories, 4 sorts, 5 pages) | 1,800 | 18 KB | 32.4 MB |
| Tax rates, settings, rate limit counters | about 2,000 | small | about 1 MB |
| Total | about 85 MB |
Every product change writes new entries, and FIFO keeps old ones until they age out, so the cache holds several generations. With the generated 256 MB cap, the hit rate he measured over an ordinary week was 90.0% (371,000 hits out of 412,000 reads a day). He raised max_size to 1 GB, which is 2.6% of a 38 GB database, and the hit rate rose to 94.6%. With invented render times of 35 milliseconds for a hit and 180 for a miss:
That is the old cache, with . The bigger cache, with :
So the average product page render fell from to about 42.8 milliseconds, roughly 13% faster, for about 770 MB more disk. A cache can be thrown away and rebuilt, so the cache database does not need the same backup treatment as the orders. The later chapter on backups goes into what to back up and what not.
# config/cache.yml
default: &default
store_options:
max_age: <%= 14.days.to_i %>
max_size: <%= 1.gigabyte %>
namespace: <%= Rails.env %>
production:
database: cache
<<: *default
Solid Cable: live updates without Redis
Action Cable needs a pub/sub layer: when one process broadcasts a message, every process holding a browser connection must hear it. Solid Cable does this by writing each message to a table and having listeners poll it, by default every 0.1 seconds, keeping messages for 1 day before trimming them5. Every time it writes a message it tries to trim twice as many expired ones, so the table stays near the number of messages sent within the retention window5.
PostgreSQL also has its own Action Cable adapter that uses the database's NOTIFY command, but a NOTIFY payload "must be shorter than 8000 bytes" in the default configuration30. The Solid Cable README points to that limit as one reason to prefer Solid Cable when broadcasts carry larger payloads5. A Turbo Stream broadcast that replaces a whole table of HTML can pass 8,000 bytes.
The table size follows from simple arithmetic: rows held messages per second retention in seconds. If you broadcast often, a shorter retention keeps the table small. Messages only need to live long enough for a briefly disconnected browser to catch up.
Example: Priya's orders today panel
Each order sends two broadcasts to the admin panel: a new row and updated totals. On Black Friday (invented) that is 610 orders times 2, so 1,220 messages, plus 2,400 low stock badges, 3,620 in the day. With the default 1 day retention the table holds at most about 3,620 rows, which is nothing for PostgreSQL.
So why change it? Because the new row in Priya's panel contains the customer's name and the order total. Performance does not need a day of history, and data protection argues against it. Callum set it to one hour:
# config/cable.yml
production:
adapter: solid_cable
connects_to:
database:
writing: cable
polling_interval: 0.1.seconds
message_retention: 1.hour
On the busiest hour, about 400 messages, the table now holds about 400 rows, and no customer name sits there for longer than an hour.
Personal data in the queue, the cache and the cable tables
With Redis, data in the queue and the cache felt temporary. In the database it is just more rows, and some of them contain personal data. The law does not care which store holds it. Under the UK GDPR, personal data must be "kept in a form which permits identification of data subjects for no longer than is necessary"31. The Information Commission (formerly the Information Commissioner's Office, ICO) puts it plainly: "You must not keep personal data for longer than you need it", and you need a retention policy and periodic review32. This is general information, not legal advice.
| Store | Where personal data can sit | Default retention |
|---|---|---|
| Solid Queue | Job arguments in solid_queue_jobs, error messages in solid_queue_failed_executions | Finished jobs 1 day, failed jobs until someone discards them3 |
| Solid Cache | Cached HTML of account and order pages | Up to max_age, 2 weeks by default4 |
| Solid Cable | Broadcast HTML in solid_cable_messages | 1 day by default5 |
| Backups of all of the above | Copies of every row | As long as the backups live |
The biggest risk is the failed jobs, because nothing removes them. A job that failed in March with the customer's email address in its arguments is still there in November unless someone acts.
Example: two ways to write the same job
Callum found an old job written before he joined:
# Before: personal data in the job arguments
NewsletterSyncJob.perform_later(customer.email, customer.bill_address.name, customer.bill_address.zipcode)
# After: only a reference, the job loads what it needs when it runs
NewsletterSyncJob.perform_later(customer)
In the first version the email, the name and the postcode sit in solid_queue_jobs for a day after success and forever after a failure. In the second, the stored argument is a GlobalID like gid://wrenfield/Spree::User/88214, and if the customer has been deleted by the time the job runs, discard_on ActiveJob::DeserializationError drops the job cleanly. He also added a weekly review of failed jobs to his routine, set filter_arguments in Mission Control for the jobs that must still carry an email, and wrote the four retention periods from the table into Wrenfield's record of processing.
When Redis or Sidekiq still make sense
I would not move every application off Redis. These are the cases where I would keep it, or add it later:
- Very high job volume or very short jobs at scale. Sidekiq's own benchmark drains 500,000 empty jobs at about 23,500 jobs a second on Sidekiq 7.0.3 with a concurrency of 30, and at about 14,700 a second through Active Job33. That is the vendor's measurement of an empty job, not your workload, but it shows the headroom of an in memory queue. If your queue is tens of millions of jobs a day and the database is already your busiest component, Redis takes that load off it.
- A database that is already the bottleneck. Solid Queue, Solid Cache and Solid Cable all add writes to PostgreSQL. If the shop's own queries already compete for the database, moving these somewhere else costs less than a bigger database.
- Features you already rely on. Sidekiq Pro and Enterprise are commercial editions with extra features and a commercial licence33. If a working system depends on them, a migration has to earn its keep.
- Real time features with many connections, such as live stock for thousands of simultaneous visitors, where 0.1 second polling per listener adds up.
- Redis used for something else anyway, for example a shared rate limit across many services.
Know the licence situation too. Redis 7.2 and earlier are under the BSD licence, versions 7.4 to 7.8 under a dual source available licence, and from Redis 8 users can choose between three licences, one of them the open source AGPLv334. Valkey is an open source (BSD) fork backed by the Linux Foundation35, and Sidekiq supports Redis 7.0+, Valkey 7.2+ and Dragonfly33.
Example: when Wrenfield would revisit the decision
Callum wrote three numbers into the operations notes, so the decision is not made on feeling:
- Jobs per day. About 750 on a normal day and 3,900 on Black Friday (from the job table, invented). He revisits above 500,000 a day, more than 100 times today's peak.
- Database CPU at peak. 31% on Black Friday (invented). He revisits if the Solid tables account for more than a third of it.
- Queue wait for emails. Under one second at p95. He revisits if it rises above 10 seconds while utilisation stays low, which would point to the database, not the threads.
None is close. The shop has room to grow many times over before Redis comes back into the conversation.
Moving from Sidekiq to Solid Queue without losing a job
The safest migration is gradual, and Solid Queue supports it: leave the application's queue adapter on Sidekiq and set self.queue_adapter = :solid_queue in each job as you move it3. The risks are not in the moving but in the differences:
- Retries. Every job that quietly relied on Sidekiq's 25 retries needs an explicit
retry_onor it will fail on the first error. - Sidekiq specific options.
sidekiq_optionsand Sidekiq's own job classes do not move over. Jobs need to be Active Job jobs. - Scheduled jobs. Jobs already scheduled for the future in Redis stay there. Keep Sidekiq running until its scheduled set is empty.
- Cron. Schedules from a Sidekiq cron extension become entries in
recurring.yml.
Example: Callum's four week plan
Week one: install Solid Queue, create the queue database with db:prepare, add the job role in Kamal, write queue.yml and recurring.yml, add retry_on and discard_on to every job, and move the low risk jobs (image variants, sitemap) with self.queue_adapter = :solid_queue. Sidekiq still runs everything else.
Week two: move the feed and the imports, the ones that benefit most from separate workers and concurrency limits. Watch the alerts.
Week three: switch the application default with config.active_job.queue_adapter = :solid_queue, which moves emails and webhooks. Stop Sidekiq's scheduled jobs from being created, but keep Sidekiq processing until its scheduled set and retry set are empty. At Wrenfield that took nine days, because of a few delayed emails.
Week four: switch the cache store to Solid Cache in a quiet hour (the cache starts cold, so the first hour is slower), remove Sidekiq, keep the Redis instance for one more week as a fallback, then delete it.
Testing the jobs and the configuration
Jobs are code and deserve tests like the rest. Rails' test adapter does not run jobs until you call perform_enqueued_jobs, and it clears jobs before each test36. The testing guide recommends perform_later inside perform_enqueued_jobs instead of perform_now, "so that if retries are configured, retry failures are caught by the test"36.
# test/jobs/warehouse_reservation_job_test.rb
require "test_helper"
class WarehouseReservationJobTest < ActiveJob::TestCase
test "stores the warehouse reference and is safe to run twice" do
shipment = spree_shipments(:ready_to_ship)
WarehouseClient.any_instance.expects(:reserve).once.returns("WH-RES-1042")
perform_enqueued_jobs do
WarehouseReservationJob.perform_later(shipment)
WarehouseReservationJob.perform_later(shipment)
end
assert_equal "WH-RES-1042", shipment.reload.warehouse_reference
end
test "retries on a timeout instead of failing" do
shipment = spree_shipments(:ready_to_ship)
WarehouseClient.any_instance.stubs(:reserve).raises(Net::ReadTimeout)
assert_enqueued_with(job: WarehouseReservationJob) do
WarehouseReservationJob.perform_now(shipment)
end
end
test "an order emails its confirmation through the mailers queue" do
order = spree_orders(:completed_today)
assert_enqueued_with(job: ActionMailer::MailDeliveryJob, queue: "mailers") do
Spree::Config.order_mailer_class.confirm_email(order).deliver_later
end
end
end
The fixtures and the mocking library (Mocha's expects and stubs here) are Wrenfield's choices. The configuration needs a test too. bin/jobs check validates queue.yml and recurring.yml without starting any process and exits with an error if, say, a schedule has a typo. It works without a database connection, so it runs in CI3. I work test first and put every release through a test gate and a release register, and this check is the kind of line that belongs in such a gate: one command, and a misspelt every day at 2:30am never reaches production. The TDD and BDD guide for Rails covers the testing habit itself.
Conclusion
For an independent shop on Rails and Solidus, the Rails 8 defaults are good enough to run Black Friday, and Redis can go. What is not good enough is the generated configuration left untouched. The chapter in five lines:
- Give jobs their own Kamal role once you have two servers, and separate fast and slow work into different workers.
- Do the connection sum before you deploy, not after the first "too many connections".
- Declare retries with
retry_on, because nothing retries for you, and make every retried job safe to run twice. - Set
shutdown_timeoutbelow Kamal'sstop_timeout, and use continuations for long jobs. - Treat the queue, cache and cable tables as places where personal data lives, with retention you chose on purpose.
My view: the Solid libraries are the right default for almost every shop I would build today. They remove a whole server from the setup, they put jobs in the same database you already back up and query, and their failure modes are documented honestly. Redis earns its place back only when your own numbers say the database cannot carry the load, and for most shops those numbers are years away.
