Forum Discussion

elito_26780's avatar
elito_26780
Icon for Nimbostratus rankNimbostratus
Mar 19, 2007

Evaluating only first HTTP request in HTTP 1.1

I need to evaluate only first request in HTTP 1.1 packet and than select the appropriate pool. When I use HTTP_REQUEST, the rule evaluates every HTTP request it sees in HTTP 1.1 packet and then chooses wrong pool, from the application perspective.

 

The problem with the application is that some data is available only in the first HTTP GET, but not in following GET requests within same HTTP 1.1 packet.

 

 

Another issue is performance. Our typical HTTP 1.1 packet contains 5-7 HTTP requests, so evaluating 5-7 requests, instead of 1 request, hits the performance.

5 Replies

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hi Eli -

     

     

    A bit of irony playing here: We usually get the opposite question -- how to keep the iRule from sending all requests in a KeepAlive connection to the server that was selected for the first.

     

     

    Enabling OneConnect forces re-selection of the most appropriate server on each request. On the other hand, with OneConnect disabled, the serverside connection is maintained for the life of the connection, causing subsequent requests to go to the same server even when conditions are observed to have changed. (It's not exactly intuitive -- lots more on that here:

     

    http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=10032 Click here)

     

     

    So I'll go out on a limb here and assume you have a OneConnect profile enabled on the virtual server, and further assume that if you remove it, you'll probably see the behaviour you are looking for...

     

     

    HTH

     

    /deb

     

     

  • No luck.

     

    I'm playing with it right now in my test environment.

     

    Here is my iRule:

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] contains ".gif"} {

     

    pool servers2

     

    }

     

    else {

     

    pool servers1

     

    }

     

     

    }

     

     

    Very simple and straight forward. My VS uses default http profile without OneConnect transformation and doesn't use OneConnect profile.

     

    I have a simple traffic generator that sends 5 HTTP requests within single HTTP 1.1 packet.The first request is a gif request. And I still see regular requests on "servers1" and gif requests on "servers2".

     

     

    Any other places to dig? What is wrong?
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Assuming that there are several requests in a single Keep-Alive connection (rather than in a single packet), you could disable the HTTP_REQUEST event after the first request is seen, then that pool will be used for the life of the connection:

    when HTTP_REQUEST {
      if { [HTTP::uri] contains ".gif"} {
        pool servers2
      } else {
        pool servers1
      }
      event disable
    }

    (Should have thought of that yesterday, I guess -- sorry!)

    HTH

    /deb

  • Thanks! Cool! That what i was looking for. Just missed the "event" command in reference guide.

     

    I wish the iRules documentation was much better and deeper.
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    No problem!

     

     

    With that iRule in place, you might want to consider enabling OneConnect if you're looking to optimize further -- it will allow you more opportunity to use KeepAlives on the server side. Default profile which shares existing connections among multiple clients is the most optimal, although the server logs will not reflect the actual client IP unless you insert an X-Forwarded-For header (http profile option) & log that.

     

     

    Good luck!

     

    /deb