Forum Discussion
Kevin_106976
Jul 16, 2010Nimbostratus
Distribute load based on uri
Hi,
I want to distribute load across two uri's (/some/uri1 and /some/uri2) on a 70/30 percentage basis. Can I do this via an iRule ?
- The_BhattmanNimbostratusHere is another one
when RULE_INIT { set counter 0 } when HTTP_REQUEST { if {$::counter <= 7} { The first 7 requests are redirected to URI 1 HTTP::redirect "http://uri1" incr $::counter } elseif {$::counter <= 10 } { The next 3 requests are redirect to URI 2 HTTP::redirect "http://uri2" incr $::counter } else { Reset counter and send the 11th request to URI 1 set $::counter 0 HTTP::redirect "http://uri1" } }
- hooleylistCirrostratusI think Bhattman's example would work. But the downside to using a global counter is that it will prevent the VS from being "load balanced" across all of the TMM cores or CPUs (if you're on a CMP capable platform and LTM version). Another poster, Kev, came up with a simple solution for scenarios like this:
http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/aff/5/afv/topic/aft/1172658/afc/1196453/Default.aspx when HTTP_REQUEST { if { rand() > 0.02 } { pool default-pool } else { pool marketing-pool } }
http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/aff/5/afv/topic/aft/1172658/afc/1196453/Default.aspx when HTTP_REQUEST { Check if URI is one we want to redirect if {[HTTP::uri] contains "search"}{ if { rand() > 0.70 } { HTTP::redirect "http://uri1" } else { HTTP::redirect "http://uri2" } } }
- Chris_MillerAltostratusOut of curiosity, anything wrong with sending traffic to a pool with 7:3 ratio and then choosing our redirect based on IP:addr [server_addr] ?
- hooleylistCirrostratusSpark suggested something similar a while back:
- Kevin_106976NimbostratusWow, I like those suggestions a lot. The one about using the random function is simply brilliant ! Thanks guys, I will try it out soon.
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