tsung

1.簡介

http://tsung.erlang-projects.org/user_manual/index.html
tsung 是一個分佈式的多協議負載測試工具;
支持 HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and Jabber/XMPP 協議/服務器測試;

1.安裝

# EPEL 源
$ sudo yum install tsung

2.命令

$ tsung <options> start|stop|debug|status|view

  -f <file>     默認配置爲 ~/.tsung/tsung.xml,可以手動指定,- 表示從標準輸入中讀取;
  -l <logdir>       測試結果存放目錄,默認爲 ~/.tsung/log/YYYYMMDD-HHMM 目錄;
  -i <id>       設置 controller 的 ID,默認爲空;
  -r <command>      設置遠程連接的方式,默認爲 SSH(需要你提前配置好密鑰認證);

  -n            不開啓 web GUI,默認開啓,端口爲 8091;
  -k            測試完成後,仍然保持 web GUI 和 controller 在線;

    -s            enable erlang smp on client nodes
    -p <max>      set maximum erlang processes per vm (default is 250000)
    -X <dir>      add additional erlang load paths (multiple -X arguments allowed)
    -m <file>     write monitoring output on this file (default is tsung.log)
               (use - for standard output)
    -F            use long names (FQDN) for erlang nodes
    -L <lifetime> SSL session lifetime (600sec by default)
    -w <delay>    warmup delay (default is 1 sec)
    -x <tags>     list of requests tag to be excluded from the run (separated by comma)
    -t <min>      erlang inet listening TCP port min (default: 64000)
    -T <max>      erlang inet listening TCP port max (default: 65500)

3.HTTP配置文件

示例文件:/usr/share/doc/tsung/examples/http_simple.xml
————————————————————————————————————————————————————————————————————————————————————————————
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung dumptraffic="false" loglevel="debug" version="1.0">

  <!-- 測試端設置 -->
  <!-- weight="1":當有多個客戶端時,指定各自的權重,可以爲整數或者浮點數;
       maxusers="800":該客戶端最多擁有的用戶數,默認爲 800,可以設置大些如 30000;
                       一般來說一個進程默認能使用 1024 個句柄,該值決定了生成 vm 的數量;
       use_controller_vm="true":表示使用本程序作爲對應主機的客戶端;
                                 如果存在多個客戶端,則其他主機默認使用 SSH 來進行調用通信;
       -->
  <clients>
    <client host="domob-207.domob-inc.cn" weight="3" maxusers="800">
      <!-- 當一個主機有多個IP時,可以輪訓使用不同的IP去訪問服務器 -->
      <ip value="10.9.195.12"></ip>
      <ip value="10.9.195.13"></ip>
    </client>
    <client host="localhost" use_controller_vm="true" weight="1" use_controller_vm="true"/>
  </clients>

  <!-- 被測試端設置 -->
  <!-- weight="4":在有多個 server 時,指定各個的權重,可以爲整數或者浮點數;
       type="tcp":設置測試的服務類型,可以爲 tcp, ssl, udp, websocket;
       -->
  <servers>
    <server host="vhost1.domob-inc.cn" port="80" type="tcp" weight="4"></server>
    <server host="vhost2.domob-inc.cn" port="80" type="tcp" weight="1"></server>
  </servers>

  <!-- 被監控端 -->
  <!-- 通常和被測試端的主機相同,會檢測 cpu, network, memory;
       type="snmp":默認檢測方式爲 erlang(通信方式見 client),可選的有 snmp;
       --> 
  <monitoring>
    <monitor host="myserver" type="snmp"></monitor>
  </monitoring>

<!-- full url with server name, this overrides the "server" config value -->

<request> <http url="/" method="GET" version="1.1"></http> </request>
<request> <http url="/images/accueil1.gif" method="GET" version="1.1" if_modified_since="Fri, 14 Nov 2003 02:43:31 GMT"></http> </request>
<request> <http url="/images/accueil2.gif" method="GET" version="1.1" if_modified_since="Fri, 14 Nov 2003 02:43:31 GMT"></http> </request>
<request> <http url="/images/accueil3.gif" method="GET" version="1.1" if_modified_since="Fri, 14 Nov 2003 02:43:31 GMT"></http> </request>

<thinktime value="20" random="true"></thinktime>

<request> <http url="/index.en.html" method="GET" version="1.1" ></http> </request>



  • tsung
    dumptraffic="false" loglevel="notice" version="1.0"
  • clients
  • servers
  • monitoring
  • load
  • options
  • sessions
    由多個 session 區塊組成,每個 session 區塊可以由 tsung-recorder 命令通過設置代理來自動生成;
    注意:此時如果 URL 是 https 協議,則請用 http://- 來代替 https://

It can simulates thousands of users on a single CPU (Note: a simulated user is not always active: it can be idle during a thinktime period)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章