Forum Discussion

gerald_wegener_'s avatar
gerald_wegener_
Icon for Nimbostratus rankNimbostratus
Jun 12, 2006

Eliminate redirects

 

In lieu of doing http redirects in the following example basic example:

 

 

--------

 

Client connects to http://abc.com and is redirected to http://www.abc.com

 

--------

 

 

would it be possible to eliminate the redirect in some fashion. For example:

 

 

1. Rewrite the request for abc.com to www.abc.com and submit it to the www.abc.com virtual.

 

 

2. Rewrite the response so the client now sees www.abc.com

 

 

Running ver 9.x

 

 

One goal here is to eliminate the time it takes for the client to get redirected and to reconnect to a new URL.

 

 

Thank You.

15 Replies

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Click here for info on generating a random number.

     

     

    I think you could configure cookie insert persistence with no expiry (session cookies) on the virtual, then look for the persistence cookie to determine if it is a "new" session or not...

     

     

    HTH

     

    /deb
  • Yes the HTTP_REQUEST event will fire on every connection to the virtual so you will need to build in some logic to handle that.
  •  

    I'm not sure what you mean by building in some logic to handle the fact that every request is evaluated by the rule.

     

     

    I have the following rule below that I'm testing. It looks for an existing cookie and if it exists then it's sent to the named pool which is extracted from the value field in the cookie.

     

     

    If no cookie is found then it is assumed to be a new session so it distributes between three pools based on the value returned by the random number generator.

     

     

    Is it a problem that every request is evaluated by this iRule? When you say I will need to build in logic to handle that what do you mean? Do you mean just make the iRule as efficient as possible? (which I have tried to do)

     

     

    Thanks.

     

     

    ===================================================

     

     

    when HTTP_REQUEST {

     

     

    if { [HTTP::cookie exists "stick2"]} {

     

     

    existing cookie found so not a new session. Send to correct pool based on cookie value

     

     

    pool [HTTP::cookie "stick2"]

     

    }

     

     

    else {

     

    no existing cookie (new session). Distribute between 3 pools using random number (1-100)

     

     

    set rndnum [expr { int(100 * rand()) }]

     

     

    if { $rndnum > 9 } {

     

    pool www1

     

    approx. 90% to pool www1

     

    }

     

    elseif { $rndnum >=5 } {

     

    pool www2

     

    approx 5% to pool www2

     

    }

     

    else {

     

    pool www3

     

    remaining 5% to pool www3

     

     

    }

     

    }

     

    }

     

     

    Is this iRule inefficient in terms of looking at all requests? How can it be made more efficient?

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    I think what was meant was that you need to be sure your rule works for all the different kinds of requests your VIP will be receiving...even those that have been passed through the rule once before.

     

     

    Colin
  •  

    I've been using the random number generator as recommended earlier in this thread and have found that it causes a much greater number of TCP connections on the server side. So if I run an iRule with rand as follows:

     

     

     

    set rndnum [expr { int(100 * rand()) }]

     

     

    then have some if statements such as:

     

     

    if { $rndnum > 10 ] } {

     

    pool abc

     

    }

     

    else {

     

    pool xyz

     

    }

     

    }

     

     

    I will 1 TCP connection on the clientside but many TCP conns on the server side. I'm using an IXIA traffic generator so I can see all connections. Plus I use the BigIP stats.

     

     

    If I then make the following modification and set rndnum manually I'll see one clientside and 1 server side TCP connection, as expected.

     

     

     

    set rndnum 10

     

    set rndnum [expr { int(100 * rand()) + 1 }]

     

     

     

    Any explanation as to why this is happening? It's definetly related to running rand. If I run any test at high traffic volumes I'll huge numbers of server side connections.

     

     

    Thanks.