Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Usage of Tsung, a high concurrency testing tool

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

The usage of Tsung, a high concurrency testing tool, is believed to be at a loss for many inexperienced people. Therefore, this paper summarizes the causes and solutions of the problem. I hope you can solve this problem through this article.

Tsung is an open source multi-protocol distributed load concurrent testing tool developed by erlang.

Can be used as a server stress test for HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP, and Jabber/XMPP.

Tsung can be distributed among multiple clients and can simulate the concurrency of thousands of virtual users.

1 download and install

Tsung has passed tests on Linux, FreeBSD and Solaris

Other systems also work on platforms that support the Erlang language (Linux, Solaris, * BSD, Win32, and Mac OS X).

Mac OS X can install tsung through Homebrew, command:

Brew install tsung

Ubuntu installation is also very simple, the command:

Apt-get install tsung

Other systems need to download the source code package before installing it. Download address of the source code package:

Http://tsung.erlang-projects.org/dist/

Take tsung 1.6.0 as an example, download the installation commands:

Wget http://tsung.erlang-projects.org/dist/tsung-1.6.0.tar.gz # take version 1.6.0 as an example tar-zxf tsung-1.6.0.tar.gz # decompress cd tsung-1.6.0 # and enter the directory. / configure # configuration Generate Makefile file make # compile make install # installation

When configure, if the Erlang language libraries that tsung depends on are not installed, the following error will be prompted:

... checking for Erlang/OTP root directory... Configure: error: in `/ root/tsung-1.6.0':configure: error: test Erlang program execution failed...

You can install erlang before configure with the following command.

Brew install erlang # OS X Homebrewport install erlang # OS X MacPortsapt-get install erlang # Ubuntu and Debianyum install erlang # Fedorapkg install erlang # FreeBSD

Other systems need to install Erlang from the source code, which is slightly more complicated, please refer to: https://github.com/erlang/otp/blob/maint/HOWTO/INSTALL.md.

2 run

After the tsung installation is complete, two command files are generated:

Tsung

Tsung-recorder

The default generation is in the / usr/local/bin directory, and all of their parameters can be found using the-h parameter:

Tsung-h

Before starting tsung, we need a configuration file in XML format against which tsung will test.

There are some sample XML configuration files in the / usr/share/doc/tsung/examples directory

Copy the HTTP test configuration file http_simple.xml to the current directory

Execute again, the command is as follows:

Cp / usr/local/share/doc/tsung/examples/http_simple.xml. / # copy the sample configuration file tsung-f http_simple.xml start # to specify the xml file and start. If not specified, ~ / .tsung/tsung.xml is used by default

This command prints out the log directory of the test until the end of the test.

3 results

After the tsung test is finished, the test result Log is saved in the directory ~ / .tsung/log/.

When you start a new test, a new subdirectory is created under this directory to hold the test data.

The Log format is a combination of the current date and time, for example: ~ / .tsung/log/20160217-0940.

By default, the control node starts an embedded web server that listens on port 8091 (which can be disabled with the-n option).

You can also use the tail command to view the real-time record during the test:

Tail-f ~ / .tsung/log/20140430-1126/tsung.log

After the test, use tsung_stats.pl to generate the report.

Yum install gnuplot # tsung_stats.pl needs to use gnuplotmkdir http_simple # to create a directory to save reports cd http_simple # enter the directory / usr/local/lib/tsung/bin/tsung_stats.pl-- stats ~ / .tsung/log/20160305-0933/tsung.log # to generate reports

After that, three directories and one log file will be generated under the http_simple directory, of which the images directory is the report image, similar to the following.

The above is only testing and has no practical use, because there is no website configured to test, so the results obtained are of no practical significance.

You need to modify the XML configuration file and then test it to get meaningful results.

4 configuration Fil

Open http_simple.xml and let's talk about a few key configurations.

4.1 clients

The way the user is generated:

The tsung runtime can consist of many virtual machines (VM), and the client configuration indicates the maximum number of users generated on this client machine.

If use_controller_vm is true, a new virtual machine will be automatically generated when the number of users reaches maxusers,tsung.

4.2 servers

The server section can configure information about the server under test, or it can be configured as a cluster, as follows

Tsung selects the server that initiates the request based on the weight value.

4.3 monitoring

System monitoring service, after configuration, you can obtain the CPU, memory, load, database and other related information of the tested server.

Can be configured as erlang monitoring service and snmp monitoring service.

4.4 load

The load of the access can be configured in the load section, and the access can be allocated into multiple stages, specified by the phase value.

Duration is the test duration and unit is the unit.

The maxnumber of the users segment limits the maximum number of users generated

Interarrival= "0.02" means that a new user is generated in 0.02 seconds, and the user executes the request in the session in the order in which the session is configured.

4.5 options Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21 Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

The options section can configure some requested information, such as agent information.

4.6 sessions

Multiple sub-session can be configured to test multiple api

Request probability can be set, which is defined in probability

It is required that the sum of probability for each session is 100, and the type is http.

You can use for in sessions to set the number of requests, as follows

You can set the specific information of the request in it.

You can include a random number in the request parameters.

Random numbers and random strings are defined as follows:

Called as% _ xxx%%.

It must be noted here that to use a random number, request must add the subst= "true" parameter, otherwise the random number cannot be referenced successfully.

Random numbers can also be read from files, such as csv.

Header parameters can be defined internally in http:

Thinktime can be used to define the interval between two requests

In addition, different transaction can be defined, so that the specific information of different transaction will be displayed in the result.

After reading the above, have you mastered how to use the high concurrency testing tool Tsung? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report