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 等