Search code examples
ruby-on-railsnginxunicornmulticoreworker

Rails or sinatra dedicate cores for applications


I have a bunch of rails and sinatra applications running behind nginx and unicorn. I want each unicorn for each application uses 2 workers per core. I want to deploy these in a machine in a cluster which has 64 cores, but I want all of these applications use only 24 cores. How can I limit or configure how many cores will be used, when running the unicorn applications?

> lscpu | grep -E '^Thread|^Core|^Socket|^CPU\('
CPU(s):                64
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             4

Solution

  • I found it. There is something called taskset, you can easily dedicate cores for your applications. e.g "taskset -c 0-12 rails start" will dedicate first 13 cores to your application.