Provision a Redis server
Sidekiq depends on Redis to communicate between the Rails server process and the background workers. Follow the Redis setup guide to provision a Redis server and set aREDIS_URL within the Rails app. Be sure to set the REDIS_URL via a secret as demonstrated here.
Verify the REDIS_URL is available to your Rails application before you continue by running:
REDIS_URL in the command above, Sidekiq won’t be able to connect and process background jobs.
Run multiple processes
Most production Rails applications run background workers in a separate process. There’s a few ways of accomplishing that on Fly that are outlined in the multiple-processes docs. The quickest way to run multiple processes in one region is via theprocesses directive in the fly.toml file.
The
[processes] directive currently only works within a single Fly region. Scaling a Rails application to multiple regions requires a different approach to running multiple processes.fly.toml:
[http_service] directive, add processes = ["app"]. The configuration file should look something like this:
Deploy and test
Once multiple processes are configured in thefly.toml file, deploy them via:
app and worker processes. Be sure to run through the application and test features that kick-off background jobs. If you’re having issues getting it working, run fly logs to see errors.
Scaling
Scaling up and down processes may be accomplished by running:ord region.