Forum Discussion
Jeremy_Rosenber
Nimbostratus
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 { !([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]
if { $lb_server_status != "up" } {
set drain_pool $lb_server_pool
set drain_addr $lb_server_addr
set drain_port $lb_server_port
}
}
if { [info exists drain_pool] } {
LB::detach
persist none
set drain_status [LB::status pool $drain_pool member $drain_addr $drain_port]
if { $drain_status == "up" } {
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 } {
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
}
}
}
}
}
}
Kevin_Davies_40
Jun 12, 2014Nacreous
Can you add comments as it is difficult to follow in which scenarios parts of the iRule are used.