siege Web-site benchmark tool

siege

Run the benchmark siege test to simulate 50 clients accessing 10 random cached pages.

siege -b -c 50 -r 10 -i -f urls_list.txt

  • -b benchmark mode, no delay between intereation
  • -c <num> concurrent number of concurrent users
  • -r repititions - tells how many times each user should run
  • -i internet mode, read URLs from urls.txt file in random order
  • -d <seconds> delay between page request, can be 0.1
  • -m "<string>" log message to log file for this run
  • -f <file> path to file with URLs one per line unlike command line argument the URLs in the file or not quoted
    •  The file also supports UNIX-style commenting:

               # Comment looks like this

               https://www.joedog.org/

               https://www.joedog.org/haha/

               https://www.joedog.org/haha/ POST homer=simpson&marge=doestoo

    • <scheme>://<username>:<password>@<hostname>:<port>/<path> POST <query>

Example siege

$ vi urls.txt 
and add some urls like this

https://domain.com/url1
https://domain.com/url2
https://domain.com/url1/details
https://domain.com/url2/more details


$ siege -d 0.2 -f urls.txt -i -v -r 10 -c 15

HTTP/1.1 200     1.83 secs:  768707 bytes ==> GET  /static/js/bundle.js
HTTP/1.1 200     0.27 secs:     806 bytes ==> GET  /details
HTTP/1.1 200     0.27 secs:     806 bytes ==> GET  /moredetails
HTTP/1.1 200     1.64 secs:  768707 bytes ==> GET  /static/js/bundle.js
HTTP/1.1 200     1.26 secs:  768707 bytes ==> GET  /static/js/bundle.js

Transactions:                 300 hits
Availability:              100.00 %
Elapsed time:               20.84 secs
Data transferred:          110.08 MB
Response time:                0.94 secs
Transaction rate:           14.40 trans/sec
Throughput:                5.28 MB/sec
Concurrency:               13.60
Successful transactions:         300
Failed transactions:               0
Longest transaction:            2.19
Shortest transaction:            0.14

Install siege on Mac

$ brew install siege

If that gives an error "Git is unavailable" then install you need to Install Xcode Command Line Tools on a Mac first then do the brew install

$ xcode-select --install

Configuration File 

Siege supports a settings configuration file in which you can store most of your command line options. This makes it much easier to invoke siege and it helps you ensure that every run in a series of runs has the exact same settings. Where is it? The siege configuration file is called .seigerc or .seige and it is located in the home directory directory of the user who installed siege. If you did not install siege but you want to use it, then run the command “siege.config”. That will put a template .siegerc file in your home directory. You can edit the settings with your favorite editor. The .siegerc file which is generated by the siege.config utility is well documented with comments describing the directives. Those comments should be all you need to get started.

Create the configuration file in $HOME

$ vi ~/seige
$ siege.config

URL Format 

Siege understands the following URL format: [protocol://] [servername.domain.xxx] [:portnumber] [/directory/file] Currently, siege only supports http and https protocols. HTTP is the default protocol and therefore does not require a protocol specification. Frankly siege allows you to cheat. The minimum requirement is this: servername. That’s it. So if you’re in the same domain as a server named shemp and shemp is in your host file or it is in DNS, then: siege -u shemp will stress http://shemp.yourdomain.net/index.shtml ( assuming that is the server specified index ). If you want to lay siege to https servers, then it is necessary to specify the protocol. In the above example, siege -u https://shemp Will lay siege to https://shemp.yourdomain.net/index.shtml given the assumptions stated above.

The URLs File 

In order to run a regression test or an effective internet simulation, you are going to have to run through the URLs on the server you are testing. To accomplish that, place the URLs in a configuration file. The default file is SIEGE_HOME/etc/urls.txt. In that file list the URLs one per line:


# comments behind hashes
http://homer.whoohoo.com/index.shtml
http://homer.whoohoo.com/howto.jsp
http://homer.whoohoo.com/cgi-bin/hello.pl?first=bart&last=simpson
# and on and on....

Siege-2.06 and later supports both POST and GET directives. GET directives are constructed as shown above, but POST directives require the POST keyword. Construct POST directives as follows:

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

When invoked without the URL option [ -u URL | –url=URL ], siege looks for URLs in a file. It reads it into memory and runs through the URLs. Normally siege starts at the beginning of the file and works it way through it sequentially. If you specify internet mode [ -i | –internet ], then it selects URLs randomly. An alternative file can be selected at run time with the [ -f FILE | –file=FILE ] option.