[OpenSIPS-Users] Use of Ratelimit Module as CPS limiter
Razvan Crainea
razvan at opensips.org
Thu Apr 19 10:46:52 CEST 2012
Hello, Will!
You are right, the ratelimit module is the one you should choose to
limit CPS. But unfortunately I think you misunderstood how it works. The
parameters of the rl_check functions are the followings:
key - the entity you want to limit the CPS. For example this can be an
IP, if you want to limit the CPS coming from a certain IP.
limit - this is the limit of CPS allowed for the specified key. If this
limit is reached, the function will return with failure, otherwise it
will return true.
algorithm - the algorithm used to detect a limit.
Therefore, if you would like to limit the CPS for each IP to 3, you
should use the following snippet:
if (!rl_check("$si", "3", "RED")) {
sl_send_reply("403", "CPS Limit Exceeded");
exit;
};
You can specify how long a value should be kept in memory using the
expire_time parameter[1] of the module.
[1] http://www.opensips.org/html/docs/modules/devel/ratelimit.html#id250152
Regards,
--
Ra(zvan Crainea
OpenSIPS Developer
http://www.opensips-solutions.com
On 04/18/2012 10:30 PM, Will Baz wrote:
> Hi All,
> I have been taking a look at the ratelimit module to limit CPS as
> suggested by a few prior posts. I believe I have the gist of it (it's
> a key/value store w/ specialized algorithms to calculate when a limit
> is reached), but I was wondering if someone could explain best
> practices for removing values from the key/value store?
> Specifically I was planning on limiting CPS by entering a string for
> my key that represents the "second" and increment. So something like
> this:
>
> rl_check("080101", 5, <some algorithm>)
>
> We could also add a trunk_id to the front of that string to limit CPS
> on a particular trunk or IP or whatever. Then when a call comes in at
> that specific second we increment the counter and check to see if
> there have already been 5 calls that second.
>
> What I'm not clear on looking at the module description
> (http://www.opensips.org/html/docs/modules/devel/ratelimit.html) is
> how I could destroy certain key/value pairs once I don't need them
> anymore (because the second is over). I do not want to have 3600
> values an hour sitting in memory.
>
> Anyways, if someone has used ratelimit in a similar fashion or may
> understand it better than I, I'd appreciate any feedback.
>
> Thanks!
> Will
>
> PS, Apologies if this is a duplicate. I originally posted w/o being a
> member of the lists. I joined and then reposted assuming my original
> would not be posted.
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120419/559cba26/attachment.htm>
More information about the Users
mailing list