Forum Discussion
Pool member failback
Hi guys,
the following irule logic inspired by some of the comments above, seems a bit neater and should do the trick. You will need to adjust the pool names and pool member counts as required, and you can of course perform more complex calculations if you prefer.
I did some basic testing, but i can't promise i caught all potential errors, so make sure to give it a whirl in a test environment first.
when RULE_INIT {
set static::pp "webpool"
set static::bp "backupwebpool"
set static::flag "flag"
}
when CLIENT_ACCEPTED {
if { [table lookup $static::flag] eq "backup" && [active_members $static::pp] < 1 } {
we're in backup mode
log local0. "backup mode"
pool $static::bp
}elseif { [active_members $static::pp] >= 1} {
active mode
log local0. "going back to active mode"
table set $static::flag "active"
pool $static::pp
}else {
backup mode needs to be enabled
log local0. "enabling backup mode"
table set $static::flag "backup"
pool $static::bp
}
}
- BinaryCanary_19Sep 02, 2016Historic F5 Account
also, might be worth looking into priority group activation, a feature of pools that can do something similar to this without needing irules, and with probably better handling of cases like persistence than this irule.
- Kai_WilkeSep 02, 2016
MVP
Hi FKnuckles,
I'm a big fan of the Priority Based Activation feature, but unfortunately you can't use this feature for the given requirement (different availability thresholds for failover and failback).
Well, you're code uses just 3 instead of 4 different conditions and looks therefor indeed much cleaner. But on the other hand it does not cover the requirements of the OP and produces a slightly higher overhead. Let me try to compare the different iRules...
Active Operation Scenario
Your code:
if [table lookup $static::flag] eq "backup" if [active_members $static::pp] >= 1 table set $static::flag "active" pool $static::pp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup" if [active_members "$static::primary_pool"] > 1] pool "$static::primary_pool"
Performance Difference: Your code requires one additional table command execution.
Functional Difference: None
Active Operation Failover Scenario
Your code:
if [table lookup $static::flag] eq "backup" if [active_members $static::pp] >= 1 table set $static::flag "backup" pool $static::bp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup" if [active_members "$static::primary_pool"] > 1] table add "status_$static::primary_pool" "backup" indefinite indefinite pool "$static::backup_pool"
Performance Differences: None
Functional Difference: None
Backup Operation Scenario
Your code:
if [table lookup $static::flag] eq "backup" if [active_members $static::pp] < 1 pool $static::bp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup" if { [active_members "$static::primary_pool"] >= 4] pool "$static::backup_pool"
Performance Differences: None
Functional Difference: The OPs requirement is not covered. The requirement for triggering the failback is [active_members $static::pp] = 4 nodes.
Backup Operation Failback Scenario
Your code:
if [table lookup $static::flag] eq "backup" if [active_members $static::pp] < 1 if [active_members $static::pp] >= 1 table set $static::flag "active" pool $static::pp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup" if { [active_members "$static::primary_pool"] >= 4] table delete "status_$static::primary_pool" pool "$static::primary_pool"
Performance Differences: Your code requires one additional [active_members $static::pp] command execution.
Functional Difference: The OPs requirement is not covered.
Cheers, Kai
- BinaryCanary_19Sep 02, 2016Historic F5 Account
Hi Kai,
First off, Thanks for posting your original irule. I believe you solved the OP's question, which is much appreciated. This wasn't really a critique of your irule. The context in which I made this version was just expressly to improve readability for a different person who actually drew their inspiration from your solution. I did not attempt to tweak for performance in any way, and I posted this here just as a way of sharing an alternative version since the work was already done.
I also didn't attempt to use the OP's numbers, understanding being that the user will place the numbers they desire.
Talking of performance, strictly speaking, the "table set $static::flag active" is completely unnecessary in my version, as the "active" value is never really used. That's one quick optimisation that I spotted.
Going further, the table set is probably totally unnecessary in fact, considering that the fallback to active pool always happens whenever the active pool is healthy. My version looks like this because I basically just took yours and tried to improve readability. I didn't approach OP's question from clean slate. It is possible that a simple solution could be devised where you simply need an
if [primary pool available members less than 4] then backup; Else: primary;
- Kai_WilkeSep 02, 2016
MVP
Hi F5Knuckles,
I didn't recognized your answer as a critique towards my irule. I was just interested in a technical discussion, to explain the pros and cons of the different coding styles... :-)
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