Forum Discussion

Magnum_IP's avatar
Magnum_IP
Icon for Nimbostratus rankNimbostratus
Jul 26, 2011

Trouble calculating web page load time

I have been posed a problem to log the load time for requested web pages.

 

 

I am quite far down the line but have hit a problem.

 

 

I thought the iRule would be fairly easy to write - a combnation of CLIENT_ACCEPTED, HTTP_REQUEST, HTTP_RESPONSE, CLIENT_CLOSED events and some timers. The thing I have learned through testing my iRule though is that browsers initiate several TCP connections triggering several CLIENT_ACCEPTED events to fulfil a request and I can't think of a way to tie these together to get the complete load time.

 

 

I'm sure it can be done I'm all out of ideas.

 

 

Looking for inspiration.

 

 

fergu5
  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    Ask the browser... There's extensions in some browsers (Chrome and Safari IIRC do this) that will allow the detection and (Accurate and consistent) reporting of page load times.

     

     

    Failing that use firebug on firefox, or httpwatch... But without a lot of help from the browser itself, you have NO idea how long it takes a browser to load a page. (Because you need to consider rendering time, and take into account the fact that you'll have multiple connections as you've found out and that also connections are left open for 'a while' after they've been finished with.

     

     

    H
  • I agree with Hamish. I use HTTPWatch all the time, but if you want something to compare it to from the BIG-IP Perspective this iRule will track the TCP Connection (Start / Finish and provide Session Timing), as well as each HTTP Request and Response (with Request Timing).

     
    when CLIENT_ACCEPTED {
    Get time for start of TCP Connection in milliseconds
    set tcp_start_time [clock clicks -milliseconds]
    
    Log the start of a new HTTP Request
    set local0. "(TCP Connection - Start) [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port]"
    }
    when HTTP_REQUEST {
    Get time for start of HTTP Request in milliseconds
    set http_request_time [clock clicks -milliseconds]
    
    Log the start of new HTTP Request with URI
    set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::uri]"
    
    Log the start of new HTTP Request without URI
    set LogString "Client [IP::client_addr]:[TCP::client_port]"
    
    log local0. "(HTTP - Request) $LogString"
    }
    when HTTP_RESPONSE {
    Recieved the response headers from the server.  Log the pool name, IP and port, status and time delta
    Detailed Log Output - Client Communication - Pool Information - Status Messages - and Communication Delta
    log local0. "(Response) $LogString - pool info: [LB::server] - status: [HTTP::status] (Request / Response Delta:  [expr {[clock clicks -milliseconds] - $http_request_time}]ms)"
    
    Response and Communication Delta
    log local0. "(HTTP - Response) $LogString - (Request / Response Delta:  [expr {[clock clicks -milliseconds] - $http_request_time}]ms)"
    }
    when CLIENT_CLOSED {
    Log the end time of the TCP Connection
    Detailed Connection Closed - Transaction can be located by using the Client IP Address and Port to Load Balancer IP Address and Port for additional matching parameters.
    log local0. "(TCP Connection - Close) Client [IP::client_addr]:[TCP::client_port] to [IP::local_addr]:[TCP::local_port] (Connection Open for:  [expr {[clock clicks -milliseconds] - $tcp_start_time}]ms)"
    }
    

    Hope this helps!