Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate number of users and think time for load testing

I want to know how to calculate number of users, Think time, Pacing time and number of Iteration for load testing.

Requirement is:

  • I need to achieve 10000 transaction per hour.
  • Need to do 1 hour execution.
  • Need to specify think time and pacing time

Note:

  1. My script "aircraft" contains 7 transactions.
  2. Overall Response time is 16 sec without think time.

How to calculate how many users to be given so that I can achieve 10000 transaction per hour and how much think time and Pacing time and number of Iteration I need to specify?

like image 702
keerthyramachandran Avatar asked Jan 23 '15 07:01

keerthyramachandran


1 Answers

If your only goal is to simulate a certain number of transactions in a certain time period, you can do that with quite few virtual users in the test.

If your average transaction time for 7 transactions is 16 seconds it means you can do 7/16 transactions per second, using a single virtual user.

To get 10,000 transactions in an hour you would have to use multiple concurrent virtual users.

VU = Number of virtual users
time = test time in seconds
TPS = transactions per second

VU * time * TPS = total_transactions

In this case we know total_transactions but not VU, so we rewrite it to:

total_transactions / (time * TPS) = VU

Using the numbers we have, we get:

10000 / (3600 * 7/16) = 6.3

I.e. you need more than 6 VUs to get 10k transactions in one hour. Maybe go for 10 VUs and insert some sleep time as necessary to hit the exact 10,000 transactions.

How much sleep time and how many iterations would you get then?

10 users executing at 7 transactions per 16 seconds for one hour would execute a total of 10 * 7/16 * 3600 = 15,750 transactions. We need to slow the users down a bit. We need to make sure they don't do the full 7/16 transactions per second. We can use the formula again:

VU * time * TPS = total_transactions

TPS = total_transactions / (VU *time)

TPS = 10000 / (10 * 3600)   =>  TPS = 0.2777...

We need to make sure the VUs only do 0.28 TPS, rather than 7/16 (0.44) TPS.

TPS = transactions / time

Your script does 7 transactions in 16 seconds, to get 7/16 (0.44) TPS.

To find out how much time the script needs to take, we then change it to:

time = transactions / TPS

time = 7 / 0.277778   => time = 25.2 seconds

Currently, your script takes 16 seconds, but we need it to take 25 seconds, so you need to add 9 seconds of sleep time.

So:

10 VUs, executing 7 transactions in 25 seconds, over the course of an hour, would produce 10,000 transactions:

10 * 7/25 * 3600 = 10080

The number of script iterations each VU would perform would be:

3600 / 25 = 144 iterations

To sum up:

Number of VUs: 10
Total sleep time during one iteration: 9
Iterations/VU: 144

Note that this all assumes that transaction time is constant and does not increase as a result of generating the traffic. This setup will generate close to 3 transactions per second on the target system, and if you have not tested at that frequency before, you don't know if that will slow down the target system or not.

like image 105
Ragnar Avatar answered Oct 21 '22 07:10

Ragnar