1.nginx monitoring module
1) Compile nginx with the parameter –with-http_stub_status_module
#/usr/local/nginx/sbin/nginx -V
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_mo
./configure --prefix=/usr/local
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_realip_module
--http-client-body-temp-path=/usr/local/var/tmp/nginx/client
--http-proxy-temp-path=/usr/local/var/tmp/nginx/proxy
--http-fastcgi-temp-path=/usr/local/var/tmp/nginx/fcgi
--http-scgi-temp-path=/usr/local/var/tmp/nginx/scgi
--http-uwsgi-temp-path=/usr/local/var/tmp/nginx/uwsgi
--with-http_geoip_module
--with-http_stub_status_module
2) Modify the nginx configuration file and add the monitoring status configuration
Add the following code to the server block of nginx.conf
location /nginx_status {
# Turn on nginx stats
stub_status on;
# I do not need logs for stats
access_log off;
# Security: Only allow access from 192.168.1.100 IP #
#allow 192.168.1.100;
# Send rest of the world to /dev/null #
#deny all;
}
xplanation:
Active connections: The number of active connections initiated by the backend.
Server accepted handling requests: Nginx handled a total of 655 connections, successfully created 655 times handshake (proved no failure in the middle), handled a total of 1985 requests.
Reading: Nginx Number of Header messages read to the client.
Writing: Nginx Number of Header messages returned to the client.
Waiting: In the case of keep-alive, this value is equal to active - (reading + writing), meaning that Nginx
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload
2. Set the maximum number of connections (50000) / tcp speed up the recovery of the number of conn
echo 50000 > /proc/sys/net/core/somaxconn
echo 1 > /proc/sys/net/ipv4/tcp_tw/recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 0 > /proc/sys/net/ipv4/tcp_syncookies
3. set to open more files
ulimit -n 50000
vim /etc/nginx/nginx.conf
worker_rlimit_nofile 10000;
events{
worker_connections 10240;
}
/usr/sbin/nginx -t
/usr/sbin/nginx -s reload
4.ab -c 5000 -n 100000 http://192.168.1.129/index.html
erver Software: nginx/1.4.6
Server Hostname: 192.168.63.129
Server Port: 80
Document Path: /index.html
Document Length: 65 bytes
Concurrency Level: 5000
Time taken for tests: 46.416 seconds
Complete requests: 100000
Failed requests: 90202
(Connect: 0, Receive: 0, Length: 90202, Exceptions: 0)
Write errors: 0
Non-2xx responses: 90282
Total transferred: 36624606 bytes
HTML transferred: 18815922 bytes
Requests per second: 2154.42 [#/sec] (mean)
Time per request: 2320.813 [ms] (mean)
Time per request: 0.464 [ms] (mean, across all concurrent requests)
Transfer rate: 770.55 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 18 1251 2273.8 824 31950
Processing: 298 839 299.1 855 6307
Waiting: 1 648 298.8 651 6194
Total: 408 2090 2323.2 1697 36083
Percentage of the requests served within a certain time (ms)
50% 1697
66% 1758
75% 1802
80% 1843
90% 2583
95% 4601
98% 8399
99% 8807
100% 36083 (longest request)
Recent Comments