[SR-Users] load-balance to registered trunks?

Daniel-Constantin Mierla miconda at gmail.com
Mon Sep 3 12:17:43 CEST 2018


Hello,

just to point that in this particular case, there was recently added a
function to do reload from config, as a simplified alternative to
jsonrpcs approach:

  *
https://www.kamailio.org/docs/modules/devel/modules/dispatcher.html#dispatcher.f.ds_reload

Otherwise, as Alex write, the rpc functions (thus reload for dispatcher,
lcr, mtree, htable, ...) can be executed inside kamailio.cfg via
jsonrpcs module.

Cheers,
Daniel


On 03.09.18 12:01, Alex Balashov wrote:
> You can trigger a reload via the jsonrpcs module. If it's available as an RPC function externally, you can call it internally. 
>
> --
> Sent from mobile. Apologies for brevity and errors. 
>
> -----Original Message-----
> From: David Villasmil <david.villasmil.work at gmail.com>
> To: "Kamailio (SER) - Users Mailing List" <sr-users at lists.kamailio.org>
> Sent: Mon, 03 Sep 2018 5:59 AM
> Subject: Re: [SR-Users] load-balance to registered trunks?
>
> Thanks for replying!
>
> Interesting approach! Though i don't think that will work for me. I've been
> looking into my requirements, and I'd need to do weight-based distribution
> instead of load-balance,  also what i need is to add destinations to the
> dispatcher lists dynamically. I was thinking of adding them dynamically
> when they register, but the module doesn't have a function to reload the
> list via the config script, or a db_mode as on other modules. This one is
> going to be tricky...
>
> Any ideas?
>
> David
>
> On Mon, Sep 3, 2018, 00:26 Alex Balashov <abalashov at evaristesys.com> wrote:
>
>> On Sun, Sep 02, 2018 at 11:58:37PM +0100, David Villasmil wrote:
>>
>>> I've got this scenario where some gateways will register on my
>>> kamailio and i need to send them calls on a load-balance fashion.  is
>>> this possible?
>> Sure, anything is possible in Kamailio if you write the logic for it.
>> :-)
>>
>> I like stateless load-balancing methods where possible - the fewer
>> moving parts, the better.
>>
>> You can do a lookup() and then t_load_contacts(),
>>
>>
>> https://kamailio.org/docs/modules/5.1.x/modules/tm.html#tm.f.t_load_contacts
>>
>> and examine the size of the `contacts_avp`, e.g. by iterating through it
>> with a while loop as you would any XAVP:
>>
>>    $var(num_contacts) = 0;
>>
>>    while(defined $xavp(whatever[$var(num_contacts)]))
>>       $var(num_contacts) = $var(num_contacts) + 1;
>>
>> or you can reg_fetch_contacts() and do the same with the $ulc PV:
>>
>>
>> https://kamailio.org/docs/modules/5.1.x/modules/registrar.html#registrar.f.reg_fetch_contacts
>>
>> and access the number of registrants for the AOR via profile=>count:
>>
>>    if(reg_fetch_contacts("location", "$ru", "blah")) {
>>        # Concurrent contact count is available as $ulc(blah=>count);
>>
>>        ...
>>    }
>>
>> I prefer the latter.
>>
>> Either way, once you have a count, judicious use of cfgutils:$RANDOM
>>
>>
>> https://www.kamailio.org/wiki/cookbooks/5.1.x/pseudovariables#random_-_random_number
>>
>> will have you on your way to sending the call to a random contact of the
>> bunch. For sufficiently large samples, random distribution is
>> substantially similar to round-robin load balancing.
>>
>> If you need failover with that load-balancing, you'll have to buffer
>> these contacts into an XAVP and serially fork through them with a
>> failure_route. Either way, it's all quite doable.
>>
>> If what you're asking is whether there is a built-in facility to effect
>> load balancing across registrants, I'm not aware of one, though it could
>> be my ignorance.
>>
>> -- Alex
>>
>> --
>> Alex Balashov | Principal | Evariste Systems LLC
>>
>> Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
>> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com
Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com




More information about the sr-users mailing list