HTTP压力/性能测试工具ABSender

2012-11-08  付民 

ABSender是一款改自ApacheBench的轻量级http压力/性能测试工具,除了具备所有ApacheBench的所有功能及性能展现之外,它修复了一处数组越界导致的Segmentation Fault的BUG并支持自定义请求的Path路径、Header头、Cookie值和Post数据的功能。所有这些请求的自定义信息,除了能够从文件中读出并随机组合之外,还支持使用范围模板设置请求信息。

 

【作者】 公远/陈震(gongyuan.cz$taobao.com/ 100continue$sina.com)

 

【源码下载】

github地址:https://github.com/100Continue/ABSender

 

【安装介绍】

ABSender的安装介绍:http://100continue.iteye.com/blog/1720376

 

【Bug Fixed】

1. 修复Apache AB在统计“Sorted on total connect times”的时候,会出现由于数组越界而引起的Segmentation fault的问题。详情请点击:http://100continue.iteye.com/blog/1337347

 

【New Feather】

1. 自定义请求信息:(以下参数可以随机组合使用)

参数设置:

 

Options are: -J pathfile File containing data in request path -j pathfile File containing data in request path and in Range Mode -O cookiefile File containing data in request cookie -o cookiefile File containing data in request cookie and in Range Mode -L headerfile File containing data in request header -l headerfile File containing data in request header and in Range Mode -Y multipostfile File containing mulit post data to POST -R multipostfile File containing mulit post data to POST and in Range Mode

 

 

举例介绍:

a. 自定义Path路径:

1)从文件中读入所有Path路径并随机访问:

 

ABSender -c 1 -J /pathfile "http://127.0.0.1:8080/"

 

 

2) 文件内容及格式:

 

4 /index1.html /index2.html /index3.html /index4.html

 

 

 3) 结果分析:

ABSender将会随机发出以下4个路径的请求:

 

GET /index1.html HTTP/1.0 GET /index2.html HTTP/1.0 GET /index3.html HTTP/1.0 GET /index4.html HTTP/1.0

 

b. 自定义Path路径+范围模式:

1)从文件中读入所有Path路径并采用范围模式随机访问:

 

ABSender -c 1 -j /pathfile "http://127.0.0.1:8080/"

 

 

2) 文件内容及格式:

 

1 /index[1-5].html

 

 3) 结果分析:

ABSender将会随机发出以下4个路径的请求(请求头其他数据未列在下面):

 

GET /index1.html HTTP/1.0 GET /index2.html HTTP/1.0 GET /index3.html HTTP/1.0 GET /index4.html HTTP/1.0

 

 

c. 自定义Post Data数据的请求:

1)从文件中读入所有Post Data信息并随机访问

 

ABSender -c 1 -R /postdatafile "http://127.0.0.1:8080/index.html"

2)文件内容及格式:

 

1 this is the post data[1-3] xx

 

 3) 结果分析:

ABSender将会随机发出以下2个请求:

 

POST /index.html HTTP/1.0 Content-length: 26 Content-type: text/plain Host: 127.0.0.1:8080 User-Agent: ABSender Accept: */* this is the post data1 xx POST /index.html HTTP/1.0 Content-length: 26 Content-type: text/plain Host: 127.0.0.1:8080 User-Agent: ABSender Accept: */* this is the post data2 xx

 

 

2. 提供关闭计算连接时间和单位时间内请求处理百分比的功能

当ApacheBench和ABSender发出请求数较多时(达到5千万次请求),统计连接时间和单位时间内请求处理百分比的功能将消耗较长的时间。因此提供了关闭该计算的方法。

参数设置:

 

-M Do not show connection times and percentage of the request served within a certain time.

 

 

【沉淀】

由于自定义请求头的功能需要从文件中读入自定义信息及在每次请求发出前需要重新组织请求内容,因此必然存在性能上的损耗。本次优化主要在以下三方面:

1. 尽量将所有文件读入操作及类型转换操作等放到压力/性能测试开始之前。

2. 对于重新组织请求内容的步骤,采用sprintf方法,减少内存拷贝操作。

3. 考虑“内存对齐”问题,因此将数据结构设置成以下方式,将相邻操作的数据放在一起。从而提高CPU效率。

 

/* to store the scope likes: pre[1-1000]middle[20-30]after, {min:1 extent:999 content:middle} {min:20 extent:10 content:\0}*/ typedef struct { char *content; int min; int extent; }scope_t; /* to store the range info likes: pre[1-1000]middle1[20-30]middle2[7-10]after, pre: pre scope_s[0] = {min:1 extent:999 content:middle1} scope_s[1] = {min:20 extent:10 content:middle2} scope_s[2] = {min:7 extent:3 content:\0} after: after */ typedef struct { char *pre; scope_t scope_s[_MAX]; char *after; int count; }range_t;

 

转至:一淘测试

370°/3704 人阅读/0 条评论 发表评论

登录 后发表评论