OpenSIPS/opensips — pull request #345 by shripchenko (2014-10-01 14:55:52+00:00)
Title: load_balancer module enhancements

Apparently, in its current implementation load_balancer module could be used in the only one way:

load balance on static destinations group and static resources list.
first - because do_load_balance() ignores new group.
second - because do_load_balance() - clean up dialog profiles according to new resources string. not a previous one.

I tried to enhance this module to be able to use it in the following ways (this is just a sample to cover all possible cases):

route[LB1] {
if( load_balancer("", "res1;res2") ) {
t_on_failure("LB2_RETRY");
route(RELAY);
}
route(LB2);
}
route[LB2] {
if( load_balancer("", "res3") ) {
t_on_failure("LB2_RETRY");
route(RELAY);
}
route(LB3);
}
failure_route[LB2_RETRY] {
route(LB2);
}
route[LB3] {
if( load_balancer("", "res4") ) {
t_on_failure("LB3_RETRY");
route(RELAY);
}
route(FAILURE);
}
failure_route[LB3_RETRY] {
route(LB3);
}

I also need to implement a scenario where I load-balance some amount of calls and reject excessive load, but some high-priority calls have to be handled at all cost. so I still want to load-balance them to select less busiest node, but ignore the fact that the amount of traffic on this node might exceed configured limits.

Also, if i register call as a 'load' using lb_count_call() function, I want to be able undo it.