Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/_posts/languages/ruby/2000-01-01-delayed-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ tags: ruby gem async jobs delayed
## What is `delayed_job`?

Delayed_job lets you run background tasks with your Rails application. It uses
your database as a queue to process background jobs. If your app has a high
database load, using delayed_job may not be a good background queuing library
for your project and you should have a look at
[Sidekiq](https://github.com/mperham/sidekiq) or
[Resque](https://github.com/resque/resque).
your database as a queue to process background jobs. Since Rails 8, [Solid Queue]({% post_url languages/ruby/2000-01-01-solid-queue %}) is the default background job processor for Rails applications.

If your app has a high database load, using a database-backed background job library may not be a good choice for your project and you should have a look at [Sidekiq]({% post_url languages/ruby/2000-01-01-sidekiq %}) or [Resque](https://github.com/resque/resque).

## Adding `delayed_job` to your Project

Expand Down
3 changes: 3 additions & 0 deletions src/_posts/languages/ruby/2000-01-01-sidekiq.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ tags: ruby gem async jobs sidekiq

Sidekiq lets you run background tasks with your Rails application. It uses a Redis® OSS instance, as a queue to process background jobs.

Since Rails 8, [Solid Queue]({% post_url languages/ruby/2000-01-01-solid-queue %}) is the default background job processor for Rails applications.
It uses your database to store jobs, so you don't need Redis® OSS for basic background job processing.

## Requirements

Your application should have access to a Redis® OSS instance, like the one provided by the [Scalingo for Caching Addon]({% post_url databases/redis/2000-01-01-start %}).
Expand Down
59 changes: 59 additions & 0 deletions src/_posts/languages/ruby/2000-01-01-solid-queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Using Solid Queue to Handle Background Tasks
nav: Solid Queue
modified_at: 2025-12-30 00:00:00
tags: ruby rails async jobs solid-queue
---

## What is Solid Queue?

[Solid Queue](https://github.com/rails/solid_queue) is the default background job processing library for Rails 8. It uses your database (PostgreSQL®, MySQL®, or SQLite) to manage the job queue, eliminating the need for a separate Redis® OSS instance for many use cases.

## Configuration for Rails 8

When using Solid Queue on Scalingo, you need to ensure that your database configuration in `config/database.yml` correctly references the `DATABASE_URL` environment variable for both the primary database and the queue database.

By default, Rails 8 might expect a separate database for the queue, but on Scalingo, you typically use the same database for both.

Update your `config/database.yml`:

```yaml
production:
primary: &default
adapter: postgresql # or mysql2 (the adapter name for MySQL)
encoding: unicode
url: <%= ENV['DATABASE_URL'] %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

queue:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
```

## Adding "worker" container type in your Procfile

To process background jobs, you need to run the Solid Queue worker process. Add the following line to your [`Procfile`]({% post_url platform/app/2000-01-01-procfile %}):

```yaml
worker: bundle exec rake solid_queue:start
```

## Deployment

After updating your `config/database.yml` and `Procfile`, deploy your application:

```bash
git add config/database.yml Procfile
git commit -m "Configure Solid Queue for Scalingo"
git push scalingo master
```

{% note %}
Solid Queue requires a migration to create the necessary tables in your database. These migrations are typically added when you install Solid Queue or when you create a new Rails 8 application. Make sure they are executed using a [post-deployment hook]({% post_url platform/app/2000-01-01-postdeploy-hook %}).
{% endnote %}

Once deployed, you need to scale the `worker` container to at least 1 to start processing jobs:

```bash
scalingo --app my-app scale worker:1
```
2 changes: 1 addition & 1 deletion src/_posts/languages/ruby/rails/2000-01-01-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ application logs in the dashboard or with Scalingo's command line interface.

### Rails 5 and Later

You've nothing to do, everything is handled by the platform
You've nothing to do, everything is handled by the platform.

### Rails 4 and Before

Expand Down
2 changes: 1 addition & 1 deletion src/_posts/platform/app/2000-01-01-long-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Asynchronously, a worker should handle the processing of the resource created in

There is various message queue system depending on the programming language and the framework your application uses:

- Ruby: [Delayed Job]({% post_url languages/ruby/2000-01-01-delayed-job %}), [Sidekiq](https://github.com/mperham/sidekiq) or [Resque](https://github.com/resque/resque).
- Ruby: [Solid Queue]({% post_url languages/ruby/2000-01-01-solid-queue %}), [Delayed Job]({% post_url languages/ruby/2000-01-01-delayed-job %}), [Sidekiq]({% post_url languages/ruby/2000-01-01-sidekiq %}) or [Resque](https://github.com/resque/resque).
- PHP: [Symfony Messenger]({% post_url languages/php/2000-01-01-symfony %}#symfony-messenger) or [Laravel Tasks Scheduler]({% post_url languages/php/2000-01-01-laravel %})
- Node.js: [Bull](https://github.com/OptimalBits/bull).
- Python: [Celery]({% post_url languages/python/2000-01-01-celery-flask %}).
7 changes: 7 additions & 0 deletions src/_posts/platform/app/2000-01-01-procfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ Notice the use of the environment variables:
```yaml
web: bundle exec rails server -p $PORT -e $RAILS_ENV -b 0.0.0.0
worker: bundle exec sidekiq -e $RAILS_ENV
```

Here is an example using [Solid Queue]({% post_url languages/ruby/2000-01-01-solid-queue %}):

```yaml
web: bundle exec rails server -p $PORT -e $RAILS_ENV -b 0.0.0.0
worker: bundle exec rake solid_queue:start
```

#### Defining a Complex Process Type
Expand Down