Forum Discussion
Failover and Failback between pools using % availability
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
syntax to calculate the % availability of your primary pool. The value is then compared using a simply [expr { 100 / [members $static::primary_pool] * [active_members $static::primary_pool] }]
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
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com