Leahcim
Leahcim

Reputation: 41919

How to determine the number of worker processes

I'm following along with a tutorial for setting up nginx on ubuntu. I have nginx installed and it started successfully. The tutorial says this about adjusting and setting nginx processes and worker connections

It is often recommended to set the number of NGINX workers equal the number of processors, you can determine the number of processors using:

cat /proc/cpuinfo | grep processor 

When I run the command, I got a 0.

processor   : 0

Therefore, according to the tutorial, I should set the config to 0 in the appropriate location

sudo nano /etc/nginx/nginx.conf


worker_processes 0;

The tutorial's example has a 1. However, I was a little concerned not only about seeing a 0 when I ran the output, but also when I ran ps -ef | grep nginx, I got this output, suggesting there are multiple workprocesses?

root      1824     1  0 19:40 ?        00:00:00 nginx: master process /usr/sbinnginx
www-data  1825  1824  0 19:40 ?        00:00:00 nginx: worker process
www-data  1826  1824  0 19:40 ?        00:00:00 nginx: worker process
www-data  1827  1824  0 19:40 ?        00:00:00 nginx: worker process
www-data  1828  1824  0 19:40 ?        00:00:00 nginx: worker process
michael   1832  1378  0 19:44 pts/1    00:00:00 grep --color=auto nginx

Is it a matter for concern that I see a 0 when I run cat /proc/cpuinfo | grep processor and what should I set worker_processes 0; to in /etc/nginx/nginx.conf?

Upvotes: 0

Views: 5743

Answers (1)

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42799

Well the counting starts from 0, so only getting a processor : 0 means you only have 1 processor/core.

I am not sure but I'm assuming worker_processes 0; means unlimited, so I think you should change it to worker_processes 1, if you want it to be corresponding to the number of processors you have;

Upvotes: 1

Related Questions