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.
For example:
I got a virtual server with the IP address of 1.1.1.1 which have a default pool named x.
I need a rule that say that once he got a traffic so 2% of the traffic will go to some other pool which is not the default pool of the virtual server.
Is it possible?
Thanks
Ido
15 Replies
Sort By
- L4L7_53191
Nimbostratus
I'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.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 } }
- The_Bhattman
Nimbostratus
Hi Ido, - Ido_Katz_38061
Nimbostratus
Thanks a lot, I will try it on our test env. - Kevin_Davies_40
Nacreous
when HTTP_REQUEST { if { rand() > 0.02 } { pool default-pool } else { pool marketing-pool } }
- Martin_Williams
Nimbostratus
Hi Guys, - Colin_Walker_12Historic F5 AccountSure, you could use effectively the same logic as above just move some numbers around. Send anything that's 1-5 to poolA, 6-10 to poolB, and the rest to the main pool.
- Colin_Walker_12Historic F5 AccountIf you have any issues or questions, feel free to ask and I'm happy to help with the code.
- Martin_Williams
Nimbostratus
Hi Colin, - hoolio
Cirrostratus
Hi Martin,when HTTP_REQUEST { Save a random number between 0 and 1 set rand [expr { rand() }] if { $rand < .90 } { pool poolA } elseif { $rand < .95 }{ pool poolB } else { pool poolC } }
- Martin_Williams
Nimbostratus
Thanks Aaron this seems to work well. How could I prove (to marketing) that the pools are being load balanced as requested. Do I need to create a stats profile?
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