nginx进程数和worker_cpu_affinity参数设置,nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数。
配置1:4核心+4个进程 (每个worker_processes 使用1个CPU)
//查看CPU核心数
[reistlin@reistlin.com ~]$ cat /proc/cpuinfo | grep processor processor : 0 processor : 1 processor : 2 processor : 3
//配置nginx进程数和worker_cpu_affinity设置(为每个进程分配cpu,上例中将4 个进程分配到4 个cpu,当然可以写多个,或者将一个进程分配到多个cpu。)
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
或者还可以
worker_processes 8;
worker_cpu_affinity 0001 0010 0100 1000 0001 0010 0100 1000;
配置2:8核心+8个进程(每个worker_processes 使用1个CPU)
[reistlin@reistlin.com ~]$ cat /proc/cpuinfo | grep processor processor : 0 processor : 1 processor : 2 processor : 3 processor : 4 processor : 5 processor : 6 processor : 7
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
配置3:16核心+16个进程(每个worker_processes 使用1个CPU)
[reistlin@reistlin.com ~]$ cat /proc/cpuinfo | grep processor processor : 0 processor : 1 processor : 2 processor : 3 processor : 4 processor : 5 processor : 6 processor : 7 processor : 8 processor : 9 processor : 10 processor : 11 processor : 12 processor : 13 processor : 14 processor : 15
worker_processes 16;
worker_cpu_affinity 0000000000000001 0000000000000010 0000000000000100 0000000000001000 0000000000010000 0000000000100000 0000000001000000 0000000010000000 0000000100000000 0000001000000000 0000010000000000 0000100000000000 0001000000000000 0010000000000000 0100000000000000 1000000000000000;
文章评论