Forum Discussion

Kram_259300's avatar
Kram_259300
Icon for Nimbostratus rankNimbostratus
Sep 14, 2016

Failover and Failback between pools using % availability

We are migrating from Cisco ACE to f5 Load balancer.

 

We have configuration in ACE - there is primary pool(4 members) and backup pool(2 members).

 

In ACE: partial-threshold 49 back-inservice 99

 

Above command on the CISCO ACE will be send all traffic to the primary pool and in an event when there is less than 3 servers available on primary pool i.e., less than 49% availability the traffic will switch to the backup pool.

 

Traffic will failback to the primary pool only when there is more than 99% availability on the primary pool. i.e., all the members are avaiable.

 

Is it possible to achieve this scenario using iRULE and by calculating the % availablility on the pools to trigger failover and failback?

 

  • Hi Kram,

    based on the answer i gave you a few weeks ago...

    https://devcentral.f5.com/questions/pool-member-failback-condition-48341

    ... the required iRule would look like that...

    when RULE_INIT {
        set static::primary_pool "pool_a"
        set static::primary_failover_value 49
        set static::primary_failback_value 99
        set static::backup_pool "pool_b"
    }
    when CLIENT_ACCEPTED {
         Check session table if backup mode is currently active
        if { [table lookup "status_$static::primary_pool"] eq "backup" } then {
             Backup mode is currently active. Applying Backup mode availability requirements. Check if primary pool has equal or more than 4 members.
            if { [expr { 100 / [members $static::primary_pool] * [active_members $static::primary_pool] }] >= $static::primary_failback_value] } then {
                  Primary pool has equal or more than 4 members. Switching back to primary pool and disable Backup mode.
                table delete "status_$static::primary_pool"
                pool "$static::primary_pool"
            } else {
                  Primary pool has less than 4 members. Using backup pool and keeping Backup mode active...
                pool "$static::backup_pool"
            }
        } else {
             Backup mode is currently not active (default). Applying normal availability requirements. Check if primary pool has more than 1 members.
            if { [expr { 100 / [members $static::primary_pool] * [active_members $static::primary_pool] }] > $static::primary_failover_value] } then {
                  Primary pool more than 1 member. Using primary pool and keeping Backup mode disabled...
                pool "$static::primary_pool"
            } else {
                  Primary pool less than 2 available member. Using the backup pool and enable Backup mode in session table...
                table add "status_$static::primary_pool" "backup" indefinite indefinite 
                pool "$static::backup_pool"
            }
        }
    }
    

    Note: The iRule uses a

    [expr { 100 / [members $static::primary_pool] * [active_members $static::primary_pool] }]
    syntax to calculate the % availability of your primary pool. The value is then compared using a simply
    >=
    comparsion with the configured failover/failback value.

    Note: The additional % value calculation requires additional CPU cycles. Using hardcoded failover/failback values has a much lower CPU overhead.

    Cheers, Kai