Search code examples
ruby-on-railsmultithreadingbackground-processsidekiq

Sidekiq - Processes or threads? Whats most effective?


I have a 20 core droplet on DO. I have a rake task that creates images. The images is converted with paperclip/imagemagick. I've added paperclip_delayed which uses delayed_job and as a background worker I've added Sidekiq.

So with sidekiq I can add additional workers or set multiple threads.

What is best in terms of performance? Is it better to have a low amount of processes and add a lot of threads or vice versa? Or does it not matter as long as I dont overstep the amount of cores?


Solution

  • "Worker" is a nebulous term: use process or thread.

    With image processing, your limiting factor is likely Disk I/O unless you have some fantastic SSDs on that droplet. Threads limit you to a single core unless the image processing routines are shelling out to something like mini_magick. If that is the case, a single process with 25 threads should be sufficient.