详细理解TPS

Loadrunner: Understanding Transaction Per Second (TPS)

Transaction per second (TPS) is the number of transactions executed per second. In other words, it can be calculated based on how many transactions are executed over certain duration of the test and then calculate it for a second.

For example, if a vuser executes 6 transactions every minute, then the TPS would be 6 transactions/60 sec = 0.10 TPS

There’s an important fact hidden in the above example. It also tells us that if the vuser is able to complete 6 transactions in 60 seconds that means response time for each transaction is 10 sec. i.e.

0.10 transactions –> 1 second

1 transaction –> 10 seconds

Little’s law

Before going into details of formula derived by little’s law, it is important to understand how response time and pacing are related because these are the key factors that control your TPS if the number of vusers are kept constant.

As we know pacing is inter-iteration gap i.e. it is the pause a vuser takes before executing next iteration. And hence it also helps to control the rate of iterations i.e. rate of transactions i.e. TPS.

Remember, Pacing always overrides Response time when it comes to determining TPS

In the examples below, let’s assume that the vuser’s action() contains only one transaction. In following examples, you may find that the terms ‘transaction’ and ‘iteration’ are used interchangeably. That is just because the action contains only one transaction. Thus one transaction will be fired when one iteration of the action is completed.

Example1:  Let’s say that we have set Pacing to zero and Think Time to zero.

A vuser performs 5 transactions and response time for each transaction is 10 seconds. Then it will take 5*10 = 50 seconds to complete 5 transactions. i.e. 5/50 = 0.1 TPS.Here, you can see that TPS is controlled by response time.

Example 1

Example2:  Let’s say that we have set pacing to 15 sec and Think Time to zero.

A vuser performs 5 transactions and response time for each transaction is 10 seconds. But the fact that now pacing is greater than response times, it will override the response times and it will control the transaction rate.  Thence it will take 5*15 = 75 seconds to complete 5 iterations.  i.e. 5/75 = 0.06667 TPS [This is the most correct way of setting up your test scenario to simulate consistent TPS load on the system under test.]

Example 2

In the second example, as long as the average response times are less than 15 seconds, it will always take 75 seconds to complete 5 iterations i.e. generate 0.06667 TPS

In both the above examples, we also assumed that think time was set to Zero. If, say, it was 2 seconds, total time taken to complete 5 transactions would still be 5*15 = 75 seconds i.e. generate (5/75) = 0.06667 TPS

Response time plus Think time

Once you understand this concept, rest understanding of Little’s law is easy.

If pacing is set to zero, then

Number of vusers = TPS * (Response Time + Think Time)

If pacing is ≠ zero and pacing > (response time + Think Time) , then the above formula would look like this

Number of vusers = TPS * (Pacing)

The fact that TPS is a rate of transactions w.r.t. time, it is also called as throughput.

So Little’s law is

Average number of users in the system = average response time * throughput

N  =  ( R + Z )  *  X

Where, N = Number of users

R = average response time (now you know, it can be pacing too)

Z = Think Time

X = Throughput (i.e. TPS)

Example, If N = 100, R = 2 sec, 100= (2+Z)*X and hence –> If Z=18, X = 5

NOTE: Please do let me know if you see any flaws in the above theory.

[Update on 30-03-2014]:  Many readers asked me a question about why I am confusing transactions with iterations in all the examples given in this post. Well, as stated somewhere in the explanation, I have made an assumption that the vuser’s Action() contains only one transaction in it. This may help beginners to understand the concept. So the code in script will look like

vuser_action()
{
  lr_start_transaction("LR_01_ViewFullPost");
  web_submit_data("ViewPost.aspx", 
    "Action=http://www.performancengineer.com/ViewPost.aspx?SID={sSID}", 
    "Method=POST", 
    "RecContentType=text/html", 
    "Referer=http://www.performancengineer.com/ViewPost.aspx?SID={sSID}",
    "Snapshot=t1.inf", 
    "Mode=HTTP",  
    ITEMDATA, 
    "Name=SID", "Value={aSID}", ENDITEM, 
    "Name=__VIEWSTATE", "Value={Viewstate_1}", ENDITEM, 
    "Name=ctl00$DefaultContent$txtDescription", "Value=ok", ENDITEM, 
    "Name=ctl00$DefaultContent$txtAmount", "Value=1", ENDITEM, 
    "Name=ctl00$DefaultContent$btnViewPostNow", "Value=Submit", ENDITEM, 
    "Name=__EVENTVALIDATION", "Value={Eventvalidation_1}", ENDITEM,  
    LAST);
  lr_end_transaction("LR_01_ViewFullPost", LR_AUTO);
  lr_think_time(lr_eval_string({pThinkTime}));
}

猜你喜欢

转载自angelguo.iteye.com/blog/2325511
TPS