Forum Discussion
Jeremy_Rosenber
Jun 12, 2014Nimbostratus
Here's an updated rule which seems better than the original. This doesn't require the 'disable' state. It is better at dealing with new and existing connections, consistently forcing requests where persistence is known to be needed to the down server while redirecting to an active member for other requests. It also doesn't muck with the persistence record, just disables on the connection with 'persist none'. Finally, it restores the original persistence node when the down server comes back up.
Just posting this FYI. I'll be testing it more, but seems much better so far. Not sure the performance impact.
when HTTP_REQUEST {
set lb_server_pool [LB::server pool]
set lb_server_addr [LB::server addr]
if { $lb_server_pool != "" && $lb_server_addr != "" } {
If not yet draining, check if we should start
if { !([info exists drain_pool]) } {
set lb_server_port [LB::server port]
set lb_server_status [LB::status pool $lb_server_pool member $lb_server_addr $lb_server_port]
Start draining member if it is not up
if { $lb_server_status != "up" } {
set drain_pool $lb_server_pool
set drain_addr $lb_server_addr
set drain_port $lb_server_port
}
}
If draining, we'll make a LB decision each request
if { [info exists drain_pool] } {
LB::detach
Ignore persistence as we're basically managing our own. We'll restore it when we're back up. If we didn't ignore it here, then our commands to select an active member will be ignored in favor of the persisted member.
persist none
set drain_status [LB::status pool $drain_pool member $drain_addr $drain_port]
When draining member is back up, stop tracking it
if { $drain_status == "up" } {
If we're going to that pool, go back to the node we were draining and reset persistence to it
if { $drain_pool == $lb_server_pool } {
pool $drain_pool member $drain_addr $drain_port
persist source_addr
}
unset drain_pool
unset drain_addr
unset drain_port
} elseif { $drain_pool == $lb_server_pool } {
At this point we're draining a member, it's still down, and
we are indeed going to that pool.
Go to the draining member only for requests we know persistence is necessity.
Otherwise, choose an active member instead.
switch -glob "[URI::path [HTTP::path] 2][URI::basename [HTTP::uri]]" {
"/ThisPathNeedsPersistence/*" -
"/This/Path/Needs/Persistence" {
pool $drain_pool member $drain_addr $drain_port
}
default {
pool $drain_pool
}
}
}
}
}
}
- Jeremy_RosenberJun 12, 2014NimbostratusAdded commented version at request of Kevin Davies. Sorry about that. Had to add as separate reply it wouldn't let me edit. (Save button no worky)
- Jun 13, 2014I'd change to case insensitive comparison by using string tolower, and change the "-glob" part. ;) Otherwise it looks ok to me. /Patrik