Here's what I have come up with. This will only have one VIP, and the logic will maintain POD/pool persistence, but not always to the same server. Please let me know what you all think, and where I can improve things. I wanted to create a switch structure in the HTTP_RESPONSE section, but couldn't get through the syntax due to the matchclass requirements. Thanks in advance...
Assumptions:
One VIP with this iRule assigned and a default pool of pool_all_servers.
One pool for each pod of servers, and another for all servers (3 total in this example).
There is an address dataset for each pod that includes the IP's for every server in that pod.
Ramp up time set to 300 sec on each of the pod pools, but not the pool_all_servers pool.
when HTTP_REQUEST {
LB::mode leastconns
set strPoolID [HTTP::cookie "pod"]
if { $strPoolID !=""} {
if {[active_members pool_www_pod_$strPoolID] > 0} {
pod cookie identified and used to load balance to that pod/pool
pool pool_www_pod_$strPoolID
} else {
if original pool is down, use the default pool..
User will lose session, but will get page.
HTTP::cookie remove "pod"
pool [LB::server pool]
log local0. "sending [IP::client_addr] coming in on [IP::local_addr] to pool [LB::server pool] because original pool pool_www_pod_$strPoolID is down"
}
}
else {
if no pod cookie is present - ie new session, then use the default pool and lb mode least connections.
log local0. "using pool [LB::server pool] since we dont have a pod yet"
pool [LB::server pool]
}
}
when HTTP_RESPONSE {
if { [matchclass [IP::server_addr] equals $::dg_pod_1_ips] } {
set strPodNumber "1"
} elseif { [matchclass [IP::server_addr] equals $::dg_pod_2_ips] } {
set strPodNumber "2"
} else {
log local0. "we have problems getting value of pod cookie or it isnt 1 or 2"
}
HTTP::cookie insert name "pod" value $strPodNumber path /
}