Forum Discussion
kyn3s_53106
Nimbostratus
Feb 03, 2010Loadbalancing URI on same server ?
Hello folks !
I have an unusual request to submit to your skills. I have two web servers running a proprietary solution. For some dark reasons (process loadbalancing, process optimisation...), they both are running two identical websites on same port but different URI. This is as follows:
http://1.2.3.45:8080/toto1.exe
http://1.2.3.45:8080/toto2.exe
http://1.2.3.46:8080/toto1.exe
http://1.2.3.46:8080/toto2.exe
I would like the users to access each of them. So I wrote the following iRule, as I could see in another post (http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=6232).
I am actually unable to test this solution. So any help is appreciated. My questions are:
Would this work ?
Is there any way to optimize this ?
How about using a pool ?
And what about client-server affinity ?
Thanks again!
rule lb_URI_rule {
when RULE_INIT {
set ::lb_caisd_counter 1
}
when HTTP_REQUEST {
if {$::lb_caisd_counter == 1} {
set ::lb_caisd_counter 2
HTTP::redirect "http://1.2.3.45:8080/toto1.exe "
}
elseif {$::lb_caisd_counter == 2} {
set ::lb_caisd_counter 3
HTTP::redirect "http://1.2.3.46:8080/toto1.exe "
}
elseif {$::lb_caisd_counter == 3} {
set ::lb_caisd_counter 4
HTTP::redirect "http://1.2.3.45:8080/toto2.exe "
}
elseif {$::lb_caisd_counter == 4} {
set ::lb_caisd_counter 1
HTTP::redirect "http://1.2.3.46:8080/toto2.exe "
}
}
}
- The_Bhattman
Nimbostratus
Hi kyn3s, - kyn3s_53106
Nimbostratus
Hi Bhattman, - The_Bhattman
Nimbostratus
Sounds you want them to hit the sites on different URIs in a round robin fashion. Is that correct? - kyn3s_53106
Nimbostratus
Correct! Least Conn would be better but probably much harder using iRules... - The_Bhattman
Nimbostratus
Hi Kyn,when RULE_INIT { set ::rr_counter 0 } when HTTP_REQUEST { if {[HTTP::host] eq "www.yourapp.com" and [HTTP::uri] eq "/" } Check the counter value switch $::rr_counter { 0 { HTTP::redirect "http://[HTTP::host]/toto1.exe set ::rr_counter 1 } 1 { HTTP::redirect "http://[HTTP::host]/toto2.exe set ::rr_counter 0 } } } }
- hoolio
Cirrostratus
You can't really do true least connections load balancing if the connections for the majority of the full session are going direct from the clients to the servers. - The_Bhattman
Nimbostratus
Good point Aaron. - kyn3s_53106
Nimbostratus
Thank you for your code Bhattman. Thank for helping too Aaron. - The_Bhattman
Nimbostratus
Hi Kyn, - kyn3s_53106
Nimbostratus
Hi Bhattman! Then we agree. My english lacks practicing! Will try your solution asap and hopefully give you a positive feedback!
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