Forum Discussion
David_Bradley_2
Nimbostratus
Apr 10, 2007LB::reselect not working as expected
I'm got an LB_SELECTED that is checking if the choice made by the LB is acceptable, and doing an LB::reselect if not. I setup an artificial condition in my lab in which no choice is acceptable. Based on the code below, what i'd expect to see is the connection be ultimately rejected after having looped through all the servers in the pool and determined that none of them were acceptable candidates. What i'm actually seeing is the LB::reselect happening twice, and on the second time, it's putting the connection on the server chosen by the LB, not looping to the next one according to the LB algo. (which is round-robin btw). There are 3 servers in the pool. Here is my LB_SELECTED rule:
when LB_SELECTED {
If we don't have the capacity to host this client on
the selected server, then reselect. If we've gone
through all the servers in the list, then reject.
if { [LB::server ratio] < $client_weight } {
if { $retry_count >= [active_members [LB::server pool]] } {
log local0. "Found no server of [active_members [LB::server pool]] in pool [LB::server pool] with enough capacity to handle $sender of weight $client_weight. Rejecting connection."
reject
return
} incr retry_count
log local0. "LB chose member ([LB::server addr]) with too little capacity ([LB::server ratio]) for sender $sender. Need at least $client_weight. Reselect try number $retry_count."
LB::reselect
}
}
Thanks in advance.
Dave
- JRahm
Admin
I believe you'll need an LB::detach statement prior to your reselect. It seems counterintuitive, but my experience has been that a detach is necessary anytime you *break* the connection and wish to reselect. I would have thought this would be part of the reselect function, but I'm sure there are good reasons why this is not the case. - David_Bradley_2
Nimbostratus
Thanks. I just gave that a try and I see the same behavior. Is there a difference between doing an LB::reselect and just using the 'pool' command? - JRahm
Admin
You could use the pool command and set the optional member tag to force the usage of another pool member. LB::reselect will reselect based on your lb algorithm, so it's possible to get the same member based on the decision process. You can also change that with LB::mode - bl0ndie_127134Historic F5 AccountYes the reselect is limited to 2 tries. Don't know if its documented if not then some one should document this.
- David_Bradley_2
Nimbostratus
I'm going through serious contortions trying to accomplish something relatively simple. I have clients of different "weights". Each server in my pool has a finite "capacity". Each time a client connects to a server I decrement the server's capacity by the client's weight. I'm trying to optimize the distribution of connections and prevent any server from becoming overloaded. I'm using 'ratio' to store the server's capacity value. I use this because it's visible to irules and I can modify it from iControl, and the ratio values are replicated to the backup LTM using session mirroring, unlike TCL global variables. I'm almost there. I can only check a server's 'ratio' in the LB_SELECTED rule, and I can only check the selected server. Ideally i'd like to be able to get a list of servers in a particular pool and query all ratios in that loop. I'd like to do this in the CLIENT_DATA rule. I can't. So i'm forced to do it in LB_SELECTED. Now if I could just get LB::reselect to loop through all of the available servers in the pool, not just two, it would work. Why is it limited to 2? I completely don't understand that one at all. - hoolio
Cirrostratus
You could try contacting F5 support and asking them to escalate the issue to F5's development group, requesting to get an explanation of the behavior and/or have it changed. - JRahm
Admin
Can I ask how you are querying the server's ratio in the LB_SELECTED event? Is this from a canned command? - JRahm
Admin
I updated the LB::reselect entry to reflect Bl0ndie's comment regarding the retry limit: - David_Bradley_2
Nimbostratus
citizen, - JRahm
Admin
going way out of the box, you could try running a foreach loop on a class that includes your pool members, then populate an array with their ratios as you query them. Not sure if this will work or not, but maybe worth a try?
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