What to test, how to test it and what to think about when load testing or stress testing your web servers.
Testing a web server is very different from testing a web application. When your testing the requests per second and throughput capacity of your webservers you want to elimate external factors, like:
These operations are interactive, dynamic content. They typically are generated by a language like PHP, and often require a SQL database interaction. These are the common bottlenecks in a modern web application. Web load testing is focused on that. For this guide we are focusing on testing the raw requests per second your webserver delivers (Nginx, Apache, etc).
Break your approach up into a couple of steps. Our advice is to follow a testing path like so
We advise you run these tests separately, so you can easily compare the difference in throughput as you change file size, content type, etc.
LoadForge gives you the opportunity to design tests to suit your needs, like we've described above. We'll use LoadForge in this example, but uou could also use another tool.
We can now write our LoadForge test, which we will execute against our webservers we've defined above. We'll start by defining just the basics - the website to run it against, and that we'll start with 10,000 simultaneous users on 3 servers. We'll also drop our wait time down to a more aggressive 1-3 seconds.
As you can see above that is defined very easily. The next step is where we can customize, defining the locustfile. We'll show you our complete one, and then break it down:
from locust import HttpUser, task, between class QuickstartUser(HttpUser): wait_time = between(1, 3) @task(1) def index_page(self): self.client.get("/robots.txt")
Let's break this down, it's quite similar to our default template, and if you want advanced uses check out our documentation.
As you can see we've defined wait_time as between(1, 3) - between 1 and 3 seconds as discussed above. Next we have the index_page test, which is fetching simply /robots.txt
You can change that in the follow up test to be an image file, or stylesheet, etc. We can launch these tests and collect the results.
In specific with a webserver load test you want the highest number of requests per second you can get, with zero errors.
Interpreting the results of your test are as important as running the test, if not more. Continue this on our reading load test results guide.