Forum Discussion

ims_243721's avatar
ims_243721
Icon for Nimbostratus rankNimbostratus
Sep 08, 2016

Irule latency

Hi

I developed irule to inspect session id and perform persistence but calculating time it might take up to 30 seconds to do this, Is there anyway to reduce the time and how can i know reason of this delay because its not related to the box itself

when HTTP_REQUEST {
    if { ( [HTTP::method] eq "POST") and
         ( [HTTP::path] equals "/url") } then {
        if { [HTTP::header value "Content-Length"] < 5000 } then {
            HTTP::collect 3000
        } else {
            HTTP::collect 5000
        }
    }
    HTTP::header remove "Accept-Encoding"
}
when HTTP_REQUEST_DATA {
    set session [findstr [HTTP::payload] ":sessionID>" 8 "<"]
    if { $session ne "" } {
        persist uie "$session" 1200
    }
}
when HTTP_RESPONSE {
            HTTP::collect 5000 
}
when HTTP_RESPONSE_DATA {
    set session [findstr [HTTP::payload] "" 8 "<"]
    if { $session != "" } {     
        persist add uie $session 1200
    }
} 

2 Replies

  • I think you need to drop the quotes under HTTP_REQUEST_DATA:

    persist uie "$session" 1200
    

    Within the HTTP_REQUEST_DATA, use the if-conditions to function only for specific conditions and not for all.

    Can you reduce the HTTP::collect data following the example provided here.

    You can probably drop the HTTP_RESPONSE & HTTP_RESPONSE_DATA events. Use the remaining iRule and add it to a UIE persistence profile as an iRule and see if it will work.

    I haven't run into latency issues with persistence based on POST data and this could help you, if you are looking for a sample iRule.

  • Hi,

    I think the problem is you collect 3000 bytes even if the content length is less than 3000.

    try this irule:

    when HTTP_RESPONSE {
    
       Trigger collection for up to 1MB of data
      if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{
        set resp_content_length [HTTP::header "Content-Length"]
      } else {
          set resp_content_length 1048576
      }
       Check if $content_length is not set to 0
      if { ([HTTP::status] == 200) && ($resp_content_length > 0)} {
        HTTP::collect $resp_content_length
      }
    }
    
    when HTTP_RESPONSE_DATA {
         do stuff with the payload
        find the application unique identifier between  and  (11 is the length of  string)
        persist add uie [string trim [findstr [HTTP::payload] "" 11 ""]]
    }
    
    when HTTP_REQUEST {
       Trigger collection for up to 1MB of data
      if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576}{
        set req_content_length [HTTP::header "Content-Length"]
      } else {
          set req_content_length 1048576
      }
       Check if $content_length is not set to 0
      if { ($req_content_length > 0)} {
        HTTP::collect $req_content_length
      }
      HTTP::header remove "Accept-Encoding"
    }
    
    
    when HTTP_REQUEST_DATA {
         do stuff with the payload
        find the application unique identifier between  and  (11 is the length of  string)
        persist uie [string trim [findstr [HTTP::payload] "" 11 ""]]
    }
    

    the

    string trim
    command remove space and new lines characters that can be added in XML format.