Forum Discussion
Dbow_21284
May 19, 2011Nimbostratus
More efficient iRule needed
Hello,
I have a Virtual Server that I just setup for SharePoint. SharePoint hosts about 15 sites which the business lines all want Load Balanced. The challenge for me was that I did not want to setup a virtual server for every site. So I consulted DEVCENTRAL and looked for solutions to this. What I read about and came up with is a single virtual server that would use an iRule to direct traffic to pools for each site. Meaning that a pool would be setup for each site. This sounded great because it would allow me to have a separate monitor for each site.
Here goes an example of the iRUle:
when HTTP_REQUEST
{ if { [HTTP::host] equals "AAA.mydomain.org" } {
if {[active_members SP_AAAA] > 0} {
pool SP_AAAAA }
else {
HTTP::redirect "http://maintenance.mydomain.org"
event disable all
}
}
elseif { [HTTP::host] equals "BBB.mydomain.org" } {
if {[active_members SP_BBBB] > 0} {
pool SP_BBBB }
else {
HTTP::redirect "http://maintenance.mydomain.org"
event disable all
}
}
elseif ..... YADA YADA YADA...
This goes on for 13 other sites!!! So I realize this is very inefficient. Everytime the user makes a request it has to pass this iRule and therefore performance sucks. If I remove it it works fine. And looking at this now, it make sense why I see these results.
So my question is ... how do I make this better? Should I just make a virtual server for each site? iRules seem like it would be very inefficient in this case. Or is there a way to do this on a connection basis instead of each HTTP request basis?
Your assistance and enlightenment is appreciated!!!
Thanks!!!
Dbow
- hooleylistCirrostratusHi Dbow,
- Dbow_21284NimbostratusHi Hoolio,
- hooleylistCirrostratusThe optimal method for selecting a pool would be a check of the host header and mapping that to a corresponding pool name without going through all possible pool names (whether in an if/elseif/.../else chain, a switch statement or a datagroup). The logic would be something like this:
when CLIENT_ACCEPTED { Save the name of the default pool set default_pool [LB::server pool] } when HTTP_REQUEST { Check if Host header ends with my domain if {[string tolower [HTTP::host]] ends_with ".example.com"}{ Try assigning a pool in the format of subdomain1_http_pool from a host header value of subdomain1.example.com if {[catch {pool [getfield [HTTP::host] "." 1]_http_pool} result]}{ log local0. "[IP::client_addr]:[TCP::client_port]: Error assigning pool [getfield [HTTP::host] "." 1]_http_pool for [HTTP::host]" pool $default_pool } } }
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