Hi!
Have you implemented a per-customer rate limit in Calls per second? If so - how?
I've played with ratelimit/pipelimit and it seems like I can define a database with one pipe per customer - but have to restart Kamailio to add customers. There are warnings for low timer settings, like 1 second, but I don't know how up-to-date those warnings are.
I guess I could play with hash tables and implement something pike-like there, but it seems like a workaround for something pretty common.
So the question remains - how are you limiting on a cps per customer?
/O
I've done this with dialog and a sql lookup/update.
The sql call updates the table with how many calls are in total for the "client" and how many international calls. There's a max calls and a max international.
If current < max, the call can go through.
The db allows me to combine the lookup over multiple media servers and kamailio servers. The lookup checks the db so any modifications occur in real-time.
Fred Posner The Palner Group, Inc. http://www.palner.com (web) +1-503-914-0999 (direct) +1-954-472-2896 (fax)
On 07/03/2014 07:37 AM, Olle E. Johansson wrote:
Hi!
Have you implemented a per-customer rate limit in Calls per second? If so - how?
I've played with ratelimit/pipelimit and it seems like I can define a database with one pipe per customer - but have to restart Kamailio to add customers. There are warnings for low timer settings, like 1 second, but I don't know how up-to-date those warnings are.
I guess I could play with hash tables and implement something pike-like there, but it seems like a workaround for something pretty common.
So the question remains - how are you limiting on a cps per customer?
/O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
I am looking for calls setups per second - not concurrent calls. Sorry for not being exact.
/O
On 03 Jul 2014, at 13:41, Fred Posner fred@palner.com wrote:
I've done this with dialog and a sql lookup/update.
The sql call updates the table with how many calls are in total for the "client" and how many international calls. There's a max calls and a max international.
If current < max, the call can go through.
The db allows me to combine the lookup over multiple media servers and kamailio servers. The lookup checks the db so any modifications occur in real-time.
Fred Posner The Palner Group, Inc. http://www.palner.com (web) +1-503-914-0999 (direct) +1-954-472-2896 (fax)
On 07/03/2014 07:37 AM, Olle E. Johansson wrote:
Hi!
Have you implemented a per-customer rate limit in Calls per second? If so - how?
I've played with ratelimit/pipelimit and it seems like I can define a database with one pipe per customer - but have to restart Kamailio to add customers. There are warnings for low timer settings, like 1 second, but I don't know how up-to-date those warnings are.
I guess I could play with hash tables and implement something pike-like there, but it seems like a workaround for something pretty common.
So the question remains - how are you limiting on a cps per customer?
/O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
I do it using htable. I maintain a rolling 3-second sample of number of calls in 'htable', the tail of which is auto-expired. The need to implement CPS limits was the basis for the 'updateexpires' option I added to the htable code in Dec 2011--I wanted updates not to cause entries' expiration time to be reset.
Divide by 3, get CPS. It's crude, but effective. One can, of course, have a longer sampling window.
Hello Olle,
If you are to reimplement this by scripting instead of developing a C module, maybe you could use redis as a database, and for each invite of a customer, create a unique key in the redis database like this:
CUSTOMER_A:CALLID
Then set this key to auto expire in let's 10 seconds for instance, with TTL command http://redis.io/commands/ttl .
Then to check the number of invite per seconds for CUSTOMER_A smoothed over a window of 10 seconds, you count the keys in the DB that starts with CUSTOMER_A ( KEYS CUSTOMER_A*) and divide it by 10.
Of course you would have to use a completely empty redis database used only for this purpose in order to reduce the time spent by the keys command to find the number of key matching.
On Thu, Jul 3, 2014 at 11:48 AM, Olle E. Johansson oej@edvina.net wrote:
I am looking for calls setups per second - not concurrent calls. Sorry for not being exact.
/O
On 03 Jul 2014, at 13:41, Fred Posner fred@palner.com wrote:
I've done this with dialog and a sql lookup/update.
The sql call updates the table with how many calls are in total for the "client" and how many international calls. There's a max calls and a max international.
If current < max, the call can go through.
The db allows me to combine the lookup over multiple media servers and kamailio servers. The lookup checks the db so any modifications occur in real-time.
Fred Posner The Palner Group, Inc. http://www.palner.com (web) +1-503-914-0999 (direct) +1-954-472-2896 (fax)
On 07/03/2014 07:37 AM, Olle E. Johansson wrote:
Hi!
Have you implemented a per-customer rate limit in Calls per second? If
so - how?
I've played with ratelimit/pipelimit and it seems like I can define a
database with one pipe per customer - but have to restart Kamailio to add customers. There are warnings for low timer settings, like 1 second, but I don't know how up-to-date those warnings are.
I guess I could play with hash tables and implement something pike-like
there, but it seems like a workaround for something pretty common.
So the question remains - how are you limiting on a cps per customer?
/O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 07/03/2014 08:12 AM, Abdelkader Allam wrote:
Then to check the number of invite per seconds for CUSTOMER_A smoothed over a window of 10 seconds, you count the keys in the DB that starts with CUSTOMER_A ( KEYS CUSTOMER_A*) and divide it by 10.
Indeed. But one could also do this with a purely in-memory htable and obviate the need to talk to any outside service to begin with. :-)
Very true Alex, didnt knew about htables, just checking about it, very interesting :) The added value of Redis though is that other scripts running outside of Kamailio can interact with it and potentially interact with kamailio, can an external script have access to htables in memory db ?
On Thu, Jul 3, 2014 at 12:14 PM, Alex Balashov abalashov@evaristesys.com wrote:
On 07/03/2014 08:12 AM, Abdelkader Allam wrote:
Then to check the number of invite per seconds for CUSTOMER_A smoothed
over a window of 10 seconds, you count the keys in the DB that starts with CUSTOMER_A ( KEYS CUSTOMER_A*) and divide it by 10.
Indeed. But one could also do this with a purely in-memory htable and obviate the need to talk to any outside service to begin with. :-)
-- Alex Balashov - Principal Evariste Systems LLC Tel: +1-678-954-0670 Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
Please be kind to the English language:
http://www.entrepreneur.com/article/232906
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 07/03/2014 08:18 AM, Abdelkader Allam wrote:
Very true Alex, didnt knew about htables, just checking about it, very interesting :) The added value of Redis though is that other scripts running outside of Kamailio can interact with it and potentially interact with kamailio, can an external script have access to htables in memory db ?
Yes, but only rather crudely, via the management interface, i.e.
http://kamailio.org/docs/modules/4.1.x/modules/htable.html#idp1887744
So, I agree that if external access to the raw sampling is desired, htable is not the best.
On 03 Jul 2014, at 14:21, Alex Balashov abalashov@evaristesys.com wrote:
On 07/03/2014 08:18 AM, Abdelkader Allam wrote:
Very true Alex, didnt knew about htables, just checking about it, very interesting :) The added value of Redis though is that other scripts running outside of Kamailio can interact with it and potentially interact with kamailio, can an external script have access to htables in memory db ?
Yes, but only rather crudely, via the management interface, i.e.
http://kamailio.org/docs/modules/4.1.x/modules/htable.html#idp1887744
So, I agree that if external access to the raw sampling is desired, htable is not the best.
Yes and no.
It's easy to write a simple HTTP interface for htables...
I really need per second, not average. I need to react FAST.
I think one htable with timestamp for last request per IP and one with number of requests for this timestamp will work. Using REDIS may not be fast enough, but I haven't tried. Redis or memcache would easily handle a situation with multiple proxys.
Would memcached or Redis handle this on a per second basis? /O
Yes if you set the key created to auto expire in a second
On Thu, Jul 3, 2014 at 12:31 PM, Olle E. Johansson oej@edvina.net wrote:
On 03 Jul 2014, at 14:21, Alex Balashov abalashov@evaristesys.com wrote:
On 07/03/2014 08:18 AM, Abdelkader Allam wrote:
Very true Alex, didnt knew about htables, just checking about it, very interesting :) The added value of Redis though is that other scripts running outside of Kamailio can interact with it and potentially interact with kamailio, can an external script have access to htables in memory db ?
Yes, but only rather crudely, via the management interface, i.e.
http://kamailio.org/docs/modules/4.1.x/modules/htable.html#idp1887744
So, I agree that if external access to the raw sampling is desired,
htable is not the best.
Yes and no.
It's easy to write a simple HTTP interface for htables...
I really need per second, not average. I need to react FAST.
I think one htable with timestamp for last request per IP and one with number of requests for this timestamp will work. Using REDIS may not be fast enough, but I haven't tried. Redis or memcache would easily handle a situation with multiple proxys.
Would memcached or Redis handle this on a per second basis? /O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 07/03/2014 08:31 AM, Olle E. Johansson wrote:
I really need per second, not average. I need to react FAST.
That was why I picked an interval of 3. It seemed the shortest practicable interval in which to collect meaningful sampling. But if the volume of calls is so large that 1-second collection will do, simply use that as the collection interval.
Hi,
do you know how the autoexpire is implemented in the htable module? If it's a timer doing the polling and checking the expiration value, it may not be ideal for your CPU do it that way. Several entries will surely impact negatively on the performance.
I'm planning to implement this for cnxcc module, and I'd like to know your opinion according to the experience you have with this approach.
Thanks, Carlos
On Thu, Jul 3, 2014 at 7:41 AM, Alex Balashov abalashov@evaristesys.com wrote:
On 07/03/2014 08:31 AM, Olle E. Johansson wrote:
I really need per second, not average. I need to react FAST.
That was why I picked an interval of 3. It seemed the shortest practicable interval in which to collect meaningful sampling. But if the volume of calls is so large that 1-second collection will do, simply use that as the collection interval.
-- Alex Balashov - Principal Evariste Systems LLC Tel: +1-678-954-0670 Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
Please be kind to the English language:
http://www.entrepreneur.com/article/232906
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 07/03/2014 08:52 AM, Carlos Ruiz Díaz wrote:
Hi,
do you know how the autoexpire is implemented in the htable module? If it's a timer doing the polling and checking the expiration value, it may not be ideal for your CPU do it that way. Several entries will surely impact negatively on the performance.
It is implemented as a timer, unfortunately:
http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules/h...
Ok. Thanks Alex.
On Thu, Jul 3, 2014 at 8:00 AM, Alex Balashov abalashov@evaristesys.com wrote:
On 07/03/2014 08:52 AM, Carlos Ruiz Díaz wrote:
Hi,
do you know how the autoexpire is implemented in the htable module? If it's a timer doing the polling and checking the expiration value, it may not be ideal for your CPU do it that way. Several entries will surely impact negatively on the performance.
It is implemented as a timer, unfortunately:
http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a= blob;f=modules/htable/ht_api.c;h=f55e784ee4efbd6e7846f57e154068 69df3e24dd;hb=HEAD#l896
-- Alex Balashov - Principal Evariste Systems LLC Tel: +1-678-954-0670 Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
Please be kind to the English language:
http://www.entrepreneur.com/article/232906
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
I think my head isn't fully woken up yet -- sorry about that.
Fred Posner The Palner Group, Inc. http://www.palner.com (web) +1-503-914-0999 (direct) +1-954-472-2896 (fax)
On 07/03/2014 07:48 AM, Olle E. Johansson wrote:
I am looking for calls setups per second - not concurrent calls. Sorry for not being exact.
/O
On 03 Jul 2014, at 13:41, Fred Posner fred@palner.com wrote:
I've done this with dialog and a sql lookup/update.
The sql call updates the table with how many calls are in total for the "client" and how many international calls. There's a max calls and a max international.
If current < max, the call can go through.
The db allows me to combine the lookup over multiple media servers and kamailio servers. The lookup checks the db so any modifications occur in real-time.
Fred Posner The Palner Group, Inc. http://www.palner.com (web) +1-503-914-0999 (direct) +1-954-472-2896 (fax)
On 07/03/2014 07:37 AM, Olle E. Johansson wrote:
Hi!
Have you implemented a per-customer rate limit in Calls per second? If so - how?
I've played with ratelimit/pipelimit and it seems like I can define a database with one pipe per customer - but have to restart Kamailio to add customers. There are warnings for low timer settings, like 1 second, but I don't know how up-to-date those warnings are.
I guess I could play with hash tables and implement something pike-like there, but it seems like a workaround for something pretty common.
So the question remains - how are you limiting on a cps per customer?
/O _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hello,
On 03/07/14 13:37, Olle E. Johansson wrote:
Hi!
Have you implemented a per-customer rate limit in Calls per second? If so - how?
I've played with ratelimit/pipelimit and it seems like I can define a database with one pipe per customer - but have to restart Kamailio to add customers. There are warnings for low timer settings, like 1 second, but I don't know how up-to-date those warnings are.
I guess I could play with hash tables and implement something pike-like there, but it seems like a workaround for something pretty common.
So the question remains - how are you limiting on a cps per customer?
pipelimit from devel branch has this option to create pipes on demand with dynamic name. Would be good to get some feedback if works fine, as I did limited testing at the time of development. The module should just work if placed over 4.1 source code.
Cheers, Daniel