Forum Discussion
IRule Creation help
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
- Colin_Walker_12Historic F5 AccountYou could look in the BIG-IP stats information in the GUI and show that each of the pools is receiving a given amount of traffic. Or you could build any kind of custom reporting you want with a stats profile or snmp info or the like.
Colin - Martin_Williams
Nimbostratus
So I assume that cookie insert persistence will not work with this irule. Would this still work if the irule directed to virtual servers (rather than pools ) and then apply a persistence profile to each vs?
Thanks,
Martin - Interesting, the problem is once you introduce persistence you have more of a chance of not distributing the traffic as planned..
I remember reading about a similar issue earlier in the year... Here is the post dug up.
http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/1176748/showtab/groupforums/Default.aspx
Read through the post, you could try enabling a persistence profile and using "match across".. but I'm not sure that is going to work for you and your cookie persistence requirements..
Also, the post makes reference to "ratio" load balancing.. Could you possibly use one pool and use Ratio for a LB metric?
Otherwise you could probably go at it a few ways.. One idea, what if you set a unique cookie for each pool during the random logic, then before the random logic you could check if either cookie exists and send it to the appropriate pool..If no cookie, then you start the random logic. Problem is now we would need to figure out how to take the existing persistent traffic into your % metric or you're not going to be meeting your original goals.. - hoolio
Cirrostratus
What 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 - sysadmin_2015_2
Nimbostratus
Hello,
Is it possible once I implement the below iRule(25% percent of production web traffic being routed to staging_web pool) on our production web virtual server to then route all traffic from the staging_web pool to our staging_app pool of servers via the production app virtual server? The dev team does not want to change DNS entries once we do a deploy to staging then production. Could I apply an iRule on the production app virtual server routing any traffic from the staging web servers to the staging_app pool?
when HTTP_REQUEST { if { rand() > 0.25 } { pool default-pool } else { staging_web } }
Thank you,
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
