Calculating the number of Virtual Users to achieve the target load using HP Loadrunner

With Performance Center you can configure the number of virtual users for your test scenario. This blog describes how to use it with the scenario runtime length to target the test system with the required load.

Business requirements (if there are any) should state how much load the website is expected to handle. The definition of load in Loadrunner is related to this business view. Other load generator tools support the specification of a fixed Transaction per Second rate. For Loadrunner a little calculation is required to achieve target load.

Configuring the virtual user script with the number of virtual users in Performance Center

The following list attempts to summarise the connection points of the various parameters and metrics:

  • A Load Test consists of one or more user scenarios, each realised by a Loadrunner script. The user scenario models one user’s activity.
  • In Performance Center so called “virtual users” can be assigned to each of the participating user scenarios. A Virtual User emulates the user’s behaviour by replaying the actions coded in the script. You assign a number of virtual users to your scenario to achieve the planned load.
  • Each script makes requests to the system, and also replays pauses (aka. think time). This is to simulate periods without load, for example: When the user reads the content of a web page or entering data into forms, etc.
  • Post Analysis of the results will include metrics such as Transactions per Second and Hits per second.

Let’s take the following example:

  • The business requirement: The website will be subject to 100.000 users per hour.
  • Upon analysing real user behaviour it is found that  a typical user spends 15 minutes on the site, and browses 10 pages on average.
  • Lets consider each request a Loadrunner transaction

This means the implemented user scenario will contains 10 page-requests and each virtual user will run for 15 minutes.

To calculate the necessary number of users, we use the following basic formula:

number of required VUsers := required requests per seconds * user scenario length (sec)

Note:  The requests-per-second-based approach (or in our case Transactions-per-Second, as we assume 1 request=1 transaction) is an adequate approach, as Loadrunner also uses Transactions per second when displaying metrics data.

Using the above requirements the number of virtual Online Blackjack users can be calculated using the following formula:

number of required VUsers := number of site users per hour * requests per user / 3600 * user scenario length (sec)

Using the above formula:

 number of site users per hour := 100.000 users
 requests per user := 10 reqs
 user scenario length (sec) := 15 minutes * 60 seconds = 900 s
 required transactions per hour (TPH) := number of site users per hour * requests per user
 required Transactions per seconds :=  required transactions per hour (TPH) / (60 minutes * 60 seconds)
 number of required VUsers := number of site users per hour * requests per user / 3600 * user scenario length (sec)

With substitution, we calculate  that 250,000 virtual users are required to create the appropriate load.
Well. This calculation is fine, but not very efficient (read on Jason’s blog on HP Loadrunner pricing)

Notice, that in our implementation each virtual user will run for 15 minutes, but they are idle for most of the time (as each user performs 10 requests alltogether).
Here is a better solution: We know that each request is likely to be quick (let’s say quicker than 1 second). So we compact the user scenario: the script can perform the scenario in 15 seconds instead of 15 minutes. The think times can also be reduced from 1.5 minutes to about 1 seconds accordingly.

After recalculating the number of required virtual users, we find that we need only 4166 virtual users to simulate the required load. This is a significant difference!

In practice scripts are not created with lengthy think times. A 1 second think time is usually the pragmatical approach. The recorded think times of the script can be scaled down or can be limited to a configured length. The Think Time runtime settings’ “User randon percentage of recorded think time” and “Limit think time to” options control this.

After the script is created the average length of script execution should be determined. This can be done with manual execution in VUGen. (e.g. my previous article helps you to output the actual time). The measured length can be substituted into the formula to determine the required number of virtual users. Then the value can be used in the Performance Center Load test composition.

The next blog will describe how Performance Center keeps the pace and repeats the execution of the associated script.

One thought on “Calculating the number of Virtual Users to achieve the target load using HP Loadrunner

Leave a Reply

Your email address will not be published. Required fields are marked *