Load testing is a form of non-functional testing that is carried out to understand the behaviour of an application under a specific user load. A load test is done by simulating the real time user load on the application under test, and this determines how the application responds when multiple users hit the server simultaneously and it reveals the application’s response time, CPU and memory usage, network and bandwidth usage.
Why Load Testing?
Load testing is vital before an online store begins working on a major seasonal, advertising campaign, otherwise time, money and resources will be wasted if the system cannot cope the extra demand placed on it at times of extreme, peak use.
An online shopping site recently found this out to their cost. They announced that they would be doing an online mega-sale during the upcoming festive season and offered huge discounts for the users who were planning to purchase during this deal time. They spent plenty of money advertising this news and expected their huge customer base to come and purchase during this window. Customers noted this date on their calendar and waited eagerly for the day. The big day arrived – but the site went down and disappointingly, all the hopeful shoppers received when trying to access the site was the message: “HTTP Error 503 – Service unavailable”. The merchant lost a huge amount of money and business because of this technical error and they went on to analyse why it happened. It was revealed that their application wasn’t good enough to accept the larger than usual number of users who tried to access their website during the deal time. The server couldn’t withstand the load and it went down! On that day, they realized the importance of testing for potential load on the server. They should have run a test that would simulate a number of users that could have accessed their site during the deal time. This should have revealed how good (or poor) the load capability of the server was. Yes, loading testing is mighty important!
Load Testing in More Detail
A load test determines how well your server responds to the requests it received. It will reveal how the server behaves under different user loads. For example, how will your server respond when the load is 100k users? How about at 200k, 300k and so on? Load testing is basically a behavioural study of the server under different loads. The behaviour of the server can improve or become less efficient under different scenarios such as the following:
- New code changes
- New hardware changes/upgrades
- Newly added features to the application etc.
- Environmental changes
Load Testing Parameters
Various parameters need to monitored while load testing an application. They are:
Response time
This shows how fast the server responds to a request received. For example, if you clicked a login button, are you getting logged in quickly? Or have you been asked to wait for some time before actually being logged in? The lesser the response time, the better the performance. The unit used for measuring response time is seconds.
Throughput
This determines how many requests can be processed at a time. The more the throughput the better the performance. The measurement unit here is bytes per second.
CPU/Memory/Network/Disk utilization
This will be expressed as a percentage value showing how well CPU/Memory/Network/Disk is utilized for different loads. The lesser the percentage value the better the utilization.
User load
This is the number of concurrent users that the application can withstand. The greater the concurrent number without any abrupt failures, the more efficient the application.
Load Testing Patterns
Different load patterns can be employed for testing real time user access scenarios. Below are the main patterns:
Steady load
In this design, user load will be steadily distributed for the given time of test. For example, if the test is planned for 60 minutes, the user load will remain constant throughout the test.
Ramp up load (Step up load)
In this design, user load will be ramped up at set intervals. For example, if you are running a test for 60 minutes with a ramp up interval of 15 minutes, the user load will be increased each quarter-hour. So if the user load is 100, the load can be ramped up by 25 users every 15 minutes.
Ramp down load (Step down load):
This is the exact reverse of ramp up design. User load will be decreased at given time intervals.
Load Testing Process
In the load testing process, the first step is to make a record of the transactions. A transaction is a set of actions in a particular period of time or scenario. Modern load testing tools allow recording of transactions by using record and playback options. Once a transaction script is prepared, they can be customized by adding certain enhancements. Some common enhancements are:
Think time
Think time is the duration a real time user takes between actions. This approximate time can be specified in the script.
Correlation
At times, you will need to correlate some data to the recorded script. For example, if you are attempting to load test some transactions for a user session, the recorded session ID may not work during the playback as it might be no longer valid. So you will need to capture the new session ID from the logs in order to make playback work.
Iterations
This value refers to number of times you need to run a transaction. If iteration is set as 10 for 100 users, the transactions will be run 10 times for each of the 100 users.
Run time settings
You need to set the target browser, network type (Lan, broadband etc) etc. before start load test.
Data parametrization
If you want to load test a login scenario and test it for 100 users with 100 different login credentials, then this needs to be provided as a data set that’s part of the enhanced script.
Test Execution Phases
Test execution has two phase – before and after. They are:
Pre execution phase
- Test environment should closely resemble the production environment
- Load generator machines will have to be up and ready
- Warm up the server with a small load for a short duration
- Check and validate IP spoofing/Proxy settings
- Set up report generation settings for collating and analysing the results
Post execution phase
- Saving test results
- Exporting results and charts
- Saving test data and logs
- Analysing performance counters
Summary
As described in the “Why load testing?” section, load testing is vital in any application where page hits are frequent. As a tester, you will have to be wise about analysing and identifying critical scenarios that can degrade performance by selecting the load testing pattern, enhancing the load testing script and analysing the results.
There are many load testing tools to choose from before you can start your tests. To help find your way about, see our post on the Top Performance and Load Testing Tools can help you select the best load testing tool for your needs.