对于http,https使用apache 的ab:
对于http/2使用nghttp2的h2load:
压测http
ab -k -t 180 -c 6 -n 1000000 http://172.16.37.66/index.html
h2load -c 6 -T 180 -n 1000000 https://172.16.37.66/index.html
TCP/UDP压测工具 (https://wiki.swoole.com/wiki/page/197.html)
php run.php -c 100 -n 10000 -s tcp://127.0.0.1:9501 -f long_tcp
测试完成后,打印的结果为:
concurrency: 100 //并发数量
request num: 10000 //请求总数
lost num: 0 //失败次数
success num: 10000 //成功次数
total time: 0.157 //总耗时
req per second: 63558 //qps,每秒处理的请求数
one req use(ms): 0.015 //单个请求的平均时长,此结果目前不准确,请勿作为参考
ab测压工具安装:
yum -y install httpd-tools
ab -V
-n 即requests,用于指定压力测试总共的执行次数。缺省是1;
-c 即concurrency,用于指定的并发数。缺省是1;
-t:测试所进行的总时间,秒为单位,缺省50000s
-k 启用HTTP KeepAlive功能,即在一个HTTP会话中执行多个请求。默认时,不启用KeepAlive功能。
-t 即timelimit,等待响应的最大时间(单位:秒),其内部隐含值是-n 50000,它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
-p:POST时的数据文件
-w: 以HTML表的格式输出结果
执行测试用例:ab -n 1000 -c 100 -w http://localhost/index.php >>d:miss.html
性能测试:
swoole、nginx、Golang web 性能比较100 个并发,100万http请求基准测试
swoole、swoole (mysql 线程池)、nginx + fastCGI + php QPS性能比较
#swoole、nginx、Golang web 性能比较
# nginx helloworld 测试
ab -c 100 -n 1000000 -k http://127.0.0.1:9508/
# golang hello,world 测试
ab -c 100 -n 1000000 -k http://127.0.0.1:8080/
# swoole helloworld 测试
php http-server.php > /dev/null 2>&1
ab -c 100 -n 1000000 -k http://127.0.0.1:9505/
#swoole、swoole (mysql 线程池)、nginx + fastCGI + php
#swoole 同步mysql
php swoole-mysql.php > /dev/null 2>&1
ab -c 2000 -n 20000 http://192.168.132.128:9502/
#swoole mysql 线程池
php swoole-mysql-pool.php > /dev/null 2>&1
ab -c 2000 -n 20000 http://192.168.132.128:9501/
#nginx + fastCGI
ab -c 2000 -n 20000 http://192.168.132.128:9508/pool/sync-mysql.php
同类型的压力测试工具还有: webbench、siege、http_load 等