幾個比較著名的測量web負載的工具:
Apache Benchmark (http://httpd.apache.org)
Siege ( http://www.joedog.org/JoeDog/Siege)
Apache Jakarta的JMeter ( http://jakarta.apache.org/jmeter)
Faban ( http://faban.sunsource.net )
其中JMeter比較有特色,提供了圖形化用戶界面,而且在web測試以及生成報告上非常有特色、非常靈活。
但JMeter不像Benchmark 以及Siege 那樣,每秒鐘請求並完成那麼多次http請求,如果你要確定每秒完成多少次http請求,那麼還是建議使用Benchmark 或Siege。
Apache Benchmark 使用:
例如,訪問某服務1萬次,最多每次併發1千個線程的測試代碼爲:
D:\Apache2.2\bin>ab -k -n 10000 -c 1000 http://192.168.0.240:8080/ab.jsp
說明:
1)使用-k參數表示使用keep-alive連接方式,可以去掉
2)如果tomcat 中conf/server.xml中的connector中maxThread爲150,但測試中的每次併發線程大於這個數量,則可能會影響性能,因爲有線程在等待(超出maxThread數量的併發請求如果在超過timout時間後,即會失敗)。