码迷,mamicode.com
首页 > Web开发 > 详细

apache bench(ab)压力测试模拟POSt请求

时间:2017-09-09 22:26:36      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:get   使用   方式   runtime   时间   内存   div   sleep   https   

ab命令格式:
-N|--count 总请求数,缺省 : 5w
-C|--clients 并发数, 缺省 : 100
-R|--rounds 测试次数, 缺省 : 10 次
-S|-sleeptime 间隔时间, 缺省 : 10 秒
-I|--min 最小并发数, 缺省: 0
-X|--max 最大并发数,缺省: 0
-J|--step 次递增并发数
-R|--runtime 总体运行时间,设置此项时最大请求数为5w
-P|--postfile post数据文件路径
-U|--url 测试地址

 

要使用ab进行post数据测试.从help可以看出我们需要定义两个内容
一个是-p参数.指定需要post的数据
还有一个是-T参数,指定使用的content-type

eg :

ab -n 3 -c 3 -p post.txt -T application/x-www-form-urlencoded http://192.168.1.176:8080/xx

ab -n 1 -c 1 -p post.txt -T application/octet-stream  http://172.25.33.211:8088/dsp/rtb

  

另外,post.txt里面的post数据要放你的json数据,比如

data={"id":"1234"}

但是注意要进行urlencode加密,于是真正放在post.txt里面的内容就是data=%7B%22id%22%3A%221234%22%7D,还有要注意,不要自己在windows上建一个post.txt放数据,而是使用比如eclipse或者notepad++,因为自己建一个txt会在文件开头有一个特殊字符,这样解析不了。我是用的intellij idea开发,用它建的txt文件。搞好之后你再ab以下肯定可以了。。。。

 

-p选项指定post文件的位置;-T选项指定post文件的编码方式,默认是明文,如果指定-T ‘application/x-www-form-urlencoded‘,则表示post文件使用urlencode
 
 
统计QPS的简单办法,通过日志来统计:
tail -f jradx-go-dsp.INFO | grep originalDeviceId | cut -d‘ ‘ -f2 | cut -d‘:‘ -f3 |cut -d‘.‘ -f1| uniq -c

  

查看内存消耗:
free -ml -s 1

  

 查看go的内存消耗:
http://xiaorui.cc/2016/03/20/golang%E4%BD%BF%E7%94%A8pprof%E7%9B%91%E6%8E%A7%E6%80%A7%E8%83%BD%E5%8F%8Agc%E8%B0%83%E4%BC%98/

  

linux上抓取网络包:
 
tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap

  

 技术分享

 

 
https://docs.mongodb.com/manual/reference/read-preference/
http://blog.csdn.net/zqg5258423/article/details/53207471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

apache bench(ab)压力测试模拟POSt请求

标签:get   使用   方式   runtime   时间   内存   div   sleep   https   

原文地址:http://www.cnblogs.com/mazhimazhi/p/7499453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!