1,nginx的http配置
proxy_intercept_errors on;
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
limit_conn_status 503; #超出限制时,返回状态码
location 模块配置:
limit_req zone=mylimit nodelay;
http模块错误页面重定向
error_page 503 /408.html;
2,ab测试验证
ab测试参数:
ab -n 800 -c 800 http://192.168.1.10/
(-n发出800个请求,-c模拟800并发,相当800人同时访问,后面是测试url)
ab -t 60 -c 100 http://192.168.1.10/
在60秒内发请求,一次100个请求。
//如果需要在url中带参数,这样做
ab -t 60 -c 100 -T "text/plain" -p p.txt http://192.168.0.10/hello.html
p.txt 是和ab.exe在一个目录
p.txt 中可以写参数,如 p=wdp&fq=78
-----------------------------------------------------------------------------------------------
ab测试具体例子:
ab -t 1 -c 20 http://192.169.0.1/base
模拟1秒钟 20个请求
[root@web-01 sbin]# ab -t 1 -c 20 http://192.168.0.1/base
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking dev.cbs.bacic5i5j.com (be patient)
Completed 5000 requests
Finished 7457 requests
Server Software: nginx/1.4.4
Server Hostname: dev.cbs.bacic5i5j.com
Server Port: 80
Document Path: /base
Document Length: 0 bytes HTTP响应数据的正文长度
Concurrency Level: 20
Time taken for tests: 1.000 seconds 所有这些请求处理完成所花费的时间
Complete requests: 7457 完成请求数
Failed requests: 7447 --失败请求数 就是由于限流10r/s 每秒钟10个请求
(Connect: 0, Receive: 0, Length: 7447, Exceptions: 0)
Write errors: 0
Non-2xx responses: 7474
Total transferred: 1233810914 bytes ---网络总传输量
HTML transferred: 1232331592 bytes --HTML内容传输量
Requests per second: 7455.60 [#/sec] (mean) ---吞吐量-每秒请求数
Time per request: 2.683 [ms] (mean) --服务器收到请求,响应页面要花费的时间
Time per request: 0.134 [ms] (mean, across all concurrent requests) --并发的每个请求平均消耗时间
Transfer rate: 1204666.99 [Kbytes/sec] received ---received 平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
网络上消耗的时间的分解:
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 1 2 0.2 2 5
Waiting: 0 0 0.1 0 2
Total: 1 3 0.3 3 6
整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间
其中 50% 的用户响应时间小于 3毫秒
80 % 的用户响应时间小于 3毫秒
最大的响应时间小于 6 毫秒
Percentage of the requests served within a certain time (ms)
Percentage of the requests served within a certain time (ms)
50% 3
66% 3
75% 3
80% 3
90% 3
95% 3
98% 4
99% 4
100% 6 (longest request)
欢迎关注我的微信公众号,里面会分享技术和投资的一些想法,欢迎交流讨论
相关推荐
nginx限流
nginx 实现对ip的限流。
web服务器如何限流-nginx,tomcat服务器如何限制流量 用ab压测工具测试限流效果
主要介绍了Nginx源码研究之nginx限流模块详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
本文以示例的形式,由浅入深讲解Nginx限流相关配置,是对简略的官方文档的积极补充。 Nginx限流使用的是leaky bucket算法,如对算法感兴趣,可移步维基百科先行阅读。不过不了解此算法,不影响阅读本文。 空桶 我们...
分布式限流面试专题系列:Nginx+zookeeper.zip
一步步安装nginx搭建流媒体服务器的所有软件打包; nginx-1.8.0.tar.gz :应用服务器主程序 nginx_mod_h264_streaming-2.2.7.tar.gz :MP4流媒体支持模块。 openssl-1.0.1c.tar.gz :openssl库 pcre-7.9.tar.gz :...
nginx四层代理测试 及SLB负载均衡功能配置测试
一般对外暴露的系统,在促销或者黑客攻击时会涌来大量的请求,为了保护系统不被瞬间到来的高并发流量给打垮, 就需要限流,这篇文章主要介绍了nginx限流方案的实现,非常具有实用价值,需要的朋友可以参考下
nginx 限制ip、并发量、连接数等配置
awk测试从nginx查询qps的测试日志
LINUX-nginx
测试htpps,以及修改nginx的配置,打开443端口,还有php相关配置
Nginx教程 防御ddos,用户访问控制,限流.zip
nginx日志测试使用 access.log.zip
Nginx应用案例分享:压力测试,Nginx测试,Nginx压力测试
nginx+lua+redis实现token验证。实现基本的token验证、反向代理转发内部服务,lua连接redis封装、lua域名解析封装、lua域名脚本等
1、ab 测试工具安装 2、wrk测试工具 1、系统和nginx是否可以建立多个socket连接 2、系统和nginx是否允许一次性打开多个文件 1、http连
对于nginx做ip限制一些总结。