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?

I don’t think you will need an iRule to match this configuration. Did you took a look at priority group activation? See:

Hi Kram,

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

… 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 asyntax to calculate the % availability of your primary pool. The value is then compared using a simplycomparsion with the configured failover/failback value.

[expr { 100 / [members $static::primary_pool] * [active_members $static::primary_pool] }]
>=

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

Cheers, Kai