Forum Discussion
Ido_Katz_38061
Nimbostratus
Jun 22, 2010IRule Creation help
Hi Guys,
our marketing ask to to check if there is a possbility to create an IRule that said that 2% of the traffic that coming to specific virtual server will go a specfic pool.
F...
hoolio
Cirrostratus
Jul 20, 2011What do you want the user persisted to? Do you want to ensure that once they go to poolA they always go to pool A? If so you could use your own cookie to do this:
when HTTP_REQUEST {
Check if there is a pool selector cookie in the request
Use a switch statement to ensure only valid pool names are present
instead of accepting any pool name from the user supplied cookie
switch [HTTP::cookie pool_cookie] {
poolA -
poolB -
poolC {
Select the pool from the cookie
pool [HTTP::cookie pool_cookie]
set selected ""
}
default {
No pool selector cookie, so randomaly choose a pool
Save a random number between 0 and 1
set rand [expr { rand() }]
if { $rand < .90 } {
pool poolA
set selected poolA
} elseif { $rand < .95 }{
pool poolB
set selected poolB
} else {
pool poolC
set selected poolC
}
}
}
}
when HTTP_RESPONSE {
Set a pool selector cookie if a pool was selected for this request
if {$selected ne ""}{
HTTP::cookie insert name pool_cookie value $selected path "/"
}
}If you need persistence within the pool members you could use a default cookie insert persistence profile. This will "just work" even when using multiple pools on the same virtual server.
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
