Get Knowledge from Video instead of Content:

Thursday, 23 February 2017

Why Pacing and Think Time are so important in Performance Testing?

Think Time and Pacing
Think Time and Pacing are two basic terms used in Performance Testing. Both are used to control the transaction rate during a load test, but having significantly different roles. Many times people are confused between these two terms. Below I have written simple one-liner definition for both which makes people understand Think Time and Pacing more easily.
Think Time: The Time between two transactions
Pacing: The Time between two iterations
In case of most performance testing tools, adding think time values and pacing values come in handy. Think time allows the virtual user (user thread) to pause in the business flow while moving from one business transaction to another. This takes into the account the time a real user might wait (think) while moving to the next transaction of the site. Similarly, pacing allows the user to wait after one business flow cycle completion. Most testers ignore the testing functionality and allow the user sessions to be spaced after one another almost instantaneously. This is not the best approach to follow since there is always some time gap between two sessions by the same user in the production environment.

Why Think Time?
Think time is used to create a real-world scenario. As I explained above it allows the virtual user (user thread) to pause in the business flow while moving from one business transaction to another. A user will never log in, search, place order, payment and log out within few seconds. Definitely, he will require some time to think and do next action. An average think time could be 5-10 seconds for a normal user. Hence this situation we try to simulate in load test using Think Time.
If there are 200 concurrent users and all logged in at the same time that makes 400Mb of memory in use. What about 400 users? 800Mb, but what if your max memory (heap) was only 512Mb? You would have got an out of memory error and found a problem with your system. If you did not use think time, then you would not have found this issue and it would have only be seen in Production

Why Pacing?
Pacing is used to regulate the rate of requests hitting to the server. Using Pacing, you can accurately achieve the desired load against your system instead of just mindlessly hammering it. Correct pacing will give you the exact load handling capacity of a server.

One Liner Tip: 
Pacing achieves Load while Think Time achieves Concurrency



Example: Let’s understand think time and pacing with an example: If you have a requirement like below:
No. of users = 6
No. of Transactions = 5
End to End Response Time = 25 seconds
TPS (Transaction per second) = 0.5

Test Start
Iteration 1
Transaction 1 (Home Page)- 3 seconds
Think Time  - 5 seconds
Transaction 2 (Log-in) - 4 seconds
Think Time  - 5 seconds
Transaction 3 (Search) - 10 seconds
Think Time  - 5 seconds
Transaction 4 (Add To Cart) - 5 seconds
Think Time  - 5 seconds
Transaction 5 (Log-out) - 3 seconds
Pacing  - 15 Seconds
Iteration 2
Transaction 1 (Home Page)- 3 seconds
Think Time  - 5 seconds
Transaction 2 (Log-in) - 4 seconds
Think Time  - 5 seconds
Transaction 3 (Search) - 10 seconds
Think Time  - 5 seconds
Transaction 4 (Add To Cart) - 5 seconds
Think Time  - 5 seconds
Transaction 5 (Log-out) - 3 seconds
Pacing  - 15 Seconds
Iteration 3
Transaction 1 (Home Page)- 3 seconds
Think Time  - 5 seconds
Transaction 2 (Log-in) - 4 seconds
Think Time  - 5 seconds
Transaction 3 (Search) - 10 seconds
Think Time  - 5 seconds
Transaction 4 (Add To Cart) - 5 seconds
Think Time  - 5 seconds
Transaction 5 (Log-out) - 3 seconds
Pacing  - 15 Seconds
.
.
.
.
Iteration N
Transaction 1 (Home Page)- 3 seconds
Think Time  - 5 seconds
Transaction 2 (Log-in) - 4 seconds
Think Time  - 5 seconds
Transaction 3 (Search) - 10 seconds
Think Time  - 5 seconds
Transaction 4 (Add To Cart) - 5 seconds
Think Time  - 5 seconds
Transaction 5 (Log-out) - 3 seconds
Test End

How Think Time and Pacing can be calculated?


What are the options available for Think Time and Pacing? 

Think Time: There are five options available for Think time settings in HP LoadRunner:

  • Ignore think time
  • Replay think time
  • Multiply Recorded think time by
  • Use random percentage of recorded think time
  • Limit think time to
Below is JMeter’s Timer list used for Think Time:
  • Constant Timer
  • Gaussian Random Timer
  • Uniform Random Timer
  • Constant Throughput Timer
  • Synchronizing Timer
  • BeanShell Timer
  • BSF Timer (DEPRECATED)
  • JSR223 Timer
  • Poisson Random Timer
To get descriptive details on above options, please click here

Pacing: There are three options available for Pacing settings in HP LoadRunner:
  • Start new iteration as soon as the previous iteration ends
  • Start new iteration after the previous iteration ends, with fixed/random delay of XX seconds
  • Start new iteration at fixed/random intervals, every XX seconds
To get descriptive details on above options, please click here

Enjoy Learning! 👍 

Related Topic:

16 comments :

  1. Hi

    Is there any component using in jmeter for stimulate pacing?

    ReplyDelete
    Replies
    1. Hi Rathina,

      There is no specific component for inserting pace time in the JMeter script. You have to use either "Timer" or "Test Action" sampler to simulate pacing.

      Delete
    2. Hi Gagandeep,
      i am using timer for think time and but i don't have idea about Test action.Let me check if i can use it for pacing. Thanks for update.

      Delete
    3. Hi, there is a plugin in jmeter "Stepping thread.." which has to be installed, to set the pacing.

      Delete
  2. HI,

    One question. Can pacing and think time be replaced?

    ReplyDelete
    Replies
    1. Please clarify your question. Are you aksing

      1. Can pacing be replaced by think time?

      or

      2. Can pacing and think time be replaced by any other component?

      or

      3. Can pacing or think time be replaced by programming logic?

      Delete
  3. Hi,

    Why can't we use think time instead of pacing at the end of iteration??

    Thanks.

    ReplyDelete
    Replies
    1. Hi Saleem,

      You can use think time (at the end of "Action") which can work as a pacing. But do remember that would be constant or random pacing according to your think time setting.

      Let's assume you need to set pacing like this which should not be calculated based on the execution time (overall response time). Then how could you achieve it. Since HP LoadRunner has given such option in pacing, so you can easily use it.

      Summary: You can use think time as a pacing for certain cases only, not all.

      Delete
  4. I am not getting below part mentioned by you:

    If there are 200 concurrent users and all logged in at the same time that makes 400Mb of memory in use. What about 400 users? 800Mb, but what if your max memory (heap) was only 512Mb? You would have got an out of memory error and found a problem with your system. If you did not use think time, then you would not have found this issue and it would have only be seen in Production

    Can u pls explain in brief?

    ReplyDelete
    Replies
    1. It is an example of achieving user concurrency on the server and find out the capacity of the server to handle the number of concurrent users. When you use think time then a user session lasts for a long time (real scenario) and the system will accommodate the connections as per its capacity and you can find out the capacity of the system to handle number of concurrent users at a time. This is the only case when you place Login and Logout in the "Action" part.

      If you do not use think time then the iteration will end-up soon (which is not a realistic scenario) and connections are available for other users. Hence you can not find out the true performance of the application.

      Delete
    2. Ok.. Thanks..

      And what is the difference between the load and concurrency.. when u say that "Pacing achieves Load while Think Time achieves Concurrency"

      How?

      Delete
    3. Think time is used to keep a user active, so that maximum concurrency can be achieved. Pacing is used to control the active user count (load). The more is pacing the less the active user load on the server.

      Delete
  5. Great job.. very good explanation..easy to understand for beginners

    ReplyDelete
  6. Hi Gagan,

    Could you please clarify to me, if i get a requirement, 100 iteration should be complete in an hour for Payment module and it includes 5 transaction. And my other scripts lets say add-to-card is also having some common transaction enclosed with lr_start and lr_end transaction function, then how i would be writting those common transaction in script because if i run these two script(payment and add-to-card) in controller results will overlap.

    ReplyDelete
    Replies
    1. Hi Amit,

      Add the prefix in the transaction name. Like:

      1. Payment_Login, Payment_Search, Payment_AddToCart
      2. ATC_Login, ATC_Search, ATC_AddToCart

      Delete