Forum Discussion
hooleylist
Jul 06, 2011Cirrostratus
Hi Jucao,
Cookie insert persistence can only be used to persist between members of one pool, not between different pools. Instead you can insert your own cookie and look for that in requests.
Here's a rough, untested example of what I was thinking of. Note that I've used a session cookie. If the user closes their browser after receiving the cjj1 cookie, they'll get load balanced again and could end up going to the other pool. If you change that to a time-expired cookie to avoid that, over time, more than 20% of the users will get pinned to the cjj1 pool.
when HTTP_REQUEST {
Track whether to set a cookie to force use of the cjj1 pool
set cjj1_cookie 0
Check if request already has a cookie indicating
they should be sent to the cjj1 pool
if {[HTTP::cookie value cjj1_cookie] == 1}{
Select the cjj1 pool
pool cjj1_pool
Exit this event in this rule
return
}
If we got here, request did not have a pool selector cookie
if {[class match [HTTP::uri] starts_with cjj1_uri_class]}{
if { rand() < 0.20 } {
Select the cjj1 pool
pool cjj1_pool
Track whether to set a cookie to force use of the cjj1 pool
set cjj1_cookie 1
}
Default action if a pool was not selected above will be to use the VS default pool
}
}
when HTTP_RESPONSE {
Check if request was for a cjj1 URI
if { $cjj1_cookie == 1 }{
Insert a session cookie in the response
HTTP::cookie insert cjj1_cookie value 1 path "/"
}
}
Aaron