Forum Discussion

Ger_Hackett_323's avatar
Ger_Hackett_323
Icon for Nimbostratus rankNimbostratus
May 28, 2015

Respone Time iRule

Hi,

I’ve used a simple iRule below, to log response times. This has worked perfectly in the past, for a site where the Apache server closes the connection after each request and the client uses a single connection, as this is an old site and uses plain HTML, with no images, style sheets, images, etc.

Using the iRule below with a modern web-site that services multiple requests per connection and where the client opens multiple connections to the virtual server, I end up with negative values for the response time. When logging [IP::stats age] alone, I can see that this value makes sense. My understanding on the scope of basic iRule variables was connection based. But what I’m seeing how seems to suggest the multiple connections seen to be using the same version of the reqAge variable.

Any thoughts?

I’m on version 11.x

Thanks,

Ger.

when HTTP_REQUEST {
    set reqAge [IP::stats age]
    set reqURI [HTTP::uri]     
}
when HTTP_RESPONSE {
  log local0. "$reqURI served in [expr {[IP::stats age] - $req_age}] ms"
  unset reqAge reqURI
}
  • Hi,

    How about you take the current time as below, maybe it works for you.

    [ ]
    when HTTP_REQUEST {
        set reqAge [clock clicks -milliseconds]
        set reqURI [HTTP::uri]   
    }
    
    when HTTP_RESPONSE {
        log local0. "$reqURI served in [expr {[clock clicks -milliseconds] - $reqAge}] ms"
        unset reqAge reqURI
    }