Forum Discussion
LTM - Load Balancing iRule
- Jun 29, 2014
The intermittent issue is that sometimes the two connections get load balanced to one member and sometimes each member receives one connection. Is there an iRule I can put in place to ensure one connection goes to each member every time?
what you are seeing is due to how cmp works. i think disabling cmp should work.
sol14358: Overview of Clustered Multiprocessing (11.3.0 and later)
http://support.f5.com/kb/en-us/solutions/public/14000/300/sol14358.htmlif you do not want to disable cmp, irule similar to Matt's suggestion is needed (global variable will demote cmp, so you have to store global_myvsconncnt in session table instead).
sol13033: Constructing CMP-compatible iRules
http://support.f5.com/kb/en-us/solutions/public/13000/000/sol13033.html
Hi Dave,
Okay, I am surprised there are two tcp connections. That would seem like round robin algorithim is not working. Could it be that there is other traffic hitting this vip? Perhaps nagios/sitescope/opennms/etc monitor traffic making requests to verify it is up? That would of course skew the alternation
Here is an irule that uses a global variable (to retain across tcp sessions). One draw back to this irule is that it will use only one core/tmm of your LTM, but that might be okay if you aren't pushing the LTM to its max limits. If someone knows a way to do this without using a writable global var, I would be keen to know.
You will need to add in the internal IP's of your member servers in the variables where 1.1.1.1 and 1.1.1.2 are prefilled
when RULE_INIT {
set ::global_myvsconncnt 0
}
when CLIENT_ACCEPTED {
set member1 "1.1.1.1 80"
set member2 "1.1.1.2 80"
set pool [LB::server pool]
incr ::global_myvsconncnt
if { $::global_myvsconncnt > 1 } {
set ::global_myvsconncnt 0
pool $pool member $member1
} else {
pool $pool member $member2
}
}
Come to think of it, if you do/may have the odd user hitting this vip in addition to the client or perhaps you have a monitoring system hitting it, we could easily add a source IP check in this irule to only apply the alternating logic to the requests coming from your client source IP. Then you could guarantee that of their two connections, one will always be on one member server and the other on the other. Additionally, logic could be added to check if the target member server is actually down in the pool and send to the other one until it is back up. Perhaps the pool member command will do this automatically if attempting to pool member a connection to a down member
Hope this helps. If it does please mark the answer as correct
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