Few parameters needs to be considered before you start the
performance test and think time is among those. In most of the cases, it has been
overlooked and passed as random number based on the preconceived notion of the
employees associated with that particular organization.
What is think time?
Think Time is the time that the real user waits between actions or transactions. Let's say, the user has performed a search operation, and the corresponding results are displayed in the application, so now the user needs to perform another action and the time taken by the real user to think and implement the action is termed as the think time.
Where to add Think time?
Let’s assume, If you are placing think time on each and
every request – This approach is not realistic as the virtual user is not imitating
the real user behavior. If a user performs a search operation, so there will be
multiple requests executed at the back end so adding think times to all those
requests corresponding to a single user action is certainly not a good
approach, it will look something like:
Think time should not be added at the request level, Indeed
it must be added at the user action or transaction level
Does think time affects TPS?
The answer is Yes, think time is one of the parameter’s that
will impact the Transactions per second, Let’s see how..
Let’s consider the following three scenario’s
Scenario 1 : 900 users with 30 seconds of think time
Scenario 2 : 900 users with 15 seconds of think time
Scenario 3: 900 users with 10 seconds of think time
And here you go with the little’s law:-
Users = Arrival Rate * (Response time + Think Time)
So, if you want to find the Arrival rate (alias TPS)
Arrival Rate
= Users / (Response Time + Think Time)
Assuming, 5
seconds as an average response times
Scenario 1: Arrival rate = 900/(5+30) = 25.71 hits/sec
Scenario 2: Arrival rate = 900/(5+15) = 45 hits/sec
Scenario 3: Arrival rate = 900/(5+10) = 60 hits/sec
So, It’s pretty clear that think time plays a vital role in
affecting the TPS.
TT = (D – R)/T
TT = think time per transaction
D = Expected time taken by the real user to complete E2E
scenario
R = Response time of the script with single user for E2E
scenario
T = Total number of transactions within the script
Let's consider a scenario for better understanding
Expected time to complete the scenario by real user (D) = 30
seconds
Time taken by virtual user to perform E2E scenario (R) = 5
seconds
Total number of transactions within the script (T)= 5
So, TT = (30-5)/5
Think time = 5 seconds
You can also validate the above calculation by the below technique:
Think time for a single transaction = 5 seconds
Think time for five transactions = 5 * 5 = 25 seconds
(Consider)
Time taken by virtual user to perform e2e scenario = 5
seconds (Consider)
Therefore, a virtual user took 30 seconds to perform the
entire scenario similar like a real user.
If you are going to use a constant think time it will act like as robotic timer and will not match like a real user, so it is advisable to take +/-
10% of the calculated think time. A good practice can be to consider a random
think time considering minimum and maximum think time.
You can use the below
formula’s for the calculation.
Minimum think time = 0.9 X TT
Maximum think time = 1.1 X TT
Stay tuned for more posts!!!