<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<tt>Hello, Will!<br>
<br>
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:<br>
<br>
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.<br>
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.<br>
algorithm - the algorithm used to detect a limit.<br>
<br>
Therefore, if you would like to limit the CPS for each IP to 3,
you should use the following snippet:<br>
<br>
if (!rl_check("$si", "3", "RED")) {<br>
sl_send_reply("403", "CPS Limit Exceeded");<br>
exit;<br>
};<br>
<br>
You can specify how long a value should be kept in memory using
the expire_time parameter[1] of the module.<br>
<br>
[1] <a
href="http://www.opensips.org/html/docs/modules/devel/ratelimit.html#id250152">http://www.opensips.org/html/docs/modules/devel/ratelimit.html#id250152</a><br>
<br>
Regards,</tt>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<br>
<pre class="moz-signature" cols="72">--
Răzvan Crainea
OpenSIPS Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
<br>
On 04/18/2012 10:30 PM, Will Baz wrote:
<blockquote
cite="mid:1334777413.77615.YahooMailNeo@web141002.mail.bf1.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:times
new roman, new york, times, serif;font-size:12pt">
<div>
<div>Hi All,</div>
<div><span class="yiv1949567040Apple-tab-span"
style="white-space: pre; "> </span>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?</div>
<div><span class="yiv1949567040Apple-tab-span"
style="white-space: pre; "> </span>Specifically I was
planning on limiting CPS by entering a string for my key
that represents the "second" and increment. So something
like this: </div>
<div><br>
</div>
<div>rl_check("080101", 5, <some algorithm>)</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>What I'm not clear on looking at the module description
(<a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/devel/ratelimit.html">http://www.opensips.org/html/docs/modules/devel/ratelimit.html</a>)
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.</div>
<div><br>
</div>
<div>Anyways, if someone has used ratelimit in a similar
fashion or may understand it better than I, I'd appreciate
any feedback.</div>
<div><br>
</div>
<div>Thanks!</div>
<div>Will</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
</body>
</html>