jmeter get post 压力测试及ab 的压力测试及单个接口xhprof对比

来源:互联网 发布:金泰妍同款衣服淘宝 编辑:程序博客网 时间:2024/04/20 18:35

Jmeter  下载和运行

1.官方网站:http://jmeter.apache.org/

解压后, 运行  “bin/jmeter.bat”   

Jmeter 是支持中文的, 启动Jmeter 后, 点击 Options -> Choose Language  来选择语言


2.实际测试的例子

目标: 测试搜索接口的压力

  方法一:请求类型:get  http://api.zintao.com/Search/Search/search?keyword=商品&did=1231234234


  












第二种 方法:post 

 










apache ab 安装

在任意目录下执行该命令:yum -y install httpd-tools

测试一下ab是否安装成功:ab -V

[root@localhost ~]#/usr/local/apache/bin/ab -VThis 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/
测试例子:

get 方法:

ab -n 1000 -c 1000 -k  http://api.zintao.com/Search/Search/search?keyword=商品&did=3E1B1CBE-B433-48FD-9AED-001E7E0FCC3C

post方式

ab -n 1000 -c 1000 -k -p  'userlogin.txt' -T  http://api.zintao.com/Search/Search/search?keyword=商品&did=3E1B1CBE-B433-48FD-9AED-001E7E0FCC3C

 userlogin.txt 为json数据 或者 user_name=639493678400&password=A1111111&cheers=1


Server Software:        nginx/0.7.65
Server Hostname:        www.test.com
Server Port:            80
Document Path:          /  ###请求的资源
Document Length:        50679 bytes  ###文档返回的长度,不包括相应头

Concurrency Level:      3000   ###并发个数
Time taken for tests:   30.449 seconds   ###总请求时间
Complete requests:      3000     ###总请求数
Failed requests:        0     ###失败的请求数
Write errors:           0
Total transferred:      152745000 bytes
HTML transferred:       152037000 bytes
Requests per second:    98.52 [#/sec] (mean)      ###平均每秒的请求数
Time per request:       30449.217 [ms] (mean)     ###平均每个请求消耗的时间
Time per request:       10.150 [ms] (mean, across all concurrent requests)  ###上面的请求除以并发数
Transfer rate:          4898.81 [Kbytes/sec] received   ###传输速率

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        2   54  27.1     55      98
Processing:    51 8452 5196.8   7748   30361
Waiting:       50 6539 5432.8   6451   30064
Total:         54 8506 5210.5   7778   30436

Percentage of the requests served within a certain time (ms)
  50%   7778   ###50%的请求都在7778Ms内完成
  66%  11059

参考:http://blog.csdn.net/superhosts/article/details/40109447

其中参数n为请求的次数,c为一次请求的并发次数,-k为keep_alive,一般出现链接被重置的错误时最好带上-k的参数。













参考文章:

http://www.cnblogs.com/TankXiao/p/4045439.html

http://my.oschina.net/hellotest/blog/512482

0 0
原创粉丝点击