How many Nginx processes should there be?

12,322

This is the number of your worker processes of nginx. The default configuration has 4 worker processes. They are here that the web server can handle multiple connections very fast. One of them is the master process see the output of ps fax | grep nginx:

 user@host:~# ps fax | grep nginx
 6885 ?        Ss     0:00 nginx: master process /usr/sbin/nginx
 6886 ?        S      0:00  \_ nginx: worker process
 6887 ?        S      0:00  \_ nginx: worker process
 6888 ?        S      0:00  \_ nginx: worker process
 6889 ?        S      0:00  \_ nginx: worker process

You see there is a master process and 4 child processes (workers).

Ot determine how many worker processes are configured type:

user@host:~# grep worker_processes /etc/nginx/nginx.conf
worker_processes 4;
Share:
12,322

Related videos on Youtube

Huw
Author by

Huw

Updated on September 18, 2022

Comments

  • Huw
    Huw over 1 year

    Just installing Nginx on a fresh ubuntu server 12.04.

    ps -e | grep nginx at first returned nothing so i ran nginxwhich appeared to get things started.

    Running ps -e | grep nginx now returns a number of identical processes?

     1793 ?        00:00:00 nginx
     1794 ?        00:00:00 nginx
     1795 ?        00:00:00 nginx
     1796 ?        00:00:00 nginx
     1797 ?        00:00:00 nginx
    

    Everything appears to be running, however I'm interested to know why there are multiples, what they're doing and what would happen to my server if I were to kill just one of them?

  • Huw
    Huw over 10 years
    Ah of course! I set it up with 4 workers! Duh. Thanks for the explanation!