Performance & Load Testing

Resources Center

How to calculate the number of Virtual Users required while testing an app?

by Swaraj Gupta

Performance testers, depend on the business teams to give the idea about the concurrent user load required for the application to be tested. If only, life would be that easy. In most scenarios, the information regarding the number of concurrent users (and the steady state time for those) is not available with the business teams. Translating the information of real time user load into simulated load is tricky. Also the performance test environments are scaled down as compared to that with the production. In such situations, the business expects the performance test team to come up with the information regarding the number of users to test and the duration of the test and here comes an article that can help you with that.

 

Let’s assume some basic items while simplifying this task –

  • An application can have multiple modules (or functionalities) and each of those can be realized using AgileLoad scripts.
  • While testing the app the virtual users perform all the transactions as are available in the script to complete all the steps required for the module.
  • Not all virtual users will execute each of the functionalities
  • Scripts are recorded in such a fashion that while replaying, they will send a request to the server and response received would be read by the controller.
  • Think time is added into the scripts to emulate the pauses (or time that he thinks for) that a user has when he moves from one page to another. Change in thinktime can have a direct impact on the number of transactions load (and thus the load) on the application.
  • Post test execution counters like hits / sec, number of users / unit time or transactions / sec can give an idea about the load subjected on the application.
  • One request made by a user can be considered as one AgileLoad transaction.

Let’s look at the formula that we will use to calculate the number of users –

Number of virtual users = Length of user scenario (in sec) * Number of requests per second required

To further understand, let’s consider an example. -> Peak load on an application is 10 users per hour and each user on an average spends 10 mins on the website and goes through 10 web pages. This means the implemented user scenario will contains 10 page-requests and each virtual user will run for 10 minutes.

The above formula in such cases gets modified to:

Number of virtual users = Number of users per hour * Number of requests per user * 3600 / [Length of user scenario (in sec)]

Here:

  • Number of users per hour = 10
  • Number of requests per user = 10 (number of web pages he accesses)
  • Length of user scenario = 10 min * 60 = 600 sec

Hence using above formula:

Number of virtual users = 10 * 10 * 3600 / 600 = 600

Hence the above formula gives a user count of 600 users. However a noticeable point is in an hour a user runs for only 10 mins and is inactive for most of the time. Moreover tool licensing are planned in such a way that more the number of concurrent users you require, more is the cost of license. Thus we need a better way of calculating the required load in such a way that the production load is met without increasing the cost of the tool (and thus the test). Instead of keeping the users idle for 50 mins out of 1 hour of the test, if same user is made to perform the task of multiple users and thus create load without impacting the load, the concurrent vuser load required can be substantially reduced.

Eg. In above scenario, if after 10 mins, a virtual user is made to make multiple iterations and thus make 6 iterations in an hour the number of concurrent users required (for the performance test) can be substantially reduced to 100 vusers.

This user load can be further reduced by reducing the thinktime and thus increasing the transaction load (per unit time). However it is not the best approach since it doesn’t help to create the accurate production like scenario and is coupled with multiple issues. Here is why this reducing think time approach should not be followed -(See our article  Number of Virtual Users – An unavoidable parameter while designing performance tests )

Thus on an average the above formula provides a pretty good way to calculate the user load and design the test. Do give it a try and post your comments on the experience.

This post is also available in: French


About Swaraj Gupta

Swaraj is a performance, automation and functional test expert who has worked on variety of desktop and mobile applications. The major areas that he focuses on are - functionality, usability, performance and consistency of application behavior. He manages the entire performance testing cycle of the projects that he is responsible for and works on multiple such engagements simultaneously. He has worked in variety of different business domains that include - Hi tech consulting, Financial services, management consulting, auditing services, e commerce, e learning, etcT

Learn more about QTest
AgileLoad.com
Agile Software Security


More Blog