siege压力测试软件,压力测试工具siege

本文通过使用 Siege 工具模拟 HTTP 压力测试,探讨了连接复用在客户端(如 OkHttp)和服务器端的影响,以及网络设备配置参数(如路由器超时时间)对请求超时的影响。实验结果显示,在特定设置下,延迟时间和服务器超时配置可能导致请求失败。同时,提到了 OkHttp 连接池的默认存活时间,并指出在并发和随机请求模式下进行压力测试的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

~/Downloads/siege-4.0.4$ ./configure

~/Downloads/siege-4.0.4$ make

~/Downloads/siege-4.0.4$ make install

注意:如果你不是root用户,需要sudo

~/Downloads/siege-4.0.4$ sudo make install

~/Downloads/siege-4.0.4$ siege -version

siege: invalid option -- 'e'

New configuration template added to /home/xxx/.siege

Run siege -C to view the current settings in that file

siege: invalid option -- 'e'

SIEGE 4.0.4

Usage: siege [options]

siege [options] URL

siege -g URL

Options:

-V, --version VERSION, prints the version number.

-h, --help HELP, prints this section.

-C, --config CONFIGURATION, show the current config.

-v, --verbose VERBOSE, prints notification to screen.

-q, --quiet QUIET turns verbose off and suppresses output.

-g, --get GET, pull down HTTP headers and display the

transaction. Great for application debugging.

-p, --print PRINT, like GET only it prints the entire page.

-c, --concurrent=NUM CONCURRENT users, default is 10

-r, --reps=NUM REPS, number of times to run the test.

-t, --time=NUMm TIMED testing where "m" is modifier S, M, or H

ex: --time=1H, one hour test.

-d, --delay=NUM Time DELAY, random delay before each requst

-b, --benchmark BENCHMARK: no delays between requests.

-i, --internet INTERNET user simulation, hits URLs randomly.

-f, --file=FILE FILE, select a specific URLS FILE.

-R, --rc=FILE RC, specify an siegerc file

-l, --log[=FILE] LOG to FILE. If FILE is not specified, the

default is used: PREFIX/var/siege.log

-m, --mark="text" MARK, mark the log file with a string.

between .001 and NUM. (NOT COUNTED IN STATS)

-H, --header="text" Add a header to request (can be many)

-A, --user-agent="text" Sets User-Agent in request

-T, --content-type="text" Sets Content-Type in request

--no-parser NO PARSER, turn off the HTML page parser

--no-follow NO FOLLOW, do not follow HTTP redirects

Copyright (C) 2017 by Jeffrey Fulmer, et al.

This is free software; see the source for copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS

FOR A PARTICULAR PURPOSE.

二、示例分析

1、模拟客户端okhttp连接池中只有一个连接复用的场景

测试目标:连接复用是否会请求超时,连接的存活时间长短和局域网网络设备参数配置,它们对客户端程序的影响大小。

2d98728064a5

image.png

~/Downloads/siege-4.0.4$ siege -d 180 -r 2 -c 1 -v http://bgp.test.com

Transactions: 2 hits

Availability: 100.00 %

Elapsed time: 212.05 secs 测试耗时

Data transferred: 0.02 MB 数据传输量

Response time: 0.02 secs 平均响应时间

Transaction rate: 0.01 trans/sec 每秒事务处理量

Throughput: 0.00 MB/sec 吞吐率

Concurrency: 0.00 并发用户数

Successful transactions: 2

Failed transactions: 0

Longest transaction: 0.03 最长响应时间

Shortest transaction: 0.02 最短响应时间

如果上述第二次请求出现超时,如下所示

2d98728064a5

image.png

就需要进一步跟踪局域网的中间设备的配置参数了。

下面给出华为AR2200路由器,tcp和http协议的默认超时时间。

2d98728064a5

image.png

注意到tcp连接超时时间为600秒,但是http的超时时间为120秒,小于siege的delay 时间,从而导致第二次的请求超时。

2d98728064a5

image.png

这里补充下android客户端关于okhttp的连接池的默认值:

keepalive为5分钟,也即300秒。连接复用技术,如果一个连接是空闲状态,且存活期内,那么客户端将复用该http连接。

2、随机选取testUrls.txt中的网址,进行压力测试。

// -b,更准确的压力测试,而不是功能测试

siege -c 1000 -r 50 -f testUrls.txt -i -b

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值