nginxpassengerworker-process

NGINX Worker Processes role when using Passenger


I am currently working on a project in which we are using NGINX along with Phusion Passenger. I have done some research on how to best optimize with different configurations, but I still do not understand how increasing the number of NGINX Worker Processes fits in to the scenario. It seems that the real factor in optimizing for a larger load is increasing the number of passenger processes.

Could anyone shed some light on what the difference between having 1 NGINX worker process with 50 phusion passenger processes vs 2 NGINX worker processes with 50 phusion passnger processes ?


Solution

  • I'll give it a try.. there's quite a difference between nginx workers and passenger workers. You definitely not want to have more nginx workers than cores because this would just cause idle processes flying around. So if you have a cpu with maybe 4 cores, give nginx 4 workers. simple as that.

    Now when it comes to passenger workers, the whole thing gets a bit more complicated. You have to think about whether your app is consuming a lot of cpu time (e.g. calculations) or doing a lot of I/O (e.g. database operations, file stuff, you name it) and configure passenger appropriately.

    Calculation: limit the worker processes and threads to either the number of cores or a multiple thereof - maybe 2 or 3 times the number of cores you have. I/O: give it as many processes as cores but as many threads as possible.

    There are some very well written blog posts about tuning nginx and/or passenger with formulas and config info:

    http://www.alfajango.com/blog/performance-tuning-for-phusion-passenger-an-introduction/ http://blog.phusion.nl/2013/03/12/tuning-phusion-passengers-concurrency-settings/