[Serusers] Load Balancing
Jiri Kuthan
jiri at iptel.org
Wed Apr 23 01:44:41 CEST 2003
At 03:33 PM 4/22/2003, Alejandro Olchik wrote:
>I need some help to implement load balance
>when sending invites to an external sip
>proxy server.
>
>I would like to be able to balance load
>between to IPs (10.0.0.1 and 10.0.0.2) and
>use the backup IP when the primary one
>fails.
>
>Below is the routing code I have:
>
>
> if (!lookup("location")) {
> rewritehost("10.0.0.1");
> if (!t_relay_to("10.0.0.1","5060")) {
> sl_send_reply("404", "Not Found");
> };
> break;
> };
>
>How can I add this behaviour?
That depends on the distribution scheme you would like to use.
For example, you can implement a distribution function that
splits requests based on some downstream weights.
e.g.,
modparam("distrib", "weights",
# ...
# rewrite host-part with one of values using the distribution
# 20-30-50
distribute("10.0.0.1/20%, 10.0.0.2/30%, 10.0.0.3/50%)
t_on_negative("1")
t_relay_to();
# ...
reply_route[1] {
# look at destinations that failed, and update their probabilities
# according to some strategy; for example, temporary 0% weight --
# note that this would take shared memory for keeping the weights
# and a timer
update_weights();
# if coupled to TM, it can look at previous attempts to eliminate
# retrying to a previously failed destination
distribute("10.0.0.1/20%, 10.0.0.2/30%, 10.0.0.3/50%)
}
-Jiri
More information about the sr-users
mailing list