【小(xiǎo)編推薦】壓力測試工(gōng)具Sieg'≠e-Web

2014-07-02   |&↑ ★∏nbsp;  發布者:梁國(guó)芳₹α   |  ∑♥ 查看(kàn):3320次

php
 Siege是(shì)我所用(yòng)過的(de)一(yī)款不(bù)<→₹♥錯(cuò)的(de)網站(zhàn)壓力測試工(gōng)具,它可(k'©™↑ě)以非常容易地(dì)定制(zhì)并發訪問(wèn)人(rén)數±↑ σ(shù)以及并發時(shí)間(jiān),安裝、使用(&£✘•yòng)也(yě)非常方便,當然它是(shì)在Linux環境下(xià‍≥♦←)使用(yòng)的(de),下(xià)面來(lái)對♣®±ε(duì)它作(zuò)一(yī)個(gè)£↓₽♦介紹。

 

官方網址:http://www.joedog.org/

下(xià)載網址:ftp://ftp.joedog.org/pub/,進入到(dào)ftp://ftp.joedog.org/pub/siege/下(xià)載最新版:

siege-2.70.tar.gz。

安裝解壓:tar zxvf siege- ​φ2.70.tar.gz,進入到(dào)解壓後的(de)目錄:siege-≥α‍☆2.70,運行(xíng)命令:

./configure

make

make install

安裝完畢後如(rú)果有(yǒu)錯(cuò)誤,則按照(zhào↔≠€)提示信息處理(lǐ)即可(kě)

輸入:siege –help,如(rú)果安裝沒問(wèn)<✔≤題會(huì)出現(xiàn)以下(xià★≠)類似信息:

SIEGE 2.70

Usage: siege [options]

siege [options] URL

siege -g URL

Options:

-V, –version   &n☆‍bsp;   ♠™'&    VERSION, prints '​±♠the version number.

-h, –help  &•&¶nbsp;    π↓;     &¥✔nbsp; HELP, prints this section.

-C, –config  δ      →✘;    &nΩβ§<bsp;  CONFIGURATION, show t♦←he current config.

-v, –verbose   ₽δε→;    &nbs βεp;   VERBOSE, ←∏φprints notification to screen  .

-g, –get →      &↓→♦nbsp;   ​​×     GET, p&₽™βull down HTTP headers and display ¶→γthe

transaction. Great for §λ application debugging.

-c, –concurrent=NUM&nγ±bsp;   CONCURRENT users,  &σdefault is 10

-i, –internet ₩☆©;   &nbs&≠σ©p;     INT∏™&ERNET user simulation, hits U÷'RLs randomly.

-b, –benchmark  &nbs←★®p;      B<≠ENCHMARK: no delays betw★φeen requests.

-t, –time=NUMm  π₽       TI•↔♣MED testing where “m” is modifie$λr S, M, or H

ex: –time=1H, oneγ×£ hour test.

-r, –reps=NUM   ♥×;      ♦→♥→; REPS, number of times to run th≠π↔e test.

-f, –file=FILE &nbs •×p;      ≈∑ FILE, select a specific URLS FILE.

-R, –rc=FILE >∑¶    &nbs≈₩λ±p;     RC, ↔€α specify an siegerc fileλφ♥₹

-l, –log[=FILE] &nb  sp;   &n✘♥≠✔bsp;  LOG to FILE. If FILE is not ∑∏₩×specified, the

default is used: PREFIX/var/si₩✔ ♥ege.log

-m, –mark=&rdqu® πo;text”   &​"≤    MARK, mark  ↔σ≤the log file with a string.

-d, –delay=NUM   &ε×®nbsp;     Time λ↓DELAY, random delay befor∏≈$"e each requst

between 1 and NUM. (NO∏↕¶☆T COUNTED IN STATS)

-H, –header=”text”&nb≈"Ωsp;    Add a heφ§ader to request (can be many)

-A, –user-agent€♣=”text” Sets User-Ag£★<ent in request

Copyright (C) 2010 by Jeffrey ↕∞Fulmer, et al.

This is free software; see th"♥ e source for copying conditions.

There is NO warranty; not even f∞πor MERCHANTABILITY or FITNESS

FOR A PARTICULAR PURPOSE.

上(shàng)面也(yě)是(shì)運行(xíng)的(de) ∑×一(yī)些(xiē)參數(shù),右邊是(shì)對(duì)一±"γ≥(yī)些(xiē)參數(shù)的(de)解釋說(shuō λ)明(míng)

比如(rú):

–C :查看(kàn)siege當前的(de)配置λ♠Ω₹信息

–V:版權說(shuō)明(★>± míng)信息

–c:并行(xíng)啓動(訪問(π↔×wèn))用(yòng)戶數(shù),默認是(shì)10

-t:壓力測試時(shí)間(jiān),比如(rú±♦)-t5表示持續時(shí)間(jiān)是δ✔(shì)5分(fēn)鐘(zhōng)

-r:每個(gè)連接發出的(de)請(qǐng)求數(shù)量>≠,這(zhè)個(gè)與t有(yǒu)♥ ↓φ些(xiē)類似,所以設置了(le)這(z∞∏hè)個(gè)值就(jiù)不(bù)需要(yào)設置t了(le)♦φ♣,反之亦然。

-f:對(duì)應一(yī)個(gè)文(wén)件(jiàn),這(zh∞€₹è)個(gè)文(wén)件(jiàn)裡(lǐ)每一(yī)行(₩ππxíng)為(wèi)一(yī)個(gè)URL鏈接,格式如(rú ≤¶):

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/201 ₽§σ0/12/14/2806/

好(hǎo)了(le),主要(yào)的(de)一(yī)些(x÷↑€§iē)參數(shù)說(shuō)明(míng)就(≈∏ ÷jiù)介紹這(zhè)麽多(duō),其餘的(de)可(kě)以參€±考上(shàng)面的(de)英文(wén)。

使用(yòng):

1、  啓動100個(gè)用(yòng)戶(線程)在5分(f÷✔ēn)鐘(zhōng)內(nèi)對(d★↓>uì)某一(yī)頁面www.zihou.me進行(xíng)并 ≈發訪問(wèn)

siege http://www.zihou.me -c200 -tδ★'δ5

2、  對(duì)多(duō)個(gè)頁面進行(xíσδ♠ng)并發訪問(wèn)

新建一(yī)個(gè)文(wén)件(jiàn)urlφ✔s,裡(lǐ)面的(de)內(nèi)容為(wèi)(<‌↔隻是(shì)例子(zǐ),任何url都(dōu)可(kě)以):

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821β↕/

http://www.zihou.me/2010/12/14/28$©✔06/

siege -f urls -c200 -t5

表示啓動200個(gè)用(yòng)戶在5分(fē¥φ☆n)鐘(zhōng)內(nèi)并發訪問(wè↑™©÷n)以上(shàng)的(de)url網址。

并發測試完畢後,會(huì)打印出一(yī)些(xiēεε)結果信息:

Lifting the server siege…&n♦§bsp;  &nbsλ∏p;  done.

Transactions: &nbsΩ'↕p;    &nbs×<εp;   &☆‍nbsp;    &nb∑ $✘sp;   7555 hits

Availability:    ←φ↔β    &n€πbsp;   <×↕    πφβ  99.47 %

Elapsed time:   &nb₹☆§δsp;    ×λ÷     &nb$β  sp;   299.§•α♥92 secs

Data transferred:  &σ☆±•nbsp;    •∞™;       ☆≥99.17 MB

Response time:    &✔&↕✘nbsp;   ♥&    <∑¶>;      7.30₹​♠ secs

Transaction rate:&nb¥♥sp;    &nb•πsp;   ≈Ω;   &nbsσ♣​p; 25.19 trans/sec

Throughput:    ♣±<↔;    &nbs₩'"p;     &nb​<≤sp;      0↓α£.33 MB/sec

Concurrency:    &nb♦σsp;   &nbs₩πp;   &nbs•γ∞ p;     18 ↕≤3.84

Successful transactions:  &nδ bsp;     7555

Failed transactions:&nbs↓∏ ‌p;     σβ;     &nbs ₹‍p;  40

Longest transaction:  ¶←λβ;     &nbs¶¥p;   17.94

Shortest transaction:&n♥Ω₽bsp;     &"£nbsp;    0.02

如(rú)果在并發的(de)過程中,被訪問(wè∏→n)的(de)頁面打開(kāi)出錯(cuò)或及其緩慢(≥α¶"màn),表示在當前并發條件(jiàn)下(xià)β$,被訪問(wèn)網站(zhàn)是(shì)不(→&≈bù)能(néng)承受的(de),也(₽✔€yě)就(jiù)是(shì)抗并發能(néng)力弱φΩ₹↕。

另外(wài),在并發的(de)過程中最好(hǎo)÷₹φ∑通(tōng)過top命令來(lái)查看(kàn)CPU和(hé)Memor♦ y的(de)占用(yòng)情況。