Saturday, 12 November 2011

Tsung: Web Application Performance and Stress Testing

The purpose of Tsung is to simulate users in order to test the scalability and performance of IP based client/server applications. You can use it to do load and stress testing of your servers.You can test with Tsung HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and XMPP/Jabber.

To install tsung you need Linux distributive, I am using debian.
  1. apt-get install erlang
  2. apt-get install gnuplot-nox libtemplate-perl libhtml-template-perl libhtml-template-expr-perl
  3. Download latest distributive  -
  4. tar -zxvf tsung-1.4.1 .tar.gz
  5. cd tsung-1.4.1
  6. ./configure && make && make install
  7. also you should create .tsung folder in root and tsung.xml inside it (ypu can see tsung.xml examples in tsung folder)
Thats all after typing tsung command in console, you should see tsung help information.

Configuration tsung.xml
   1. Server configuration
   <server host="" port="80" type="tcp"></server>

2.Client configuration
Very important to specify  maxusers
     <client host="localhost" use_controller_vm="true" maxusers="7000"/>

 3.Define the load that we want our server to be exposed to
Tsung simulates the user arrivals in the application. The example below describes 2 different phases.The first will last 5 minutes and every second will come 10 new users, at all 5 minute x 10 users = 3000 users. Next phase will last 10 minutes and every second will come 25 new users , 10 minutes x 25 users = 15 000 users.
<arrivalphase phase="1" duration="5" unit="minute">
<users arrivalrate="10" unit="second"/>
<arrivalphase phase="2" duration="10" unit="minute">
<users arrivalrate="25" unit="second"/>

4. Recording script
To test smth, you should provide sequence of actions, what tsung should to do. This configuration you should put in  tag <sessions> ..</sessions> tsung.xml.  I will test web-site and easiest way it's to use tsung proxy to record actions. To achieve that we must first tell our browser to pass through a proxy listening to port 8090 (Firefox preferences - Advanced - Network - Settings) and ip of the your server.

To start recording use tsung-recorder start
To stop recording use tsung-recorder stop

We will end up with an xml representing the newly recorded session located in ~/.tsung/tsung_recorderyyyymmdd-HH:MM.xml. Just copy-paste this session into the main tsung xml file:
<session name='login_settings' probability='25' type='ts_http'>
<request> <http ... /> </request>
<thinktime random="true" value="4"/>
<transaction name="Login">
<request> ... </request>
<request> ... </request>
<session name='login_add_people' probability='75' type='ts_http'>

To run Tsung tsung start and to stop tsung stop. Tsung is logging data in the ~/.tsung/log/yyyymmdd-HH:MM folder. To view status tsung status. Wery important to set ulimit value greater than default, type in console ulimit -n 100000. One time i have situation when tsung process not terminated, but tsung stop command didn't worked, in this case you could use ps ax | grep tsung to see all processes and  kill -9 <process pid>

Generating HTML report
In order to use these info, we launch the script which will produce a nice html report.
cd .tsung/log/yyyymmdd-HH:MM
and copy file here or specify absolute path type perl . This script will create in this folder reports.

Here is my example, of Simultaneous Users:

And more reports examples here

The Tsung manual 
Tsung home page
This article in Russian
Tsung presentation in Russian


  1. The below line not work for me
    /configure && make && make install

    But this work for me
    ./configure && make && sudo make install

    Thanks ..Good Artical


  2. Thanks for this straightforward and easy-to-follow post! It got me up and running on my first day using tsung :)