Forum Discussion

Gary_Rudolph_31's avatar
Gary_Rudolph_31
Icon for Nimbostratus rankNimbostratus
Sep 16, 2005

Rule Based Persistence & Fail Over

We have a rule where it routes to a specific member using a value parsed from a cookie (JSESSIONID). The problem is if the member fails the rule still routes the traffic to the failed member. Is there a way to have it not route to the failed member and instead fall back on the pool? Our assumption with the current rule is that in setting the node specifically the F5 is smart enough to detect if it's down or not and to not use it if it is.

Here's the rule:


when HTTP_REQUEST {
  if {[HTTP::cookie exists "JSESSIONID"]} {
    set jvmid [getfield [HTTP::cookie "JSESSIONID"] "." 2]
  } else {
    set jvmid [findstr [HTTP::uri] "jsessionid" 44 3]
  }
  set nodes $::admin
  pool admin
  if {$jvmid ne ""} {
    set entry [findclass $jvmid $nodes]
    if {$entry ne ""} {  
      node [getfield $entry " " 2]  
    }
  }
}

The cookie is usually of the format:

Cookie: JSESSIONID=371C2D7A70BAA2F1BC38F4D5ABDFF8D2.a02

We have a class that maps a01, a02 to specific members.

Thanks, Gary
  • FYI, the goal is to be completely stateless with no persistence as the persistence tables would become large with a 2 hour timeout on a commercial site.

     

     

    We've also tried:

     

    pool admin member [getfield $entry " " 2]

     

     

    Instead of:

     

    node [getfield $entry " " 2]
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Unfortunately, that's the problem with using the node command. It does not have any knowledge of the status. This is one big reason we now recommend using the pool member command. This takes into account status of the pool member. So, use this command instead of the node command:

       pool admin member [getfield $entry " " 2] [TCP::local_port]

    You will also want to add a LB_FAILED event so you can issue the command "LB::reselect pool admin" which will then reselect a new member of the pool based on a load-balancing decision (instead of using the supplied member).

    when LB_FAILED {
       LB::reselect pool admin
    }

  • If we add the reselect it works.

     

     

    when LB_FAILED {

     

    LB::reselect pool admin

     

    }

     

     

    Can't this also be done through the admin on the "Action on Service Down" = Reselect?

     

     

    We were told not to do this as it would take longer for a fail over to recover?
  • If the pool is dynamic by the URI, can we set the pool used for that request in HTTP_REQUEST and then just read it in LB_FAILED?

     

     

    when HTTP_REQUEST {

     

    ...

     

    set selectedPool admin

     

    ...

     

    }

     

     

    when LB_FAILED {

     

    LB::reselect pool $selectedPool

     

    }
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    The problem with "Action on Service Down" is that it applies to existing connections (eg, reselect a new server for the existing connections). It does not apply to new connections that have failed to connect to a specific pool member.

     

     

    BTW, setting that attribute should not effect failover at all. I'm not sure why you were told that...

     

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    You don't even need to set it in a variable:

    when LB_FAILED {
       LB::reselect pool [LB::server pool]
    }