Forum Discussion
Jay_Allison_400
Nimbostratus
Nov 15, 2005Brute Force iRule, any more elegant solutions?
So here is the situation. We have some front end servers that connect to some middleware using .net. .net connections stink, as they are always up, are never idle, and spawn new connections when they are 'full'. In our environment we want to send all of the traffic to one server. When that server dies, we want to send it to a backup server. When the server returns, we want to either
- Make the newly recovered server the new backup server
- Smoke all of the connections on the existing backup server so they can reestablish on the main server
What is happening now is that the existing connections on the backup server (because of main server failure) stay there and then the new connections go back to the main server, and we end up getting wierd state/session issues.
The rule I cobbled together to avert this is below, the nice thing is its stateless, the bad thing is its utterly brute force. Can anyone puzzle out a more clever way to do this?
Two pools
Pool A = 10.1.1.1 (The main server)
Pool B = 10.1.1.2 (The backup server)
---
The rule
when CLIENT_CONNECTED {
if { [active_members poolA] > 0 } {
pool poolA
} else {
pool poolB
}
}
when SERVER_DATA {
if { [active_members poolA] > 0 } {
if { [ IP::Addr[IP::server_addr] equals 10.1.1.2 ] } {
TCP::close
}
}
}
- unRuleY_95363Historic F5 AccountHere is an approach that you suggested: make the server coming up the new backup server.
when RULE_INIT { set ::main_server pool_A } when CLIENT_CONNECTED { if { [active_members $::main_server] == 0 } { switch $::main_server { pool_A { set ::main_server pool_B } pool_B { set ::main_server pool_A } } } pool $::main_server }
- unRuleY_95363Historic F5 AccountA slightly more elegant way of killing the connections might be:
This is only more elegant in that you don't need to know the IP address.when CLIENT_CONNECTED { if { [active_members pool_A] > 0 } { set cur_server pool_A } else { set cur_server pool_B } pool $cur_server } when SERVER_CONNECTED { TCP::collect } when SERVER_DATA { if { $cur_server eq pool_B and \ [active_members pool_A] > 0 } { TCP::close } }
- Jay_Allison_400
Nimbostratus
Thanks on both counts, i was trying to figure out an easy way not to hardwire the ip and to do a 'pool switch' as it were. - unRuleY_95363Historic F5 AccountNo prob. Still wearing your utilikilt these days?
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects