Forum Discussion

Ronan_Burke_110's avatar
Ronan_Burke_110
Icon for Nimbostratus rankNimbostratus
Oct 07, 2005

A/B Site Testing

Hi,

 

I have a iRule where depending on a value stored on the Clients cookie, the user will be directed to one of two Pools. There is no issue if the Cookie exists, but how would I send the user to each pool randomly or in a round robin fashion if no cookie exists ?

 

 

Regards

 

Ronan

 

 

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Well, without seeing your exact rule, I can't give you a modified version that functions on the "no cookie exists" case, but here's an example of how to check for a cookie, and if it's not present, route to a specific pool.

    
    if(not (exists http_cooke("some_cookie"))) {
      use pool no_cookie
    }

    So, you could use the same rule structure, but replace the cookie name with the cookie you're looking for.

    Hope this helps,

    -Colin
  • Hi Colin,

     

     

    thanks for the reply.

     

     

    I already have the cookie part setup and working. The problem I now have is that if the cookie does not exist all connections will be sent to the ChannelB Pool.

     

    Is there a way I can load-balance between both Pools - ie: half the traffic going to each of the Pools if there is no cookie found.

     

     

     

    if (exists http_cookie("cookietest") and http_cookie("cookietest") contains "ChannelA") {

     

    log "ChannelA used"

     

    use pool ChannelA

     

    }

     

    else {

     

    if (exists http_cookie("cookietest") and http_cookie("cookietest") contains "ChannelB") {

     

    log "ChannelB used"

     

    use pool ChannelB

     

    }

     

    else {

     

    log "Cookie NotFound"

     

     

    }

     

    }

     

     

     

     

    Regards

     

    Ronan
  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    Ronan,

    probably the simplest solution is to create another pool which is union of ChannelA and ChannelB nodes. If you use round-robin loadbalancing method (which is the default) and you interleave A and B nodes in the new pool, you will (in average) get 50:50 distribution of connections to A and B nodes via the new pool.

    Here is how the configuration may look like:

    
    pool ChannelA {
       member 10.1.1.1:80
       member 10.1.1.2:80
    }
    pool ChannelB {
       member 10.1.2.1:80
       member 10.1.2.2:80
    }
    pool ChannelAB {
       member 10.1.1.1:80
       member 10.1.2.1:80
       member 10.1.1.2:80
       member 10.1.2.2:80
    }
    rule distributor {
       if (exists http_cookie("cookietest") and http_cookie("cookietest") contains "ChannelA") {
          log "ChannelA used"
          use pool ChannelA
       }
       else {
       if (exists http_cookie("cookietest") and http_cookie("cookietest") contains "ChannelB") {
          log "ChannelB used"
          use pool ChannelB
       }
       else {
          log "Cookie NotFound"
          use pool ChannelAB
       }
    }

    If you have other preferences how to distribute connections to servers, you may want to use the direct node selection feature in the ChannelAB pool. See BIG-IP Reference Guide for details.