Saturday, 6 June 2015

Load Generation - Revisted



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:
Iteration time = (No transactions per Iteration * Vu) / TPS

time = 7 / 0.277778   => time = 25.2 seconds
Alternatively way (10000/7)= 1428/3600==>0.39 so 10=0.39*p ==> 25.2
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

Lets take an example scenario: There is an application for which current production volume for 100 concurrent users are 1M transactions per 1 hour. Also there is an estimate that in future the transaction will grow from 1M to 1.5M.  

Solution: Lets create a load runner script which has 6 transaction/ Iteration.So with the above data given , below are the possible workload model that we can design by tuning Pacing& users. 




Simple steps to calculate:
1. run the 1 user test and note down the no. transaction in the script and collect the Total TPS
2. collect the production value data like ( total no. of txn completed for hr/min/day).
3. Now use the formula to get the Vu required to meet the production volume:=> Vu=total txn/(total    tps*Duration)
4. Now increase the volume of users to calculate the additional Pacing time required. TO do this calculate the new Total TPS= Total Txn/(increased Vu* duration).
5 With the new Total TPS calculate Iteration Pacing=(no. of txn in the script)/(New Total TPS)

Example 2:
=============
for one of the banking application there are 1875 transaction observed for  an hour. Also as per the test plan 750 are active on the system.

solution:

To simulate above workload how much pacing is required.
TPS=1875/3600 =0.52

Pacing == 750/0.52 ==>24 min
which means to simulate 1875 of load with 750 users we need pacing of 1444 sec

But another challenge in simulating the load is we can't able to reach above data when we go for the slow rampup and rampdown of the users as this will mask the actual load.

The solution for this issue includes noting down the steady state txn for ex: for 1 hr  we will achieve say 1560 txn.

Diff 1875-1560==315

==>315/1875=16%

So we need to reduce hte pacing of 16% == > 1444-(16*1444/100) ==>1212sec >>20min

============================
1. Run the single uesr test and get the TPS= 7/16
2. Now get the Total TPS=10000/3600
3. now get the users
4. increase the users and pacing
5. calucate the pacing==> 10=0.39*P
===============================

No comments:

Post a Comment