Tsung: Web Application Load Testing

Tsung is a distributed load testing system written in Erlang. Declared support for HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and XMPP / Jabber. In this article I will describe how to test a normal web site for load.
Why tsung
First off, this app is free. Secondly, the application is written in Erlang, which gives it an advantage over other products in the ability to simulate a huge number of simultaneous requests.
Installation
For installation, you need a Linux distribution, I used debian. The following sequence of actions must be done:
- apt-get install erlang
- apt-get install gnuplot-nox libtemplate-perl libhtml-template-perl libhtml-template-expr-perl
- Download the latest version of tsung-1.4.1.tar.gz
- Unzip tar -zxvf tsung-1.4.1 .tar.gz
- Install ./configure && make && make install
- It is also necessary to create a directory with the name .tsung in the root directory and the tsung.xml configuration file inside it (more about it below)
That's all the installation is complete!
Customization
All settings are stored in the xml file tsung.xml. First of all, you need to specify the server under test, as follows:
Further, the address of the emulated client, for large-scale tests it is recommended to change the maxusers threshold:
And the most interesting, the desired load. Tsung simulates visits to users. The following example illustrates 2 phases. The first one lasts 5 minutes and every second the site is visited by 10 new users, for a total of 5 minutes x 10 users / sec = 3000 users. The second phase increases the load even more and lasts 10 minutes, 25 users come in every second, in total 15 000 users.
Instead of arrivalrate, you can also use
in this case, the user will come every 2 seconds. The next stage is most important, it is the creation of a sequence of actions that the simulated user, the so-called session, will do. In order to test the site’s capabilities to the fullest extent possible, you need to try so that users constantly do something, that is, do not stand idle.
...
....
Automatic session generation
A session can be created manually, but there is an easier way - use tsung's proxy to record your actions on the site. To do this, you just need to register in the settings of your browser the ip server where tsung and port 8090 are installed. Next, you need to run the tsung-recorder start command to wander around the site, emulate the behavior of an ordinary visitor. To stop recording tsung-recorder stop . After that, the generated sequence will appear in ~ / .tsung / tsung_recorderyyyymmdd-HH: MM.xml. Next, you just need to copy this session to the main tsung.xml file.
Launch
Finally, when all the preparatory steps have been done, you can start our test. To do this, enter the tsung start command , to stop tsung stop, respectively . Tsung will write log to the ~ / .tsung / log / yyyymmdd-HH: MM directory. A very important point in large-scale tests is to set the ulimit value before starting to run above the standard in my case 1024, ulimit -n 100000 . To view the status of the number of users on the site, you can use the tsung status command . The generated log is placed in the .tsung / log / yyyymmdd-HH: MM directory .
Report and Chart Generation
To generate reports, a perl script is used that comes with the program - tsung_stats.pl. The script must be run from the directory with the log, perl tsung_stats.pl command . After that a wonderful html report and diagrams are generated.
Tsung provides statistics:
- Performance: response time, join time, transactions, requests per second
- Errors: statistics on returned errors
- Server Behavior: CPU and memory utilization graph of network. SNMP
Here is an example of one of the diagrams (the number of users on the site, and the number of generated users):

More diagrams on the developer site
Sources:
Tsung Guide