• [转]web服务器压力测试工具


    http_load学习心得:

    测试网站每秒所能承受的平均访问量(吞吐量)

    http_load -parallel 5 -fetches 1000 urls.txt
    这段命令行是同时使用5个进程,随机访问urls.txt中的网址列表,总共访问1000次。运行之后的结果:

    1000 fetches, 5 max parallel, 6e+06 bytes, in 58.1026 seconds
    6000 mean bytes/connection
    17.2109 fetches/sec, 103266 bytes/sec
    msecs/connect: 0.403263 mean, 68.603 max, 0.194 min
    msecs/first-response: 284.133 mean, 5410.13 max, 55.735 min
    HTTP response codes:
    code 200 — 1000

    从上面的运行结果来看,目标网站仅仅能够承受每秒17次访问,不够强壮。

    测试网站是否能承受住预期的访问压力(

    http_load -rate 2 -seconds 300 urls.txt
    在300秒内保持一定的频率访问目标url。

    注:

    • urls.txt保存要访问的url列表,每行一个
    • 不要测试上线之后的网站,压垮了可不好玩

    例如:

    1.http_load -parallel 5 -fetches 1000 urls.txt

    2.http_load -rate 2 -seconds 300 urls.txt

    3. http_load -p 30 -s 60   urllist.txt

    4. http_load -parallel 50 -s 10 urls.txt
           这段命令行是同时使用50个进程,随机访问urls.txt中的网址列表,总共访问10秒。

     

    参数说明:

    -parallel 简写-p :含义是并发的用户进程数。
    -fetches 简写-f :含义是总计的访问次数
    -rate    简写-r :含义是每秒的访问频率
    -seconds简写-s :含义是总计的访问时间

    参数是可以自由组合的,参数之间的选择并没有什么限制。

    urls.txt保存要访问的url列表,

    url 是你要访问的网址名,参数可以是单个的网址也可以是包含网址的文件。文件格式是每行一个URL,URL最好超过50-100个测试效果比较好. 文件格式如下

    http://iceskysl.1sters.com/?action=show&id=336
    http://iceskysl.1sters.com/?action=show&id=335
    http://iceskysl.1sters.com/?action=show&id=332
    http://iceskysl.1sters.com/?action=show&id=32

    参数了解了,我们来运行一条命令, 来看看它的返回结果

    命令:% ./http_load -rate 5 -seconds 10 urls
    命令解释: 执行一个持续时间为10秒的测试,每秒的访问频率为5次。

    49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
    5916 mean bytes/connection
    4.89274 fetches/sec, 28945.5 bytes/sec (重要性能指标吞吐量)
    msecs/connect
    : 28.8932 mean, 44.243 max, 24.488 min(重要指标响应时间)
    msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
    HTTP response codes:
    code 200 — 49

    结果分析:
    1.49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds
    说明在上面的测试中运行了49个请求,最大的并发进程数是2,总计传输的数据是289884bytes,运行的时间是10.0148秒
    2.5916 mean bytes/connection
    说明每一连接平均传输的数据量289884/49=5916
    3.4.89274 fetches/sec, 28945.5 bytes/sec (吞吐量: 单位时间完成请求数)
    说明每秒的响应请求为4.89274,每秒传递的数据为28945.5 bytes/sec
    这个值得是根据 49 fetches / 10.0148 seconds 秒计算出来的
    4.msecs/connect: 28.8932 mean, 44.243 max, 24.488 min (响应时间: 每次请求需要的时间, 平均, 最大, 最小)
    说明每连接的平均响应时间是28.8932 msecs,最大的响应时间44.243 msecs,最小的响应时间24.488 msecs
    5.msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min
    6、HTTP response codes: code 200 — 49

    说明打开响应页面的类型,如果403的类型过多,那可能要注意是否系统遇到了瓶颈。
    特殊说明:这里,我们一般会关注到的指标是fetches/sec、msecs/connect
    他们分别对应的常用性能指标参数

    Qpt-每秒响应用户数和response time,每连接响应用户时间。
    测试的结果主要也是看这两个值。当然仅有这两个指标并不能完成对性能的分析,我们还需要对服务器的cpu、memory进行分析,才能得出结论

    ,另外,测试结果中主要的指标是 fetches/sec 这个选项,即服务器每秒能够响应的查询次数,用这个指标来衡量性能。似乎比 apache的ab准确率要高一些,也更有说服力一些。

     

     

     

    http_load测试参数比较

    6月 11th, 2008 Posted in http_load < by Johnny Woo >

    ./http_load -parallel 200 -seconds 10 urls
    按照固定时间来结束测试,这样可以比较相同时间内被测服务器的响应速度.
    ./http_load -parallel 200 -fetches 1000 urls
    按照固定申请数来测试,这样可以比较相同访问量下返回的响应速度.

    虽然两者都可以获取到服务器的响应速度
    但是使用fetches更容易让被测服务器收到压力
    由于seconds控制测试时间,很有可能在短时间内测试客户端并没有发起足够数量的请求
    而服务端在收到足够压力之前,测试就已经结束了.
    有一些情况,诸如内存泄漏以及资源回收不利或者对后面的响应速度越来越慢等情况
    在这种测试条件下不容易发生
    而使用fetchs,能够让客户端保证确定请求数的全部处理.
    使用时间作为控制参数
    会由于测试人员不够耐心而人为将seconds参数设置过小
    导致测试结果失去意义

    所以,最后建议使用fetches作为测试参数.用以作为基准进行比较

     

     

    http_load做测试时出现”byte count wrong”的错误,
    如果httpd_load获取到的页面数据和上次不一致
    则会报错byte count wrong
    如果是动态页面,由于返回数据内容不同.则此报错可以忽略

    webbench

    webbench是Linux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。下载地址可以到baidu google搜,我这里给出一个
    下载地址:http://cid-9601b7b7f2063d42.skydrive.live.com/self.aspx/Public/webbench-1.5.tar.gz
    这个程序更小,解压后不到50K,呵呵
    安装非常简单
    #tar zxvf webbench-1.5.tar.gz
    #cd webbench-1.5
    #make && make install
    会在当前目录生成webbench可执行文件,直接可以使用了

    用法:

    webbench -c 并发数 -t 运行测试时间 URL
    如:
    webbench -c 5000 -t 120 http://www.askwan.com



    ab
    ab是apache自带的一款功能强大的测试工具
    安装了apache一般就自带了,
    用法可以查看它的说明

    引用
    $ ./ab
    ./ab: wrong number of arguments
    Usage: ./ab [options] [http://]hostname[:port]/path
    Options are:
    -n requests Number of requests to perform
    -c concurrency Number of multiple requests to make
    -t timelimit Seconds to max. wait for responses
    -p postfile File containing data to POST
    -T content-type Content-type header for POSTing
    -v verbosity How much troubleshooting info to print
    -w Print out results in HTML tables
    -i Use HEAD instead of GET
    -x attributes String to insert as table attributes
    -y attributes String to insert as tr attributes
    -z attributes String to insert as td or th attributes
    -C attribute Add cookie, eg. 'Apache=1234. (repeatable)
    -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
    Inserted after all normal header lines. (repeatable)
    -A attribute Add Basic WWW Authentication, the attributes
    are a colon separated username and password.
    -P attribute Add Basic Proxy Authentication, the attributes
    are a colon separated username and password.
    -X proxy:port Proxyserver and port number to use
    -V Print version number and exit
    -k Use HTTP KeepAlive feature
    -d Do not show percentiles served table.
    -S Do not show confidence estimators and warnings.
    -g filename Output collected data to gnuplot format file.
    -e filename Output CSV file with percentages served
    -h Display usage information (this message)



    参数众多,一般我们用到的是-n 和-c
    例如:
    ./ab -c 1000 -n 100 http://www.askwan.com/index.php

    这个表示同时处理1000个请求并运行100次index.php文件

  • 相关阅读:
    什么是根文件系统
    构建基本的嵌入式Linux根文件系统
    “文件系统”与“根文件系统”详解
    C#中NameValueCollection类用法详解
    别把西红柿连续种在同一块地里
    asp.net 服务器控件的 ID,ClientID,UniqueID 的区别
    不要为框架作过多的假设
    构件技术
    asp.net中控件id,clientid,uniqueid的区别
    系统架构图怎么画
  • 原文地址:https://www.cnblogs.com/isoftware/p/3726557.html
Copyright © 2020-2023  润新知