0

Let's say my process will run 3 workers, and I want to dedicate 1 of them to process web requests, and 2 to handle Sidekiq background jobs, each process potentially being multi-threaded. Is there an easy or best-practices way to handle this? I've tried a few different configurations, but they either give me an error, or just don't process the jobs at all.

I'm using Rails 4 and ActiveJob, but I don't think those points are relevant.

sway
  • 363
  • 1
  • 5
  • 17
  • I feel like your question is not clear. You want your app to run three processes, one of which is a puma/raptor server and two of which sidekiq workers? Have you looked at foreman? – ihaztehcodez Jan 20 '15 at 10:02

1 Answers1

0

You don't have to take care of sidekiq worker scheduling from you rails application. Sidekiq runs a separate process with the whole rails environment for managing the background workers. Each Worker is a separate Thread, backed by the Celluloid Actor framework. So for your setup you just do the following:

# start a single puma web server process with min 4 and max 16 Threads
$ bundle exec puma -t 4:16  

# start a single multithreaded sidekiq process,    
# with councurrency settings defined in sidekiq.yml
$ bundle exec sidekiq --pidfile tmp/pids/sidekiq_1.pid 

# start another sidekiq process (if really necessary)
$ bundle exec sidekiq --pidfile tmp/pids/sidekiq_2.pid  
dre-hh
  • 7,840
  • 2
  • 33
  • 44