几个比较著名的测量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时间后,即会失败)。