How Tsung works
(1) Every virtual user of Tsung is an Erlang Lightweight Process. This is quite different from LoadRunner.
(2) the virtual user disappears after completing the session.
(3) A large number of virtual users (Erlang Lightweight Process) are built on erlangvm.
(4) One test machine can start multiple erlangvms. Currently, one erlangvm is started based on one CPU.
During the distributed deployment of Tsung, ssl_esock, beam, and beam are generated. for smp3 processes, SSL-esock is the port program used by erlangvm to assist in completing the SSH function. beam is a single-processor version of erlangvm; beam. SMP is the control program responsible for coordinating system operations.
######################################## ############################ 3
Recently I used Tsung, a so-called Erlang stress testing tool that "overwhelmed n servers. Here, record the journal account.
Install
Get Tsung source code
Wget http://www.process-one.net/downloads/tsung/1.2.2/tsung-1.2.2.tar.gz; tar-zxvf tsung-1.2.2.tar.gz
Or
SVN Co http://svn.process-one.net/tsung/trunk
Ensure dependency
Tsung depends on these things Erlang (nonsense, from the source code to compile the program written by Erlang, can it not be installed?) gnuplot perl5 (if you want to see the graph in the report, you need to install this ), install them one by one.
Apt-Get install Erlang-Src gnuplot perl5
Compile and install
./Configure
Make
Sudo make install
After the installation is complete, the Tsung script runs in/usr/bin/Tsung. In the system path, you can run the script directly.
Set
Copy one or two examples from/usr/share/doc/Tsung/examples ~ /. Tsung/Tsung. XML is used as the configuration file. I only need HTTP testing, so:
CP/usr/share/doc/Tsung/examples/http_simple.xml ~ /. Tsung/Tsung. xml
Tsung uses a clever proxy method to "record" the test script. Specifically, a local HTTP proxy is created and port 8090 is used by default. After Firefox uses localhost 8090 as the proxy (foxyproxy plug-in is recommended ), all HTTP actions that "flow" through the proxy will be recorded,During testing, you can "play back" these steps to generate requests.
Tsung rocorder
Tsf-stop_recorder
After "Recording" is complete, you will get ~ /. Tsung/tsung_recorderxxxxxxxxxx.xml file. This is the script for playback during testing.
Add the script to Tsung. xml.
Gedit ~ /. Tsung/Tsung. xml
Just like this
<! Doctypetsungsystem "/usr/share/Tsung/tsung-1.0.dtd"
[
<! Entitymysession1system "/home/yourname/. Tsung/tsung_recorderxxxxxxxxxx.xml">
]>
...
<Sessions>
& Mysession1;
</Sessions>
Slightly adjust the configuration
<Monitoring>
<Monitorhost = "localhost" type = "Erlang"> </monitor>
</Monitoring>
<! -- You need to configure SSH Logon (SSH via rsa_key) to localhost without a password. With this configuration enabled, you can obtain the CPU and RAM consumption of the target machine. -->
<Load>
<Arrivalphasephase = "1" Duration = "1" unit = "Minute">
<Usersinterarrival = "2" unit = "second"> </users>
</Arrivalphase>
</Load>
<! -- 1 minute in stage 1st (you can perform several more stages on your own). When you create a new user every 2 seconds, each user executes the test script of the session, and the maximum concurrency is about 30, I personally think this "gradual pressurization" method is slower than AB XXXX's "Sudden pressurization", but more scientific -->
Run
Ready for pressurized operation.
Tshortstart
After running, go ~ The/. Tsung/log directory will generate a directory named after time and enter this directory.
Cd ~ /. Tsung/log/XXXXX
/Usr/lib/Tsung/bin/tsung_stats.pl
Generate an HTML stress test report
Firefox report.html
Enjoy it slowly.
In addition to HTTP, Tsung can also press a lot of things, such as jabber and PostgreSQL [Legend: MySQL is more extensive]. You can also write plug-ins to pressurize anything you want to test, the configuration file is also "rich and colorful". For more information, see the document.
Enter the test Log Path, for example,/home/iamlaobie/. Tsung/log/20110528-testing.
Several similar concepts in the report:
Request: request the corresponding time of a URL address using the PHP function file_get_contents.
Page: the total time of a group of requests with no interval. It is equivalent to opening a page. Besides loading HTML of the page, it also loads IMG, CSS, JS, etc.
Session: the total time from the first request to the end of the last request.
5. Others
5.1. Tsung-recorder can be used to record the user's access process and play back the process with Tsung to make the stress test more realistic. In fact, recorder is an HTTP proxy. After you start recorder, point the browser proxy to it. The default port is 8090. You only need to use a browser to browse the tested server, tsung-recorder writes the process to the configuration file.
5.2 add request variables. During stress testing, variables such as the mobile phone number, user ID, and stock code may be required. Tsung supports random File Reading, you can write these parameters to a file according to certain rules and define the read rules in the configuration file to get the file content during the request. Define a file service:
<Options>
<Option name = "file_server" id = "file1" value = "/tmp/x.txt"/>
</Options>
Read, add in the session segment
<Setdynvars sourcetype = "file" fileid = "file1" delimiter = ";" Order = "random">
<Var name = "username"/>
</Setdynvars>
<Request>
<Http url = "/B. php? Username = % _ username % "method =" get "version =" 1.1 "> </HTTP>
</Request>
In addition to reading files, you can also randomly generate
<Setdynvars sourcetype = "random_string" length = "13">
<Var name = "rndstring1"/>
</Setdynvars>
<Setdynvars sourcetype = "random_number" Start = "3" End = "32">
<Var name = "rndint"/>
</Setdynvars>
QPS
QPS query per second (QPS) QPS is a measure of the traffic processed by a specific query server within a specified time. On the internet, the performance of machines serving as Domain Name System servers is often measured by the query rate per second. Corresponding to fetches/sec, that is, the number of response requests per second, that is, the maximum throughput.
Reference URL:
Http://blog.csdn.net/bxc168/article/details/6020683
Http://wwwzhouhui.iteye.com/blog/451298