For long running asynchronous jobs, we use Sidekiq
For any long running work such as external API integrations, heavy lifting is delegated to background jobs. This allows us to respond to requests quickly and also to handle large number of requests concurrently.
- Create a new job class in
app/jobs/
- Use ActiveJob's
perform_later
to enqueue the job
MyJob.perform_later(arg1, arg2)
Sidekiq provides a web interface for monitoring and managing jobs.
# Start the Sidekiq server
bundle exec sidekiq
# Access the web interface
http://localhost:3000/sidekiq
Redis is used as message broker / queue to store the jobs and their status.
Check Sidekiq initializer for more details.