darragh_19954
Dec 13, 2007Nimbostratus
Saving pools to persistence table when it's not the LB default
I'm trying to persist cookie-disabled users on a particular pool using their IP/UserAgent combination by saving the IP/UA as a universal key in the persistence tables.
In the BIG-IP GUI, I've set up poolA as the default pool with universal as the default persistence profile.
So when a new user arrives, there will be no entry in the persistence table. So we randomly sample between pool A and B. Then we save the outcome in the persistence table against their IP/UA as a key. When a subsequent request comes from that user, we check the persistence table and send to the pool previously sampled.
What I'm finding is that if I use pool A as the default for the load-balancer, and the request gets directed to B, then some of the subsequent requests (for page elements like stylesheets etc) will not find an entry in the persistence table so they get re-sampled. So the HTML comes from pool A and the stylesheet comes from pool B.
The code is below. I don't know what I'm doing wrong but it looks there is some delay between adding an entry to the non-default pool persistence and being able to query it. Any thoughts on this would much appreciated.
when HTTP_REQUEST {
set SessionID [string map {" " ""} "[IP::client_addr][HTTP::header User-Agent]"]
set persistence [session lookup uie $SessionID]
if { $persistence != "" } {
set PoolVal $persistence
set message "Persistence on $persistence"
} else {
if { rand() < 0.5 } {
set PoolVal "poolA"
} else {
set PoolVal "poolB"
}
set message "Pool sampled as $PoolVal"
}
log local0. "$PoolVal,$message,[HTTP::path]"
pool $PoolVal
}
when HTTP_RESPONSE {
if { $persistence == "" } {
session add uie $SessionID $PoolVal 60
}
}