Forum Discussion
Robert_47833
Altostratus
Jul 04, 2011need help in forward uri to different pool via specific percentage
I have two pool: cjj1 ,cjj2
1:for uri in data group aaa, send 80% request to cjj1 and 20% to cjj2
2:if one client visit cjj1,all other requests from this client should be sent to cjj1,s...
hoolio
Cirrostratus
Jul 05, 2011Hi 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects