V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
lander
V2EX  ›  问与答

nginx 进程个数问题

  •  
  •   lander · 2022-01-19 18:15:25 +08:00 · 895 次点击
    这是一个创建于 800 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如题,为啥 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 条回复    2022-01-19 18:43:20 +08:00
    ysc3839
        1
    ysc3839  
       2022-01-19 18:19:51 +08:00
    有三个 master process ,每个 master process 有一个 worker process ,不是很正常吗?
    lualuer
        2
    lualuer  
       2022-01-19 18:36:09 +08:00
    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
       2022-01-19 18:43:20 +08:00
    原来如此,多谢两位!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2777 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:50 · PVG 20:50 · LAX 05:50 · JFK 08:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.