Search code examples
ruby-on-railsrubysidekiq

Multiple sidekiq daemons on one machine


I have a two rails apps hosted on the same VPS. I'm using a sidekiq for background processing. I'm running two separate sidekiq daemons for each application and the problem is that sometimes (not sure when), jobs from one application are handled by the sidekiq daemon of a second app, which produces some undesired behavior and exceptions.

Can multiple sidekiq instances be run on the same machine (without any glitches)? If so, can you point me to any resource, which would explain how to make do it in properly? I couldn't find anything related.


Solution

  • You can use sidekiq namespace to fix this problem. From sidekiq's wiki

    NOTE: The :namespace parameter is optional, but recommended if Sidekiq is sharing access to a Redis database.
    

    One more thing you can do is to have a separate queue for workers.

    :queues:
      - [default, 1]
      - [new_comments, 1]
      - [email_alerts, 1]
      - [new_messages, 1]