
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.
Installation
To install tsung you need Linux distributive, I am using debian.
- apt-get install erlang
- apt-get install gnuplot-nox libtemplate-perl libhtml-template-perl libhtml-template-expr-perl
- Download latest distributive - http://tsung.erlang-projects.org/dist/tsung-1.4.1.tar.gz
- tar -zxvf tsung-1.4.1 .tar.gz
- cd tsung-1.4.1
- /configure && make && make install
- also you should create .tsung folder in root and tsung.xml inside it (ypu can see tsung.xml examples in tsung folder)
Configuration tsung.xml
1. Server configuration
<servers>
<server host="example.com" port="80" type="tcp"></server>
</servers>
2.Client configuration
Very important to specify maxusers
<clients>
<client host="localhost" use_controller_vm="true" maxusers="7000"/>
</clients>
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.
<load>
<arrivalphase phase="1" duration="5" unit="minute">
<users arrivalrate="10" unit="second"/>
</arrivalphase>
<arrivalphase phase="2" duration="10" unit="minute">
<users arrivalrate="25" unit="second"/>
</arrivalphase>
</load>
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:
<sessions>
<session name='login_settings' probability='25' type='ts_http'>
<request> <http ... /> </request>
<thinktime random="true" value="4"/>
<transaction name="Login">
<request> ... </request>
...
</transaction>
<request> ... </request>
...
</session>
<session name='login_add_people' probability='75' type='ts_http'>
...
</session>
...
</sessions>
Running
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 tsung_stats.pl script which will produce a nice html report.
cd .tsung/log/yyyymmdd-HH:MM
and copy tsung_stats.pl file here or specify absolute path type perl tsung_stats.pl . This script will create in this folder reports.
Here is my example, of Simultaneous Users:

And more reports examples here
References:
The Tsung manual
Tsung home page