News
Seven days of Black Friday madness — great deal from Serverspace!
Serverspace Black Friday
VB
August 17, 2022
Updated June 7, 2023

Webserver Load testing

Ubuntu Web server

Why should you use tests

When website is rolls up from development environment to production, much real visitors generates server load and website performance may be different then you expect. To predict website behaviour you should simulate real loading on your test server.

Testing aims

The most important parameters of website working is:

  • Latency - the time from user request to the server response;
  • Server performance margin - the number of simultaneous requests server can handle. In case server is overloaded, user requests to the website will be places in the queue or even discards;
  • Stability - how many requests are handled with predictable quality. This is so-called "percentile". E.g. 20 milliseconds first-byte-response 90th percentile (good work) means 90% of user requests will be "answered" in 20ms or less.

Before testing

Before run the tests you should ensure that your server has enough system resources to handle all requests. Common "metrics" is available system memory and CPU loading. To check available RAM you can use built-in utility named free. Just run simple command:

free -m

pic1

In most uses cases server should has at least 25% free RAM, without swapping.

Situation with CPU loading will describe other built-in utility. Please run it to check:

top

pic2

System load average shouldn't excess 1*CPU cores quantity. E.g. if load average of 8-cores CPU excess 8.00 - you're in trouble.

Load simulation

To simulate real visitors you can use a few tools. Look at description below:

  • ab. 

This tool allow you to make much simultaneous connections to the webserver. Just run:

ab -c <NUMBER_OF_SIMULTANEOUS_REQUESTS> -n <NUMBER_OF_TOTAL_REQUESTS> <WEBSITE_URL>

pic3

  • siege.

This is very similar with previous console tool. To install it just run package manager:

apt install siege

pic4

Then use the tool:

siege -t <TESTING_TIME> -c <NUMBER_OF_SIMULTANEOUS_REQUESTS> <WEBSITE_URL>

pic5

  • locust

Other utility for testing is locust. It is test utility with web-interface. To install it please run:

pip3 install locust

pic6

Then download config file, edit it by your needs and run test:

wget https://raw.githubusercontent.com/locustio/locust/master/examples/browse_docs_test.py
sed 's|https://docs.locust.io/en/latest|<YOUR_DOMAIN>|g' browse_docs_test.py
locust -f browse_docs_test.py

pic7

Then you can open URL http://<YOUR_SERVER_IP>:8089 to see test results

pic8

Summary

In this article we described how to simulate production load on your server to test website.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 3
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.