How to do load testing?

Planning and execution of a load test

Planning and execution of a load test requires several activities to be performed, these activities are common to every load test irrespective of the tool we use. This post will cover all of these activities in detail, giving example of the applications that we normally use.

1. Create user scenarios-

Before creating user scenarios, one needs to understand the application completely. Unlike functional test user scenarios, the load test scenarios include only the scenarios that are most likely to happen at large concurrent load or the frequency of occurrence of which is high. Taking an example of any mailing website, a functional user scenario will cover each and every aspect of that website like user registration, user log in - log out, user reading unread mails, compose mail, delete mails, creating/saving as draft, settings configuration, archive mail, manage labels, restore from trash, prioritize mail and several others.
Whereas, load test scenario will include scenario like reading unread mails, composing mails, deleting mails, user registration and some others as per client's request. The basic fact is include only the scenarios that will be performed by relatively large group of people. So, in GMail scenarios like setting configurations, manage labels, restore from trash etc will not be included unless otherwise explicitly specified by client.
PS - Don't do load test on any live application unless you are allowed to or paid to, the application owner may block your IP address and can take even severe actions. Also, the example quoted here are just for reference purpose, to make you understand the concepts, they are nowhere related to how actually there load testing was/will be done.

Mock of a user scenario(Read unread mails)-

  1. User launch the application
  2. Wait Time/Think Time
  3. User enter valid credentials and click on Login button
  4. Wait Time/Think Time
  5. User click on the links of unread mails
  6. Wait Time/Think Time
  7. Click on Log out button
  8. Wait Time/Think Time
  9. Exit the application

The wait time or think time included here is the time user takes in going through the web page once it loads, time taken to fill the forms like login form, user registration form, entering in search fields etc. This time is variable depending on the underlying step like in step 2 wait time can be 1 or 2 seconds which is an average time a user takes in filling the credentials, similarly step 4 can have a wait time of 5-6 seconds- the time taken to read mail(s). The wait time in step 8 can be removed as the time taken to exit the application after log out is negligible.

2. User Distribution-

Once the scenarios are identified and stated, the next step is user distribution. In this step, user count will be allotted to the scenarios identified. Like user reading unread mail scenario can have 50% of users, compose mail 30% users, deleting mail 15%, user registration 5%. All this means is our load test tool will make scripts simulating the user scenarios and during the load test these scenarios will be executed as per the user distribution specified e.g. for 100 user load test the user reading unread mail scenario will be made to execute concurrently for 50 users, compose mail 30 users, deleting mail 15 users and user registration 5 users.

3. Scripting-

Scripting is done with a load test tool like - Load Runner, JMeter, Silk Performer etc. Basically these tools simulate the actions performed by users. We script the scenarios identified and assign users to them as per user distribution done.
Scripting will be explained in detail using JMeter.

4. Dry run of the application-

Before actually starting the load test with predefined number of users, we do a dry run of the application assigning 1 or 2 user to each scenario and check whether every thing is working fine or not like the script is able to simulate user or not. Dry run is basically done to check the correctness the script.

5. Running a load test and analyzing the result-

Once all the scripting is done and verified, its time for actual load test. The load test can be made to execute for predefined time or defined iterations e.g. we can run a load test for 30 minutes or for 50 iterations per user. After load test, the results are analysed, most of the tools have very good inbuilt controls for results display, one may need to use plugins or other tool to include even further detailed result interpretation.

These were the activities performed during planning and execution of load test, in the next post we will start with the performance testing tool JMeter.