Pylotで負荷テストしてみる
負荷テストは、今までabでしかしたこと無かったけどpython製の負荷テストツール「pylot」というのがあったので試してみた。かなりイイ感じなので紹介
ダウンロード
http://www.pylot.org/
公式ページからダウンロードできる。5/22現在のバージョンは1.24
機能
* HTTP and HTTPS (SSL) support
* multi-threaded load generator
* automatic cookie handling
* response verification with regular expressions
* execution/monitoring console
* real-time stats
* results reports with graphs
* custom timers
* GUI mode
* shell/console modes
* cross-platform
と言うことらしい、GUIが有るらしい。使えなかったけど・・・
中身
. |-- __init__.py |-- core | |-- LICENSE.txt | |-- __init__.py | |-- __init__.pyc | |-- config.py | |-- config.pyc | |-- corestats.py | |-- corestats.pyc | |-- engine.py | |-- engine.pyc | |-- graph.py | |-- graph.pyc | |-- reportwriter.py | |-- reportwriter.pyc | |-- results.py | |-- results.pyc | |-- xmlparse.py | `-- xmlparse.pyc |-- results | |-- results_2009.05.23_21.40.27 | | `-- agent_stats.csv | |-- results_2009.05.23_21.41.07 | | `-- agent_stats.csv | `-- results_2009.05.23_21.42.14 | |-- agent_1.log | |-- agent_10.log | |-- agent_2.log | |-- agent_3.log | |-- agent_4.log | |-- agent_5.log | |-- agent_6.log | |-- agent_7.log | |-- agent_8.log | |-- agent_9.log | |-- agent_detail.dat | |-- agent_stats.csv | |-- results.html | `-- workload_detail.dat |-- run.py |-- scripts | `-- pylot_win_recorder.py |-- testcases.xml |-- ui | |-- __init__.py | |-- __init__.pyc | |-- blocking | | |-- __init__.py | | `-- pylot_blocking.py | |-- console | | |-- __init__.py | | |-- __init__.pyc | | |-- pylot_console.py | | |-- pylot_console.pyc | | `-- win | | |-- README.txt | | |-- __init__.py | | |-- _consolepos25.cpp | | |-- _consolepos25.pyd | | |-- _consolepos26.cpp | | |-- _consolepos26.pyd | | `-- cpos.py | `-- gui | |-- __init__.py | |-- __init__.pyc | |-- icon.ico | |-- wx_gui.py | `-- wx_gui.pyc `-- util |-- __init__.py |-- __init__.pyc |-- optionparse.py `-- optionparse.pyc 12 directories, 61 files
と言う状況です。ルートのrun.pyを叩くだけで動く。
どこにどのようなリクエストをするかは、デフォルトではtestcases.xmlに定義されている。
サンプルのxmlには
<testcases> <!-- SAMPLE TEST CASE --> <case> <url>http://www.example.com</url> </case> <!-- SAMPLE TEST CASE --> <!-- <case> <url>http://search.yahooapis.com/WebSearchService/V1/webSearch</url> <method>POST</method> <body><![CDATA[appid=YahooDemo&query=pylot]]></body> <add_header>Content-type: application/x-www-form-urlencoded</add_header> </case> --> </testcases>
結果
実行結果はresulutディレクトリに保存される。キレイに整形されたhtmlも出来る。
------------------------------------------------- Test parameters: number of agents: 10 test duration in seconds: 60 rampup in seconds: 0 interval in milliseconds: 0 test case xml: testcases.xml log messages : True Started agent 10 All agents running... [################100%##################] 60s/60s Requests: 38 Errors: 0 Avg Response Time: 9.475 Avg Throughput: 0.635 Current Throughput: 02 Bytes Received: 16644 ------------------------------------------------- Generating Results... Generating Graphs... Matplotlib ImportError: No module named pylab ERROR: Unable to generate graphs with Matplotlib Done generating results. You can view your test at: results/results_2009.05.23_21.42.14/results.html
あとで、さくらのDjangoとGAEでテストしてみようと思う。