近来有需求要对HTTP接口进行压测,于是去了解了一下JMeter,发现虽然功能强大,但本身依赖JAVA,并且依赖图形化界面,不够轻量化,所以想着自己写一个基于命令行的轻量级压测工具,于是就有了httptester。
httptester是采用GO语言来编写的,尽管目前仍是早期版本,但是基本功能已经没有问题了。
快速开始
httptester是一个二进制可执行文件,无需安装。
下载最新版本:https://github.com/rocketk/httptester/releases
国内镜像地址:https://gitee.com/rocketk/httptester/releases
找到自己平台对应的版本下载至本地,将其所在目录放入系统环境变量中。
常用命令
获取帮助信息
httptester -h
httptester run -h
httptester serve -h
最简单的压测命令(以压测百度首页为例)
httptester run -u 'https://www.baidu.com/'
设定并发量、循环次数、超时时间
httptester run --loop 10 --concurrency 100 --timeout 500ms -u 'https://www.baidu.com/'
#httptester run --loop 10 --concurrency 100 --timeout 2s -u 'https://www.baidu.com/'
结果
100% [==============================]
-- Configuration --
Concurrency: 100 Loop: 10 Timeout: 2000 ms KeepAlive: true TimeUnit: ms Method: GET URL: https://www.baidu.com/
Headers: []
Body:
-- Conclusion --
total count: 1000
success count: 981
failed count: 0
error count: 19
nature duration: 2280 ms
total cost: 195688 ms
max: 1539 ms
min: 0 ms