When developing the web applications, you want to be sure that your production is ready to handle the success and the traffic, that’s why load testing and stress testing are important to ensure a web app is performant and scalable.
There are plenty of Load testing solutions nowadays, both commercial and free, so you can consider what is the best for your project at this point of time. Load testing is not always a part of CI/CD pipeline and is typically initiated for seasonal events such as tax filing, summer sales, Black Friday, Christmas, etc. Therefore many projects choose free solutions which doesn’t put additional load on the finances, while putting the load on tested web applications :)
In this article I want to share my approach to distributed testing, using Apache JMeter , Docker and Azure container instances. I prefer this setup because you can create a high load in a relatively short amount of time, for relatively low price, with a relatively low effort.
All right, all right, I know you already think: “Oh come on! Get to the point, you bloody ******* !”. The whole idea is not new and in a nutshell looks like this:
Distributed testing with JMeter and Azure Container Instances
JMeter Controller instance is sending the test and the necessary instructions to JMeter servers which are creating the load on our website under test. To have this setup up and running we build two Docker images with JMeter in Non-Gui mode — JMeter controller image and JMeter server image. Then we run controller in one container instance and spin up as many server(worker) instances as we need. To make it easier for controller to access worker nodes they are placed in the same vnet and subnet. Because we need some place to persist our test file, logs and test reports we mount Azure File Share as volume into our containers. When our infrastructure in populated, Controller node is giving command to the Worker nodes and they start putting the load on our web application. After the tests are executed, report is stored in our file share.
For a demo purposes I have deployed a simple Asp.net core app with register and login functionality and ran the tests from 6 workers, where each worker was adding a load of 40 users in a 10 seconds period. Because my test is visiting a few pages, this resulted in 10k requests at a peak load. It is also interesting to see how the response time was changing.
After the tests are executed, logs and test report is stored in our Azure File Share and will be looking somewhat like this.
Report can be downloaded using Azure Storage Explorer or we can add a download command in the end of our script (I was a little lazy in the end). There are also a lot of possibilities to adjust/upgrade the reports with different JMeter plugins\addons. JMeter community is really good and helpful.
To automate the whole process I have prepared Docker files and a PowerShell script that is running Azure CLI commands. This script is provisioning all the infrastructure and then runs the tests. Since it is running Azure CLI commands it can be easily converted into other shell scripts if necessary —I used PowerShell because I am working on Windows at the moment. I will list below the main steps taken in the script:
#azure #technology #programming
A simple way to perform load and performance testing in Azure using JMeter and Azure Container Instances.