lnmp 安装的nginx 如何优化?提高并发
本地用ab压测线上nginx服务器:Server Software: nginx
Server Hostname: ************
Server Port: 443
Document Path: /
Document Length: 166 bytes
Concurrency Level: 20
Time taken for tests: 89.538 seconds
Complete requests: 200
Failed requests: 190
(Connect: 0, Length: 190, Exceptions: 0)
Non-2xx responses: 10
Total transferred: 28153479 bytes
HTML transferred: 27263399 bytes
Requests per second: 2.23
Transfer rate: 307.06 kb/s received
Connnection Times (ms)
min avg max
Connect: 69 270 1120
Processing: 2267 8275 24068
Total: 2336 8545 25188
第二次访问https hello word
Server Software: nginx
Server Hostname: ************
Server Port: 443
Document Path: /testrps.php
Document Length: 11 bytes
Concurrency Level: 20
Time taken for tests: 9.212 seconds
Complete requests: 200
Failed requests: 0
Total transferred: 38000 bytes
HTML transferred: 2200 bytes
Requests per second: 21.71
Transfer rate: 4.03 kb/s received
Connnection Times (ms)
min avg max
Connect: 169 560 1148
Processing: 233 306 441
Total: 402 866 1589
第三次访问http hello world
Server Software: nginx
Server Hostname: ************
Server Port: 80
Document Path: /testrps.php
Document Length: 11 bytes
Concurrency Level: 20
Time taken for tests: 6.663 seconds
Complete requests: 200
Failed requests: 0
Total transferred: 38000 bytes
HTML transferred: 2200 bytes
Requests per second: 30.01
Transfer rate: 5.57 kb/s received
Connnection Times (ms)
min avg max
Connect: 16 32 135
Processing: 43 605 1146
Total: 59 637 1281
服务器配置如下
CPU: 2核
内存: 8 GB
实例类型: I/O优化
操作系统: CentOS6.8 64位
当前使用带宽: 5Mbps
实例规格族: 通用型
rps极不理想,nginx与php-frm做了些优化,感觉不到效果
nginx.conf
worker_processes 4;
worker_cpu_affinity 01 10 01 10;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_buffers 256 16k;
fastcgi_buffer_size 128k;
fastcgi_connect_timeout 3s;
fastcgi_send_timeout 120s;
fastcgi_read_timeout 120s;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE \.";
php-fpm.conf
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = static
pm.max_children = 100
pm.start_servers = 30
pm.min_spare_servers = 30
pm.max_spare_servers = 60
pm.max_requests = 200
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
页:
[1]