Best Practices for Load Testing
Load testing is a critical phase in testing of a software product. All products or applications that will endure large scale activity should undergo load testing as it provides a clear understanding of their capabilities and limits.
Each product is unique and different in their own way. However, there are several good practices that can be followed across all applications while running load tests.
An application will allow several business scenarios and transactions. However, not all scenarios can be deemed as important for load and performance testing. For example - An online shopping portal is expecting 100 visitors per hour and out of these visitors, 10 users are expected to buy a product and complete the purchase. In this particular case, the login process should be prioritized for testing as it is certain that it will experience higher user traffic than the payment process.
The performance of an application is mostly related to the nature of transactions executed by the users. Development teams generally have a sense of potential breakpoints of the applications. It would be a worthwhile effort for the testing teams and development teams to collaborate while prioritizing scenarios for testing.
Use Real Life Test Data
Functional testing generally requires minimal data. Load testing on the other hand typically requires a huge amount of test data due to to the larger data sets. Testers try to get around this problem by creating data using random text appended with date, time or some random numbers just in order to make the test data unique. For example - Say that you need to pass name as a parameter for a particular load test scenario and the test name pass is “abc3456788”. As expected, this name will not return any results. During test execution, even though the API is hitting the server, a NIL response will be received. It is important to note that the load implication caused by NIL response is going to be different compared to an actual response with results. There are numerous libraries available to help you generate test data in the pattern you want. A good example is Faker library in Python.
Auth Based Login
Most of the applications have auth integrated with the application. While testing auth, you need to make sure that each user request is sent out with a unique Auth token. If 1000 users are logging in at the same time, the application will create 1000 unique Auth tokens. Many a times, for the ease of execution, testers use a single Auth request to handle any number of requests. This needs to be avoided as the process of validating Auth itself can be resource hungry especially under significant loads.
Incremental load testing
Always start the test with a minimal load set. Many a times we overestimate the capability of an application and start the tests with a much higher load set than what the application can handle. Keep incrementing the load gradually, that too based on the results of the previous tests. I always start a test with 5 or 10 users and continue in the pattern of 25, 50, 100, 200, 500 users.
#Users Vs Hatch Rate
It is very important to understand hatch rate of an application, i.e. the number of users simultaneously performing the operation per second. Your application may be able to support say 1000 users at a hatch rate of 1 user / second. But it may break even with 50 users at a hatch rate of 5 users/second. Just like how we incrementally test with user count increasing, also ensure test by increasing the hatch rate of users.