Forum Discussion

buksy_12596's avatar
buksy_12596
Icon for Nimbostratus rankNimbostratus
May 16, 2007

Calculating Latency

Hi All

 

 

I am new to BIG-Ip and IRules, we have a F5 load balancer and I want to calculate the user latency of a HTTP request to a Virtual Server?

 

 

Is there any way i can use a IRULE to do this or.. Is there any other direct functionality that is given by F5 load balancer

 

 

I would really appreciate if someone can advice me on this..

 

 

Thanks

 

Buksy

5 Replies

  • Latency is something that really can only be measured on the client. Once the data gets to the BIG-IP until it leaves it, there is a lot of control, but the latency most often comes from the time it takes the client application (browser, etc) to reach the BIG-IP.

     

     

    Off the top of my head, you could build a page with some javascript that adds the current time to the request when the request is made. Then build an iRule that just replays the request content back in a response along with some javascript to take that original time and subtract it from the current time that the response page is rendered. Not super accurate as the processing speed of the client machine could play on how fast the javascript is interpreted and executed.

     

     

    Let me know if you were looking for more data than just the time to/from the BIG-IP. I've posted a tech tip on calculating the server application response time that may be useful

     

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=66

     

    Click here

     

     

     

    Heck, sounds like a fun little tech tip. If you don't have time to tackle this, I'll see what I can come up with...

     

     

    -Joe
  • Joe

     

     

    Thank you, i think your link supplied me what I am looking for. Actually I want to check the time taken by the server end.

     

     

    I need one more clarification.. This may sound bit odd :-), if I write soemthing like this

     

     

     

    when CLIENT_ACCEPTED {

     

    set tcp_start_time [clock clicks -milliseconds]

     

    }

     

    when HTTP_REQUEST {

     

    set http_request_time [clock clicks -milliseconds]

     

    }

     

    when HTTP_RESPONSE {

     

    set http_response_time [ clock clicks -milliseconds ]

     

    }

     

    when CLIENT_CLOSED {

     

    set tcp_end_time [ clock clicks -milliseconds ]

     

    log local0. "HTTP request/response difference: $http_response_time - $http_request_time = [expr $http_response_time - $http_request_time]"

     

    log local0. "Total connection time: $tcp_end_time - $tcp_start_time = [expr ($tcp_end_time - $tcp_start_time)]"

     

    }

     

     

     

     

    would BIG-IP run different instences of IRULE for each connection it gets..

     

     

    If BIG-IP get multiple simultanious connection whouke there me multiple instences of the IRULE over those connections..

     

     

    Thanks

     

    Gihan
  • you would probably want to log the http request turnaround time in the response event. Like you surmised, if there are more than one connection request within the client session, you'll only get the response time of the last request.

     

     

    If you wanted to get really fancy, you could log the timestamps of each request within a session in an array and when the client closed, log the min/max/avg response time. This might not be that helpful without having an idea of content length, but this should give you a start.
  • The iRule is processed for each connection and variables created are connection specific meaning each connection has it's own table of variables that gets cleaned up with the connection closes.

     

     

    I'm a bit confused why you are including the CLIENT_ACCEPTED and CLIENT_CLOSED events here. If it's an HTTP connection that is using a KeepAlive connection, then multiple HTTP requests can be made across the same connection but from what you said, you are concerned with the time it takes for each request to go to/from the backend server. If this is the case, then you can just track on all HTTP request/responses, not across the entire connection.

     

     

    From what I can see, you can take the iRule I posed in the above referenced Tech Tip and deploy it. It will give you the total requests along with the total request time from which you can derive the time per request to/from the server.

     

     

    Maybe I'm missing something...

     

     

    -Joe
  •  

    You are right what I need is something like this

     

     

     

     

    when HTTP_REQUEST {

     

    set http_request_time [clock clicks -milliseconds]

     

    }

     

    when HTTP_RESPONSE {

     

    set http_response_time [ clock clicks -milliseconds ]

     

    log local0.info "Time to response = [expr $http_response_time - $http_request_time]"

     

    }

     

     

     

     

    Thanks

     

    Buksy