Forum Discussion
Reset session on my Virtual Server when a specific pool member with high priority come UP
Hi Cryosleep,
you may try one of the iRules below, to rebalance active sessions for ServerB if ServerA comes back online...
iRule 1: Using a per TCP-Packet
event for active connections to ServerB to lookup the availability of ServerA and then failover CLIENT_DATA
when RULE_INIT {
set static::IP_ServerA "10.10.10.1%1"
set static::IP_ServerB "10.10.10.2%1"
}
when SERVER_CONNECTED {
if { [LB::server addr] equals $static::IP_ServerB } then {
clientside {
TCP::collect
}
}
}
when CLIENT_DATA {
if { [active_members -list [LB::server pool]] contains $static::IP_ServerA } then {
LB::detach
LB::reselect
TCP::release
return
}
TCP::release
TCP::collect
}
iRule 2: Using a periodic TCL script on every active connections to ServerB to lookup the availability of ServerA and then failover.
when RULE_INIT {
set static::IP_ServerA "217.110.108.152%1"
set static::IP_ServerB "217.110.108.152%1"
set static::reject_interval 5000 ; msec
}
when SERVER_CONNECTED {
if { [LB::server addr] equals $static::IP_ServerB } then {
after $static::reject_interval {
if { [active_members -list [LB::server pool]] contains $static::IP_ServerA } then {
after cancel -current
LB::detach
LB::reselect
}
}
}
}
Note: iRule 1 should be considered as very agressive for your CPU, since the status of ServerA is checked on each single TCP-Packet send from the client to ServerB (allows very fast failbacks). iRule 2 uses a once every X msec interval to check the status of ServerA for server side connection send to ServerB (less CPU hungry approach).
Note2: Both iRule are designed to keep the client side TCP-Connection active by transparently reselecting the server side side connection from ServerB to ServerA. If this is a problem for your application, then report back and I'll rewrite the iRule, to reject the client side connection.
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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