1.全局配置
1.1 CPU内核的绑定
[root@c7-147 ~]# lscpu |grep -i cpuCPU op-mode(s): 32-bit, 64-bitCPU(s): 4 # 添加CPU核的个数On-line CPU(s) list: 0-3CPU family: 6Model name: Intel(R) Core(TM) i5-10400 CPU @ 2.90GHzCPU MHz: 2903.998NUMA node0 CPU(s): 0-3[root@c7-147 html]# ps -ef |grep nginx #开启nginxroot 2586 1 0 03:02 ? 00:00:00 nginx: master process /apps/nginx/sbin/nginxnginx 2587 2586 0 03:02 ? 00:00:00 nginx: worker processroot 3112 2242 0 05:42 pts/0 00:00:00 grep --color=auto nginx# [root@c7-147 ~]# cat /apps/nginx/conf/nginx.conf#user nobody;worker_processes 4; #4个核同时安排worker_cpu_affinity auto; #自动排序#重启nginx[root@c7-147 ~]# systemctl restart nginx#客服端发送请求[root@localhost rc.d]# while true;do curl http://10.0.0.147/index.html;sleep 0.5; done# 服务端查看是哪些CPU的核在发生变化情况[root@c7-147 ~]# watch -n1 ps -axo pid,cmd,nice,psr | grep nginx
1.2 错误日志
[root@c7-147 ~]# ulimit -n1024[root@c7-147 ~]# ulimit -n 1048576 #最多打开这么多(2*20)[root@c7-147 ~]# ulimit -n 1048577-bash: ulimit: open files: cannot modify limit: Operation not permitted[root@c7-147 ~]# cat /etc/security/limits.conf# /etc/security/limits.conf##This file sets the resource limits for the users logged in via PAM.
1.3
[root@c7-147 ~]# grep master* /apps/nginx/conf/nginx.confmaster_process off; #默认是on,关闭以后就只有一个主进程,性能很差[root@c7-147 ~]# systemctl restart nginx[root@c7-147 ~]# ps -ef |grep nginx #开启以后都只有一个主进程了root 6700 1 0 06:38 ? 00:00:00 /apps/nginx/sbin/nginxroot 6702 1334 0 06:38 pts/0 00:00:00 grep --color=auto nginx
1.4 httpd配置详解