nginx 进程个数问题

2022-01-19 18:15:25 +08:00
 lander
如题,为啥 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

提前谢过
927 次点击
所在节点    问与答
3 条回复
ysc3839
2022-01-19 18:19:51 +08:00
有三个 master process ,每个 master process 有一个 worker process ,不是很正常吗?
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
2022-01-19 18:43:20 +08:00
原来如此,多谢两位!!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/829295

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX