欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

目錄

描述nginx中worker_processes、worker_cpu_affinity、worker_rlimit_nofile、worker_connections配置項(xiàng)的含義

描述nginx中worker_processes、worker_cpu_affinity、worker_rlimit_nofile、worker_connections配置項(xiàng)的含義

nginx 配置文件格式說明

配置文件由指令與指令塊構(gòu)成

每條指令以;分號(hào)結(jié)尾,指令與值之間以空格符號(hào)分隔

可以將多條指令放在同一行,用分號(hào)分隔即可,但可讀性差,不推薦

指令塊以{ }大括號(hào)將多條指令組織在一起,且可以嵌套指令塊

include語句允許組合多個(gè)配置文件以提升可維護(hù)性

使用#符號(hào)添加注釋,提高可讀性

使用$符號(hào)使用變量

部分指令的參數(shù)支持正則表達(dá)式

1.worker_processes

啟動(dòng)Nginx工作進(jìn)程的數(shù)量,一般設(shè)為和CPU核心數(shù)相同,auto:自動(dòng)檢測,設(shè)置為當(dāng)前主機(jī)cpu的核心數(shù)

worker_processes [number | auto];  

[root@centos7 ~]#ps aux|grep nginx

root       1301  0.0  0.0  46344  2020 ?        Ss   18:52   0:00 nginx: master process /apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf

nginx      2011  0.0  0.1  46772  2276 ?        S    21:21   0:00 nginx: worker process

root       2211  0.0  0.0 112808   968 pts/1    S+   22:54   0:00 grep --color=auto nginx

#將工作進(jìn)程的數(shù)量設(shè)置為2個(gè)

[root@centos7 ~]#vim /apps/nginx/conf/nginx.conf

worker_processes  2;

[root@centos7 ~]#nginx -s reload

[root@centos7 ~]#ps aux|grep nginx

root       1301  0.0  0.1  46232  2060 ?        Ss   18:52   0:00 nginx: master process /apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf

nginx      2241  0.0  0.0  46652  1932 ?        S    23:02   0:00 nginx: worker process

nginx      2242  0.0  0.0  46652  1932 ?        S    23:02   0:00 nginx: worker process

root       2244  0.0  0.0 112808   968 pts/1    S+   23:02   0:00 grep --color=auto nginx

2.worker_cpu_affinity

將Nginx工作進(jìn)程綁定到指定的CPU核心,默認(rèn)Nginx是不進(jìn)行進(jìn)程綁定的,綁定并不是意味著當(dāng)前nginx進(jìn)程獨(dú)占以一核心CPU,但是可以保證此進(jìn)程不會(huì)運(yùn)行在其他核心上,這就極大減少了nginx的工作進(jìn)程在不同的cpu核心上的來回跳轉(zhuǎn),減少了CPU對(duì)進(jìn)程的資源分配與回收以及內(nèi)存管理等,因此可以有效的提升nginx服務(wù)器的性能。

worker_cpu_affinity 00000001 00000010 00000100 00001000 | auto;

CPU MASK: 00000001:0號(hào)CPU

          00000010:1號(hào)CPU

          10000000:7號(hào)CPU

[root@centos7 ~]#ps axo pid,cmd,psr |grep nginx

  1301 nginx: master process /apps   1

  2241 nginx: worker process         0

  2242 nginx: worker process         0

  2340 grep --color=auto nginx       1

#將第一個(gè)工作進(jìn)程綁定到 CPU0,將第二個(gè)工作進(jìn)程綁定到 CPU1

[root@centos7 ~]#vim /apps/nginx/conf/nginx.conf

worker_processes  2;

worker_cpu_affinity 01 10;

[root@centos7 ~]#nginx -s reload

[root@centos7 ~]#ps axo pid,cmd,psr |grep nginx

  1274 nginx: master process /apps   0

  2029 nginx: worker process         0

  2030 nginx: worker process         1

  2036 grep --color=auto nginx       1

3.worker_rlimit_nofile

所有worker進(jìn)程能打開的文件數(shù)量上限,包括:Nginx的所有連接(例如與代理服務(wù)器的連接等),而不僅僅是與客戶端的連接,另一個(gè)考慮因素是實(shí)際的并發(fā)連接數(shù)不能超過系統(tǒng)級(jí)別的最大打開文件數(shù)的限制。最好與ulimit -n 或者limits.conf的值保持一致。用于在不重新啟動(dòng)主進(jìn)程的情況下增加限制。

#設(shè)置工作進(jìn)程的最大打開文件數(shù)為65536

[root@centos7 ~]#vim /apps/nginx/conf/nginx.conf

worker_rlimit_nofile 65536;

[root@centos7 ~]#ulimit -n 100000

[root@centos7 ~]#ulimit -a

core file size          (blocks, -c) 0

data seg size           (kbytes, -d) unlimited

scheduling priority             (-e) 0

file size               (blocks, -f) unlimited

pending signals                 (-i) 7835

max locked memory       (kbytes, -l) 64

max memory size         (kbytes, -m) unlimited

open files                      (-n) 100000

pipe size            (512 bytes, -p) 8

POSIX message queues     (bytes, -q) 819200

real-time priority              (-r) 0

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 7835

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

#修改PAM資源限制

[root@centos7 ~]#vim /etc/security/limits.conf

*                soft    core            unlimited

*                hard    core            unlimited

*                soft    nproc           1000000

*                hard    nproc           1000000

*                soft    nofile          1000000

*                hard    nofile          1000000

*                soft    memlock         32000

*                hard    memlock         32000

*                soft    msgqueue        8192000

*                hard    msgqueue        8192000

#重啟生效

[root@centos7 ~]#reboot

[root@centos7 ~]#ulimit -n

1000000

[root@centos7 ~]#ulimit -a

core file size          (blocks, -c) unlimited

data seg size           (kbytes, -d) unlimited

scheduling priority             (-e) 0

file size               (blocks, -f) unlimited

pending signals                 (-i) 7835

max locked memory       (kbytes, -l) 32000

max memory size         (kbytes, -m) unlimited

open files                      (-n) 1000000

pipe size            (512 bytes, -p) 8

POSIX message queues     (bytes, -q) 8192000

real-time priority              (-r) 0

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 1000000

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

4.worker_connections

設(shè)置單個(gè)工作進(jìn)程可以同時(shí)打開的最大連接數(shù)。這個(gè)數(shù)字包括所有連接(例如與代理服務(wù)器的連接等),而不僅僅是與客戶端的連接。另一個(gè)考慮是實(shí)際同時(shí)連接數(shù)不能超過當(dāng)前最大打開文件數(shù)限制,可以通過 worker_rlimit_nofile更改。

作為web服務(wù)器的時(shí)候最大并發(fā)數(shù)為:worker_connections * worker_processes

作為反向代理的時(shí)候?yàn)椋?worker_connections * worker_processes)/2

[root@centos7 ~]#vim /apps/nginx/conf/nginx.conf

events {

    worker_connections  10240;

    accept_mutex on;

    multi_accept on;

}

[root@centos7 ~]#nginx -s reload

5、Nginx性能優(yōu)化建議

Syntax:accept_mutex on | off;

Default:accept_mutex off;

Context:events

#建議設(shè)置為accept_mutex on; 

如果accept_mutex啟用,工作進(jìn)程將依次接受新連接,默認(rèn)為off。否則,將通知所有工作進(jìn)程有關(guān)新連接的信息,如果新連接量較低,則某些工作進(jìn)程可能只是浪費(fèi)系統(tǒng)資源,在高并發(fā)場景下,建議設(shè)置為on。

Syntax:multi_accept on | off;

Default:multi_accept off;

Context:events

#建議設(shè)置為multi_accept on; 

如果multi_accept禁用,工作進(jìn)程將一次接受一個(gè)新連接,默認(rèn)為off。開啟后,工作進(jìn)程將一次接受所有新連接。建議設(shè)置為on

原文鏈接:

評(píng)論可見,查看隱藏內(nèi)容


本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場。

轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://m.gantiao.com.cn/post/18580220.html

發(fā)布評(píng)論

您暫未設(shè)置收款碼

請(qǐng)?jiān)谥黝}配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問

文章目錄