Topic
9 replies Latest Post - ‏2013-12-27T05:43:12Z by minim
minim
minim
27 Posts
ACCEPTED ANSWER

Pinned topic calculating time taken for a transaction

‏2013-12-16T13:01:28Z |

Hi forum,

I have a mpgw configured with skip backend, with backend as java webservices in transform action.

Now I want to calculate the total time between, a request and response in datapower. Start time is when request hits Datapower URL and  end time is when response is sent back for that request from Datapower, response coming from backend.

 I also want to capture the timestamp particluars of backend process.i.e., how much time alone my transform action is taking to hit the backend, get response and process to frontend. Is this possible.

Need your suggestions on the above two.

Thanks in advance.

 

With Regards.

 

  • pablosanchez84
    pablosanchez84
    31 Posts
    ACCEPTED ANSWER

    Re: calculating time taken for a transaction

    ‏2013-12-16T14:28:25Z  in response to minim

    There are several topics on this, so you might want to give the search feature a try.

    Anyway, this post from Hermann will give you a direction:

    https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/latency_messages_in_datapower_appliance21?lang=en

  • minim
    minim
    27 Posts
    ACCEPTED ANSWER

    Re: calculating time taken for a transaction

    ‏2013-12-23T13:23:49Z  in response to minim

    HI,

    Thanks for reply. Hermanns post is useful. Based on the post, i tried to capture below four service variables in my XSLT. But except for time-elapsed, all other 3 are coming as 0. I checked in probe and even there, i can see those values as 0. Any idea why this could be.

    Please note that I am using a dynamic backend with url:open function. There is no response rule configured as I am capturing response from url:open function in the same request rule.

    I wrote these 4 variables right after printing main response  I received, which is ideally last step of my  xslt and my transaction. Am I right here.

    • var://service/time-started
    • var://service/time-forwarded
    • var://service/time-response-complete
    • var://service/time-elapsed

    TIA.

    --Warm Regards--

    • HermannSW
      HermannSW
      4327 Posts
      ACCEPTED ANSWER

      Re: calculating time taken for a transaction

      ‏2013-12-23T13:55:39Z  in response to minim

      Hi,

      so you seem to use skip-backside.
      In that case  var://service/time-response-complete (14)  has no meaning and is 0 (no response rule).
      And  var://service/time-forwarded (5)  has no meaning because nothing gets send to backend, so value 0.

      In case yout request is not big  var://service/time-started (7)  may be 0 because parsing did not take much time.
      Sometimes (7) is 0 because of streaming or some specific protocol handler used.


      > Now I want to calculate the total time between, a request and response in datapower
      >
      Seems that you mean the <dp:url-open> response, perhaps this snippet is what you are looking for?

      <xsl:variable name="t0" select="dp:variable('var://service/time-elapsed')"/>
      <dp:url-open ...>...</dp:url-open>
      <xsl:message dp:priority="alert">
      url-open: <xsl:value-of select="dp:variable('var://service/time-elapsed') - $t0"/>
      </xsl:message>


      Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>

      Updated on 2013-12-23T13:57:22Z at 2013-12-23T13:57:22Z by HermannSW
  • minim
    minim
    27 Posts
    ACCEPTED ANSWER

    Re: calculating time taken for a transaction

    ‏2013-12-24T06:38:46Z  in response to minim

    Thanks Hermann. Explanation is very clear.

    Just for information, the above snippet gives the transaction time till the line url-open is used, but not the time it actually took for url-open to execute. I placed the time-elapsed step after dp:url and then transaction time increased. So can we assume this to be exact time taken . Please correct me if i am wrong.

    <xsl:variable name="t0" select="dp:variable('var://service/time-elapsed')"/>
    <dp:url-open>...</dp:url-open>
    <xsl:message dp:priority="alert">
    url-open: <xsl:value-of select="$t0"/>
    </xsl:message> ----> Gives 10 milliseconds

     

    <dp:url-open>...</dp:url-open><xsl:variable name="t0" select="dp:variable('var://service/time-elapsed')"/>
    <xsl:message dp:priority="alert">
    url-open: <xsl:value-of select="$t0"/>
    </xsl:message> -----> Gives 400 milliseconds

     

     

     

     

    • HermannSW
      HermannSW
      4327 Posts
      ACCEPTED ANSWER

      Re: calculating time taken for a transaction

      ‏2013-12-24T11:29:25Z  in response to minim

      Hi,

      since I did subtract $t0 from the time after <dp:url-open> the output shoule be exactly the time in milliseconds that <dp:url-open> took:

      select="dp:variable('var://service/time-elapsed') - $t0"


      Did I misunderstood what you wanted to calculate?


      Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>

      • minim
        minim
        27 Posts
        ACCEPTED ANSWER

        Re: calculating time taken for a transaction

        ‏2013-12-26T11:08:50Z  in response to HermannSW

        Thanks Hermann.

        I am the one who misunderstood there. Now I am able to extract the required time taken by my dp:url -open. Sorry for the mislead.

        But  one more query which I have regarding this transaction timings.

        In my case, If I wanted to calculate the total time for a request- response in datapower. Is that possible in DP. I think answer is no. Below is what I did. 

        In my transform action, I have total time elapsed, which gives me the time taken till that action. But logically, we cannot say a response is complete there as it travels further as transform action is not an end point. I can see in SOAP UI,  from where I am firing requests, that there is a difference of 30-40 milliseconds when compared to time-elapsed. I believe this is time taken by Datapower for further transactions after transform action.

        So if requirement is to calculate total time by Datapower, we have to calculate it from outside the box, not from inside, as it wont be accurate. Am I making correct statement here.

         

        Thanks a lot.

        --With Regards.

        • ted.jump
          ted.jump
          254 Posts
          ACCEPTED ANSWER

          Re: calculating time taken for a transaction

          ‏2013-12-26T13:58:30Z  in response to minim

          The "latency" log records have the data you are looking for (it actually has one timing entry for when the headers are transmitted to the client and a second for when the response transmission is complete), but I don't think you can get it 100% accurately from within your response rule as the actual transmission of the reply happens after your last XSLT would be executed.

          However you're still right that you can only truly know how long the E2E is, from the client's perspective, by timing at the client. The on-appliance timing can't include latency induced by transmission time to DP initially, and from DP on the response. On a WAN or via the internet those could be significant quantities.

        • HermannSW
          HermannSW
          4327 Posts
          ACCEPTED ANSWER

          Re: calculating time taken for a transaction

          ‏2013-12-26T19:09:51Z  in response to minim

          > So if requirement is to calculate total time by Datapower, we have to calculate it from outside the box, not from inside,
          > as it wont be accurate. Am I making correct statement here.
          >

          I would say yes.

          The only "issue" you might face from measuring on client side is network latency.
          So for measuring the pure request/response processing time your client should be "close" to the DataPower box.
          If that is not possible, you may access the real service through a passthru XML FW or MPGW on same box.
          Then the difference of timestamps (8)-(5) of passthru latency record will give you processing time of back service.
          From
          https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/latency_messages_in_datapower_appliance21

          5 entire request transmitted
          8 response headers received

           

          Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>
           

           

          • minim
            minim
            27 Posts
            ACCEPTED ANSWER

            Re: calculating time taken for a transaction

            ‏2013-12-27T05:43:12Z  in response to HermannSW

            Yes, logically also, we cant calculate a response time before actual completion of response in any tool. Having a intermediate passthru is a better idea in this case which captures time taken for a particular call.

            Thanks Ted, Hermann for your suggestions. 

            --With Regards.

            Updated on 2013-12-27T05:50:31Z at 2013-12-27T05:50:31Z by minim