V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
lander
V2EX  ›  问与答

nginx 进程个数问题

  •  
  •   lander · Jan 19, 2022 · 1832 views
    This topic created in 1573 days ago, the information mentioned may be changed or developed.
    如题,为啥 nginx.conf 里定义了 worker_processes=1 ,还是有 3 个 worker 进程?百思不得其解
    root@lnxaio1:/opt/openresty/nginx/conf# grep worker_processes nginx.conf
    worker_processes 1;

    root@lnxaio1:/opt/openresty/nginx/conf# ps aux |grep nginx
    root 13 0.0 0.0 233480 5972 ? S 18:10 0:00 nginx: master process /opt/openresty/nginx/sbin/nginx -c /opt/openresty/nginx/conf/nginx_background.conf -g daemon off;
    root 14 0.0 0.1 549668 8780 ? S 18:10 0:00 nginx: master process /opt/openresty/nginx/sbin/nginx -c /opt/openresty/nginx/conf/nginx.conf -g daemon off;
    root 15 0.0 0.0 141972 6296 ? S 18:10 0:00 nginx: master process /opt/openresty/nginx/sbin/nginx -c /opt/openresty/nginx/conf/nginx_console.conf -g daemon off;
    nobody 60 0.0 0.0 236412 4284 ? S 18:10 0:00 nginx: worker process
    root 63 0.0 0.0 145020 5020 ? S 18:10 0:00 nginx: worker process
    root 65 0.1 0.2 570756 23840 ? S 18:10 0:00 nginx: worker process
    root 792 0.0 0.0 14524 1008 ? S+ 18:13 0:00 grep --color=auto nginx

    提前谢过
    3 replies    2022-01-19 18:43:20 +08:00
    ysc3839
        1
    ysc3839  
       Jan 19, 2022
    有三个 master process ,每个 master process 有一个 worker process ,不是很正常吗?
    lualuer
        2
    lualuer  
       Jan 19, 2022
    ps -ef| grep nginx
    root 2232 1 0 17:54 ? 00:00:00 nginx: master process nginx
    nginx 2233 2232 0 17:54 ? 00:00:12 nginx: worker process
    root 2234 2232 0 17:54 ? 00:00:07 nginx: privileged agent process
    root 2413 2342 0 18:30 pts/3 00:00:00 grep --color=auto nginx

    这样可以看到每个 worker 进程对应的 master 进程 id (比如这个 2232 )
    lander
        3
    lander  
    OP
       Jan 19, 2022
    原来如此,多谢两位!!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2842 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 15:34 · PVG 23:34 · LAX 08:34 · JFK 11:34
    ♥ Do have faith in what you're doing.