测试服务器网站并发,Nginx服务器10000 并发 优化测试(ab测试工具)

1.nginx监控模块

1)编译nginx,加上参数 --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_module

#配置指令

./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)修改nginx配置文件,添加监控状态配置

在nginx.conf的server块中添加如下代码

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;

}

89da5d1594b0eee5453e78a472b54ec4.png

解释:

Active connections:对后端发起的活动连接数。

Server accepts handled requests:Nginx总共处理了655个连接,成功创建655次握手(证明中间没有失败的),总共处理了1985个请求。

Reading:Nginx 读取到客户端的Header信息数。

Writing:Nginx 返回给客户端的Header信息数。

Waiting:开启keep-alive的情况下,这个值等于 active – (reading + writing),意思就是Nginx已经处理完成,正在等候下一次请求指令的驻留连接。

/usr/local/nginx/sbin/nginx -t //测试配置是否正确/usr/local/nginx/sbin/nginx -s reload2.设置最大连接数(50000)/加快tcp连接数的回收/让空的tcp允许回收利用/关闭洪水攻击抵御

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.设置打开更多文件数

ulimit -n 50000

vim /etc/nginx/nginx.conf

worker_rlimit_nofile 10000; //nginx允许打开最大文件数10000-->写在全局 不是在events

events{

worker_connections 10240;

}

/usr/sbin/nginx -t

/usr/sbin/nginx -s reload

4.ab -c 5000 -n 100000 http://192.168.63.129/index.html //压力测试

测试结果:

Server 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)

5000并发100000连接数 失败请求90202  幸好这个是测试服务器

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值