Forum Discussion

Kiran_Kumar's avatar
Kiran_Kumar
Icon for Nimbostratus rankNimbostratus
Oct 12, 2022

iRule: Pool selection based on percentage active members available

Anyone has an idea for below requirement.

vip with 2 pools. Need to select primary pool if active members is greater than 10% of total pool members

Else, select secondary pool.

if both pools have less than 10% active members, then default to primary pool

I know how to do it with number of active members available, but want to know if we have a way to select based on percentage of active members in a pool since pool member count is dynamic in our situation.

Thank you for your help.

4 Replies

  • Hello,

    I've used active_members and members function for this scope, plus some math expressions. Tested in BIG-IPv13

     

    # note: round() returned closest integer value in my tests, so with 2 members in pool expression result was 0.2 which was rounded to 0. This is why i added +1 in expression. With >10 pool members I think math should work fine

    # EDIT - note 2 : ceil() TCL command could be a better fit but I'm not sure iRule support this. 

     

     

    when CLIENT_ACCEPTED {
    
     # log local0. "active members: [active_members primaryPool]"
     # log local0. "total members: [members primaryPool]"
     # log local0. "minimum req. members: [expr round([members primaryPool]*0.1)+1]"
     
    # note: round() returned closest value in my tests, so with 2 members in pool expression result was 0.2 which was rounded to 0. This is why i added +1 in expression. 
     
      if { [active_members primaryPool] >= [expr round([members primaryPool]*0.1)+1] }{
        pool primaryPool
      } else {
    	pool secondaryPool
      }
    }

     

     

     

     

  • Have you tested "active_members" irule command as you can attach it under the Wide_IP ? For %  you will have to do some expression  and this may cause CPU or slowness andI do not think it is a good way to go.

     

    DNS_REQUEST (f5.com)

     

    active_members (f5.com)

     

     

    when DNS_REQUEST {
      if { [active_members http_pool] >= 2 } {
        pool http_pool
      }
    }

    "

    • Kiran_Kumar's avatar
      Kiran_Kumar
      Icon for Nimbostratus rankNimbostratus

      Unfortunately this has to be done at LTM level in our scenario. No GTM play. Thank you very much for your response.

  • Kiran_KumarIf you start load balancing across multiple pools for the same destination URL and what not you will most likely run into persistence issues. It might be better to use priority group activation or simply use another pool if the primary pool goes down completely. Trying to figure out how to balance traffic based on percentage of members available will add a significant amount of complexity that will most likely come back and bite you in the long run.