天天看点

httperf 一个高性能的压力测试工具

Written by bixuan on 2008年06月26号 – 22:14

做个标记:)

Httperf 是一个高效的 http 压力测试工具,使用它可以模拟出超过1千的并发访问,能充分测试出 web server 的性能。而之前使用的 siege 测试工具则未能突破 500 个并发测试(如果您知道如何可以实现,请告诉我)

使用 httperf 应该能了解到自己编写 yo2cache 软件性能极限如何了

以下是 gzip 格式访问的测试数据(因缓存文件以 gzip 格式保存,所以性能是最高的)

oneoo@oneoo-pc:~/Desktop$ httperf –server oneoo.com –num-conns 2000 –add-header “accept-encoding: gzip” httperf –client=0/1 –server=oneoo.com –port=80 –uri=/ –send-buffer=4096 –recv-buffer=16384 –add-header=’accept-encoding: gzip’ –num-conns=2000 –num-calls=1 Maximum connect burst length: 1 Total: connections 2000 requests 2000 replies 2000 test-duration 1.304 s Connection rate: 1533.7 conn/s (0.7 ms/conn, Connection time [ms]: min 0.6 avg 0.7 max 6.3 median 0.5 stddev 0.2 Connection time [ms]: connect 0.0 Connection length [replies/conn]: 1.000 Request rate: 1533.7 req/s (0.7 ms/req) Request size [B]: 81.0 Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples) Reply time [ms]: response 0.6 transfer 0.0 Reply size [B]: header 302.0 content 10482.0 footer 0.0 (total 10784.0) Reply status: 1xx=0 2xx=2000 3xx=0 4xx=0 5xx=0 CPU time [s]: user 0.29 system 1.01 (user 22.4% system 77.6% total 100.0%) Net I/O: 16273.4 KB/s (133.3*10^6 bps) Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0 Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

以下是 deflate (2级压缩率)格式访问的统计数据(需要从 gzip 解压,再压缩为 deflate 的数据处理)

oneoo@oneoo-pc:~/Desktop$ httperf –server oneoo.com –num-conns 2000 –add-header “accept-encoding: deflate” httperf –client=0/1 –server=oneoo.com –port=80 –uri=/ –send-buffer=4096 –recv-buffer=16384 –add-header=’accept-encoding: deflate’ –num-conns=2000 –num-calls=1 Total: connections 2000 requests 2000 replies 2000 test-duration 4.113 s Connection rate: 486.2 conn/s (2.1 ms/conn, Connection time [ms]: min 2.0 avg 2.1 max 11.8 median 2.5 stddev 0.3 Request rate: 486.2 req/s (2.1 ms/req) Request size [B]: 84.0 Reply time [ms]: response 0.6 transfer 1.5 Reply size [B]: header 305.0 content 11014.0 footer 0.0 (total 11319.0) CPU time [s]: user 0.91 system 3.20 (user 22.2% system 77.8% total 100.0%) Net I/O: 5414.3 KB/s (44.4*10^6 bps)

以下是 deflate (4级压缩率)格式访问的统计数据

Total: connections 2000 requests 2000 replies 2000 test-duration 5.329 s Connection rate: 375.3 conn/s (2.7 ms/conn, Connection time [ms]: min 2.6 avg 2.7 max 32.8 median 2.5 stddev 0.7 Request rate: 375.3 req/s (2.7 ms/req) Reply rate [replies/s]: min 374.8 avg 374.8 max 374.8 stddev 0.0 (1 samples) Reply time [ms]: response 0.6 transfer 2.0 Reply size [B]: header 305.0 content 10457.0 footer 0.0 (total 10762.0) CPU time [s]: user 1.29 system 4.01 (user 24.2% system 75.2% total 99.4%) Net I/O: 3975.4 KB/s (32.6*10^6 bps)

以下是文本格式访问的统计数据

oneoo@oneoo-pc:~/Desktop$ httperf –server oneoo.com –num-conns 2000 –add-header “accept-encoding: normal” httperf –client=0/1 –server=oneoo.com –port=80 –uri=/ –send-buffer=4096 –recv-buffer=16384 –add-header=’accept-encoding: normal’ –num-conns=2000 –num-calls=1 Total: connections 2000 requests 2000 replies 2000 test-duration 2.349 s Connection rate: 851.3 conn/s (1.2 ms/conn, Connection time [ms]: min 1.1 avg 1.2 max 5.8 median 1.5 stddev 0.2 Request rate: 851.3 req/s (1.2 ms/req) Request size [B]: 83.0 Reply time [ms]: response 0.6 transfer 0.6 Reply size [B]: header 278.0 content 42562.0 footer 0.0 (total 42840.0) CPU time [s]: user 0.62 system 1.73 (user 26.2% system 73.7% total 99.9%) Net I/O: 35683.0 KB/s (292.3*10^6 bps)

从以上数据可以看到 yo2cache 性能挺好的,最高能达到每秒 1500 个并发处理。性能瓶颈是出现在缓存数据的解压与压缩处理上,如果缓存空间足够大的话,可以考虑保存多种格式的缓存数据,就能解决这个瓶颈问题。

而在 deflate 数据压缩方面,因为2级压缩率与4级压缩率所产生的数据量差距不大,但并发性能有一定差距,可以考虑使用 2 级压缩率。

From:http://oneoo.com/articles/httperf-the-pressure-of-a-high-performance-test-tools.html

继续阅读