Sidekiq 7 adds a new feature called capsules Show archive.org snapshot .
Use cases:
- a chromequeue limited to1for e.g. PDF processing to not overload the application server
- an apiqueue, that limits a queue to2to protect the API server from too many requests in parallel
Example:
Sidekiq.configure_server do |config|
  # Edits the default capsule
  config.queues = %w[critical default low]
  config.concurrency = 5
  # Define a new capsule which processes jobs from the `unsafe` queue one at a time
  config.capsule("unsafe") do |cap|
    cap.concurrency = 1
    cap.queues = %w[unsafe]
  end
end
Some notes:
- To know the total threads per sidekiq server your need to sum up the concurrencies. In the example above this would be 6 threads in total. Instead of config.concurrency = 5you also might have this config in asidekiq.ymlfile saying:concurrency: 5.
- In case you run multiple sidekiq servers (processes), the total number of concurrent capsules differs. In the example above with e.g. two application servers with a sidekiq role the maximum number of jobs in the unsafequeue is 2. And the total number of threads 12.
Posted by Emanuel to makandra dev (2023-05-22 10:06)