标签:roo error_log mime oca request default processes 时间 pid
优化Nginx服务的worker进程个数例如一台2颗物理CPU 每个CPU的核数为4核 ;计算结果就是8*2 =16 (为worker_processes XX)
[root@blog ~]# vi /etc/nginx/nginx.conf
[root@blog ~]# vi /etc/nginx/nginx.conf
user nginx;
worker_processes 24;所有CPU的核数总和
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 24576;**24核乘以每核可承载1024连接数
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
access_log /var/log/nginx/access.log main;
**sendfile on;**开启高效的文件传输模式
**tcp_nopush on;**放开#注释符 可以防止网络和磁盘I/O阻塞,提升Nginx工作效率。
**keepalive_timeout 65;**优化连接超时时间
**gzip on;**启用传输压缩,文件被压缩小了返给用户更快
include /etc/nginx/conf.d/*.conf;
**server_tokens off;**隐藏版本号
标签:roo error_log mime oca request default processes 时间 pid
原文地址:https://blog.51cto.com/kangxi/2407559