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...
L4L7_53191
Nimbostratus
Jun 22, 2010I'm sure that some other folks will have ideas here too, but this particular issue is a little hard to solve directly. After all, how much of your traffic is 2%? You won't really know what 2% was until your day is done and you're counting requests in your server logs. But you can approximate it using something like below.
**Note: This uses the (totally great) table command, which requires 10.1 or higher. Also, this rule is an example only and it may not work for your requirements. That said, it will send 2% of HTTP requests to a specific place.
when HTTP_REQUEST {
set requestNum [table incr "mkt_count" ]
if { $requestNum >= 99 }{
table set "mkt_count" 0
}
if { $requestNum == 1 or $requestNum == 2 } {
log local0. "Got a 2% request. Counter is at $requestNum"
pool marketing-pool
} else {
log local0. "Got a normal request. Counter is at $requestNum "
pool default-pool
}
}
Give this a whirl in your test environment and see if it will work for you. Obviously, change your pool names to match. Also, if any of the smart folks out there have ideas to bulletproof this approach please chime in! This is a very cool use case.
HTH,
-Matt
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
