[SR-Users] [Kamailio-users] Weight based routing

marius zbihlei marius.zbihlei at 1and1.ro
Fri Jul 30 10:57:58 CEST 2010


Chandrakant Solanki wrote:
>
> Hi
>
> Thanks for reply.
>
> I have look into carrierroute module, it seems that my requirement is 
> fulfill.
>
> But i have multiple carrier in my carrier_name table, say car1, car2, 
> car3, default, and I want them load dynamically on INVITE of any user 
> based on its probability. Above all carrier has 0.1 probability and 
> each point to different asterisk machine.
>
> How could it be possible..??
>
> Any Idea..?
>  
> -- 
> Regards,
>
> Chandrakant Solanki


Hello,

I think you can do things much simpler . For example you don't event 
need a database, you could use carrierroute in file mode . Just have one 
sp-route.conf file containing the entries like in this example:

domain my_domain {
        prefix NULL {
                max_targets = 10
                target asterisk_server1:5060 {
                        prob = 0.1
                        hash_index = 1
                        status = 1
                        comment = "asterisk server 1"
                }        
                target asterisk_server2:5060 {
                        prob = 0.1
                        hash_index = 2
                        status = 1
                        comment = "aserisk server 2"
                }
       .....
   }
}

Then in the cfg file you could specify modparam("carrierroute", 
"config_file", "/path/to/sp-route.conf")

To balance INVITEs, in you cfg you call

if(method == "INVITE"){
       cr_route("default", "my_domain", "$rU", "$rU",  "call_id");
       forward();
}


This will balance your invites based on the Call-id header.(it will be 
sent randomly to one of the hosts based on the weight). If you want you 
could balance them based on from_user(Call originating from one user 
will always go to the same asterisk machine). Note that in file mode you 
only have 1 carrier(called default), but you can have several domains.

Hope this helps
Marius





More information about the sr-users mailing list