Sniperを使ってHttpサイトをテストします.

4575 ワード

Sniperは機能が強く、高性能なHTTP負荷ツールで、Golangで作成します.協働プロセスの同時優勢を利用して、大容量の同時、超低メモリの占用、豊富な図表の展示を実現します.テスト、分析、サービスの性能を最適化する素晴らしい助手です.
機能
  • GET/POST
  • keep-aliveモード
  • https
  • グラフの結果
  • 複数の目標をテストします.
  • は、大ファイル負荷
  • をサポートしています.
  • クロスプラットフォーム、Linux、FreeBSD、Darwin
  • をサポートします.
  • メモリ占有量は、Apache Benchmark(ab)などの主流負荷ツール
  • 以下である.
  • 実行速度はabに近く、高合併時はab
  • を超える.
  • は10 k以上の合併をサポートします.
  • は、大きなファイルテスト
  • をサポートします.
    Alt text
    使用説明
    1.Golangのインストール
    astaxieのオープンソースGolang書籍『Go Webプログラミング』を参照してください.
    2.Sniperをインストールする
    $ go get github.com/lubia/sniper
    $ go install github.com/lubia/sniper
    $ cp src/github.com/lubia/sniper/.sniperc ~
    3.パラメータの説明

    GET
    $sniper -c 10 -n 100 http://www.google.com
    POST
    $sniper -c 10 -n 100 -p postData.txt http://www.google.com
    パラメータ
    コマンドラインパラメータ
    Usage: 
       sniper [options] http[s]://hostname[:port][/path]                 http https,     ip
       sniper [options] -f urls.txt                                               ,    :  url  
    Options: 
       -c, --concurrent     concurrent users, default is 1.                 (   1)
       -n, --requests       number of requests to perform.                   
       -r, --repetitions    number of times to run the test.                 (n=c*r)
       -t, --time           testing time, 30 mean 30 seconds.                (   )
       -R, --sniperc        specify an sniperc file to get config              (   $HOME/.sniperc)
                            (default is $HOME/.sniperc).               
       -f, --urlfile        select a specific URLS file.                        url  
       -p, --post           select a specific file to POST.              POST  
       -T, --content-type   set Content-Type in request                  POST     (   text/plain)
                            (default is text/plain).
       -V, --Version        print the version number.                      sniper   
       -h, --help           print this section.                                
       -C, --config         show the current config.                                
       -s, --plot           plot detail transactions' info                   html      (   true) 
                            (true | false,default set true,              (  :  -t       ,    html)
                            notice: set -t will not plot anyhow).
    ファイルのパラメータを設定
      :   $HOME/.sniperc      ,                
           -R         ,-C       。
    [protocol]
    version = HTTP/1.1                            HTTP    ,1.1 1.0
    #connection = keep-alive                      connection  ,#       
    connection = close
    accept-encoding = gzip                        
    user-agent = golang & sniper                  
    
    [header]
    #cookie = SSID=Abh_TYcDc6YSQh-GB                    ,       
    
    [process]
    timeout = 30                                  socket     
    failures = 64                                       ,socket           
    
    [Authenticate]
    login = jeff:supersecret                      HTTP    
    
    [ssl]
    ssl-cert = /root/cert.pem                     ssl-cert    
    ssl-key = /root/key.pem                       ssl-key    
    ssl-timeout = 30                              https  
    結果出力
    グラフを現在のディレクトリに出力します.
    Transactions:                   1000 hits               
    Availability:                   100.00 %                     
    Elapsed time:                   0.15 secs           sniper    
    Document length:               1162 Bytes                    
    TotalTransfer:                  1.11 MB                   
    Transaction rate:            6625.60 trans/sec            
    Throughput:                     7.34 MB/sec             
    Successful:                     1000 hits               (     200    )
    Failed:                           0 hits                (socket     ) 
    TransactionTime:               1.495 ms(mean)              (  )
    ConnectionTime:                0.596 ms(mean)             (  ,tcp    )
    ProcessTime:                   0.900 ms(mean)              +    (TransactionTime = ConnectionTime + ProcessTime)
    StateCode:                    1000(code 200)            200   
    テストケース:
    [root@localhost bin]# pwd
    /usr/local/go/sniper/bin
    [root@localhost bin]# ./sniper -c 10 -n 100 http://202.200.82.60/WebGoat/attack