2

I have 31GB RAM 8 Core Web Server with current load of 3k per min.

Currently worker_processes parameter in nginx config is 4 which as per my understanding means only 4 cores would be used. But when I see CPU performance I see that all 8 cores have equal load. Why?

enter image description here

Moreover, making this value 8 would help in my case?

3 Answers 3

2

Some other programs uses cpu, like php maybe? Paste all your top output, not only your cpu, but programs too. Turn on visibility of threads too... (H key, if I remember correctly.)

2
  • Let's say there are other processes which are causing this up of CPU consumption. Thus, in such a case is it advisable to add more worker processes (upto max of total number of cores)?
    – Ut xD
    Jun 30, 2014 at 8:29
  • 1
    Probably not. Only case, that you will want that some day nginx could use all of your cpu resources. Jul 3, 2014 at 8:46
1

From the documentation:

The optimal value depends on many factors including (but not limited to) the number of CPU cores, the number of hard disk drives that store data, and load pattern. When one is in doubt, setting it to the number of available CPU cores would be a good start (the value “auto” will try to autodetect it).

So, basically, setting it to the number of CPUs is a good idea. But, if you have disk latency problems, decrease the value.

1

The value of worker_processes is not equivalent to the number of CPU cores used. As the name suggests it controls only the number of individual nginx process instances that will be running. Any one of these instances will spawn a number of threads to process the incoming requests and these threads will run on all available cores even if you choose to use only a single worker process.

As for why one worker process per CPU is preferable over e.g. only a single one - I don't know. Someone with knowledge of the inner workings of how nginx uses threads would have to shed light on that.

PS. I'm wondering why your server load is so high - we're running a small 2-core server that handles up to 200 req/s with hardly any load at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .