📜 ⬆️ ⬇️

Siege - a utility for load testing web servers

I hope that this material will be useful to someone.

Siege is a utility for load testing web servers. It was created in order to give developers the opportunity to test the resource intensity of their code in conditions as close as possible to real ones. Siege can also mimic multiple users accessing a site at once. This allows you to keep the server as if “under siege” for a long time. The number of requests made during the "siege" is calculated from the total number of users and the number of their requests to the server. For example, 20 users, appealing 50 times, create a total of 1000 requests. The result displayed by the program after testing includes the time spent on the check, the total amount of information transmitted (including headers), the average response time of the server, its bandwidth and the number of requests for which the answer came with a code of 200. This data is generated and issued at each verification. These are described in detail below. Siege has 3 main models of work - regression testing mode, Internet simulation mode and brute force mode. The program reads a portion of the links from the configuration file and accesses them in turn (regression testing mode) or by accident (internet simulation). Or the user can specify a single address to which all calls will be made - brute force mode.

UPD: thanks for the pluses, transferred to the thematic blog.

Launch parameters
The launch format for Siege is as follows: “siege options”. The program can take the following parameters:
')
'-V'
'–Version'
Displays the current version.

'-h'
'–Help'
Displays help.

'-C'
'–Config'
Shows the current configuration. Siege reads the settings and displays their contents. You can change them by editing the $ HOME / .siegerc file. If you do not have such a file, you should run the siege.config utility, which will generate it

'-v'
'–Verbose'
Detailed information output. If this option is enabled, Siege will display detailed information about all calls to the server. It includes the HTTP protocol type, the response code and the address of the request. Example:

HTTP / 1.1 200 OK: /cgi-bin/whoohoo.cgi?first=Homer&last=simpson

This option is especially useful in the case of regression testing or imitation of the Internet, when a program contacts a wide range of addresses.

'-g URL'
'–Get URL'
Makes an appeal to the specified link. Receives headers from the server and displays them on the screen. A great tool for spot testing.

'-c NUM'
'–Concurrent = NUM'
The number of simulated users. The option allows testing the web server with the number of simultaneous users specified in the NUM. In fact, this number is limited only by computer resources, but in practice, for a good result, you only need to simulate a couple of hundred user sessions. Remember that with any configuration you still do not simulate the behavior of real people. If only because they linger on each page, reading the information, and do not enumerate the links one by one.

'-i'
'–Internet'
This option is used with a configuration file containing many links. When it is turned on, Siege randomly selects the addresses of requests and makes requests to them. In reality, you cannot tell users which pages and in what sequence they should go. They will always do this in different ways. Internet simulation mode attempts to emulate this behavior. Please note that during the testing process some addresses from the file may not be accessed at all because they are randomly selected.

'-t NUMm'
'–Time = NUMm'
The time over which must be tested. It is specified in the “NUMm” format, where NUM is the number of time units, and “m” is the modifier S, M, or H for seconds, minutes, and hours, respectively. For example, in order to run the test for an hour, you can use the following combinations: -t3600S, -t60M, -t1H. The modifier is not case sensitive, but there must be no spaces between it and the number.

'-f FILE'
'–File = FILE'
Configuration file containing links (SIEGE_HOME / etc / urls.txt). You can use this option to specify a different path to it. For example:

siege –file = serverb.txt

'- l'
'–Log'
This option tells Siege that it should record all information in the SIEGE_HOME / var / siege.log log file. With each new testing file will be added.

'- m MESSAGE'
'–Mark = MESSAGE'
This option allows you to specify an expression that will be separated records of different tests in the log file. It is not necessary to use the -l option with it, since it will be turned on automatically. If the expression in MESSAGE contains spaces, do not forget to put it in quotes.

'-d NUM'
'–Delay = NUM'
This option indicates the delay between calls from the simulated users to the server. The delay time is calculated from one to the entered number. When testing in resource-intensive areas of the application, it is desirable to set a delay equal to a second (-d1). By default, the delay is from 1 second to 3. This option allows you to cover the server with waves of requests.

Configuration file
Starting from version 2.00, Siege supports configuration files in which you can store frequently used commands. This can help with a lot of testing with almost the same settings. This file is called .seigerc and is located in the home directory of the user who installed Siege. If this file is not there (for example, you did not install the program), you can use the siege.config utility to create it. Inside the file are various directives with comments to them. Editing You can carry out using any text editor.

URL format
Siege understands the following link format:

[protocol: //] [server.domain.xxx] [: port] [/ directory / file]

Only addresses with HTTP and HTTPS protocols are supported. The minimum you need to specify is the name of the server. If you are inside a domain and are testing a server named shemp, and it is registered in your hosts file or on the local DNS, then the command
“Siege -u shemp” will call the address shemp.domain.net / index.shtml . If you want Siege to work with the https server, then you need to specify an additional protocol. Thus, the command “siege -u shemp ” will force the program to contact the address shemp.yourdomain.net/index.shtml .

File with links
Before you run a regression test or simulate the Internet, you need to pass the list of addresses to be checked to the program. To do this, put them in the file SIEGE_HOME / etc / urls.txt. In it addresses should be located one per line:

homer.whoohoo.com/howto.jsp
homer.whoohoo.com/index.jsp
homer.whoohoo.com/cgi-bin/hello.pl?first=bart&last=simpson
etc.

Siege-2.06 and later versions support POST and GET directives. GET directive is used by default and it is not necessary to specify it. But for a POST request, the directive should be specified. Example:

homer.whoohoo.com/cgi-bin/hello.pl POST name = homer
homer.whoohoo.com/haha.jsp POST word = doh! & scope = ALL

When you run a program without the [-u URL | --url = URL], it takes addresses from this particular file. In normal mode, the Siege starts from the beginning of the file and gradually addresses all the addresses. If you selected the Internet simulation mode [-i | --internet], then addresses are randomly accessed. You can specify a different path to the file with links through the [-f FILE | --file = FILE].

Variables
Starting with release 2.57, Siege supports declaring variables in a .siegerc file and in files with links (urls.txt). Siege variable declaration syntax is similar to UNIX shell syntax. They are declared one per line in the format “varname = value”
The name of the variable is placed inside the $ () or $ {} construct. You can use them for example to quickly switch between two protocols of checked links:

PROT = https: //
$ (PROT) eos.joedog.org/siege/index.php
$ (PROT) eos.joedog.org/wacky/index.php
$ (PROT) eos.joedog.org/scout/index.php
$ (PROT) eos.joedog.org/libping/index.php
$ (PROT) eos.joedog.org/gunner/index.php

In this example, in order to change the protocol of all links, you need to change just one line.

Log file
When Siege starts with the logging option [-l / - log] enabled, the program logs all output information to PREFIX / var / siege.log, where PREFIX is the Siege installation directory (see the INSTALL file). Everything that is displayed by the program on the screen in standard mode is written to the log file. Information when recording is separated by commas for quick import into other formats.
To separate the results of different checks there is an option -m “text” / - mark = ”text”. It places the specified message in the log file before starting the scan so that you can quickly find its result. For example, if you are testing links using the http and https protocols, you can leave notes like “start HTTPS testing” in the logs. If you use the -m / –mark option, the -l / –log option is not required.

Research statistics
Statistics generated by the program include the total testing time, the total amount of data transferred (including headers), the average response time of the server, its throughput and the number of hits to which the server responded with code 200. The report itself is generated by the Lincoln Stein script torture .pl. Here is an example of a Siege report:

Ben: $ siege -u shemp.whoohoo.com/Admin.jsp -d1 -r10 -c25
..Siege 2.65 2006/05/11 23:42:16
..Preparing 25 concurrent users for battle.
The server is now under siege ... done
Transactions: 250 hits
Elapsed time: 14.67 secs
Data transferred: 448000 bytes
Response time: 0.43 secs
Transaction rate: 17.04 trans / sec
Throughput: 30538.51 bytes / sec
Concurrency: 7.38
Status code 200: 250
Successful transactions: 250
Failed transactions: 0


Here:
Transactions - the number of calls to the server. In the example, this number is calculated from 25 users [-c25] who launched 10 hits each [-r10], which totals 250.
Elapsed time - the total duration of the test. It is calculated starting from the first call to the server and ending with the response to the last request. In the example, the test took 14.67 seconds.
Data transferred is the total amount of data transferred by all simulated users. It includes both request bodies and their headers.
Response time - the average time for which the server managed to respond to the client.
Transaction rate - the average number of requests that the server managed to process per second. It is obtained by dividing the total number of requests by the elapsed time.
Throughput - the average number of data transmitted every second from the server to users.
Concurrency - the number of simultaneous connections at which the server responds without delays.
Successful transactions - the number of requests for which the server responded with a code less than 400.

Platforms
The multi-stream Siege was built and successfully tested on the following platforms:

* AIX (powerpc-ibm-aix4.2.1.0). Siege was compiled and successfully tested using the “IBM C for AIX” compiler version 5.
* GNU / Linux (i [56] 86-pc-linux-gnu). Siege was developed on SuSE GNU / Linux with gcc.
* HP-UX (hppa2.0w-hp-hpux11.00) Siege was compiled on this platform using “HP ANSI C compiler” and gcc.
* Solaris (sparc-sun-solaris2. [678]) Siege loves this platform. It was normally compiled on it using gcc.
* Microsoft Windows (pc-i686-cygwin) Siege was ported to Cygwin Funkman. All Siege versions after 1.5 work fine on it.

The authors
Jeffrey Fulmer - Designed and implemented Siege as webmaster at Armstrong World Industries.
License Information
For complete license information, see the COPYING file. All rights reserved by Jeffrey Fulmer. Everyone is allowed to make and distribute copies of this document without any changes. Allowed to change this document and distribute its modified versions only in case of indication of changed places.

Translated by Kuzya

Source: https://habr.com/ru/post/65128/


All Articles