Nginx性能优化
影响性能的指标
网络
网络是否丢包
系统
系统负载 内存等
服务
连接优化 请求优化
程序
处理速率 接口性能等
数据库
系统性能优化
设置文件句柄数
vim /etc/security/limits.conf
//针对root⽤用户
root soft nofile 65535
root hard nofile 65535
//所有⽤用户, 全局
* soft nofile 25535
* hard nofile 25535
nginx进程句柄
worker_rlimit_nofile 45535;
nginx性能优化
worker_processes auto;
worker_cpu_affinity auto;
相关配置如下
<pre class="section">user www;
worker_processes auto;
worker_cpu_affinity auto;
error_log /var/log/nginx.error.log warn;
pid /var/nginx/nginx.pid
worker_rlimit_nofile 35535;
events {
use epoll;
#限制每个进程能处理理多少个连接请求,10240x16
worker_connections 10240;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# 统⼀一使⽤用utf-8字符集
charset utf-8;
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;
# Core module
sendfile on;
# 静态资源服务器器建议打开
tcp_nopush on;
# 动态资源服务建议打开,需要打开keepalived
tcp_nodelay on;
keepalive_timeout 65;
# Gzip module
gzip on;
gzip_disable MSIE [1-6]\.;
gzip_http_version 1.1;
# Virtal Server
include /etc/nginx/conf.d/*.conf;
}
Nginx性能优化
http://www.jcwit.com/article/44/