[OpenSIPS-Users] Ratelimit usage

Wadii ELMAJDI | Evenmedia wadii at evenmedia.fr
Fri Oct 27 15:39:02 UTC 2023


Hello Adrien

Try :

if (!rl_check("test1", 1, "RED"))
{
   rl_dec_count("test1")
   send_reply(487, "Request Terminated: CPS limit exceeded");
   exit;
}

* If you are using ratelimit to limit only successful traffic, you need to explicitely decrease the counter for the declined calls using the rl_dec_count() function
also I’m not sure RED is the best algorithm for your usecase.

De : Users <users-bounces at lists.opensips.org> De la part de Adrien LACOMME
Envoyé : vendredi 27 octobre 2023 17:06
À : users at lists.opensips.org
Objet : [OpenSIPS-Users] Ratelimit usage

Hi,

I'm trying to implement CPS limitation on OpenSIPS and I got some difficulties to understand how ratelimit module works.

Here is the setup (I want to limit cps to 1) :

if (!rl_check("test1", 1, "RED")) {
      send_reply(487, "Request Terminated: CPS limit exceeded");
}

I tried to make few calls simultaneously but rl_check return is always FALSE.

Here is the log I got :

2023-10-27T16:52:19.792337 SBC /usr/sbin/opensips[137782]: DBG:ratelimit:w_rl_check: Pipe test1 counter:1 load:0 limit:1 should NOT be blocked (0x7fcae1504888)
2023-10-27T16:52:19.804064 SBC /usr/sbin/opensips[137781]: DBG:ratelimit:w_rl_check: Pipe test1 counter:2 load:0 limit:1 should NOT be blocked (0x7fcae1504888)
2023-10-27T16:52:22.872991 SBC /usr/sbin/opensips[137782]: DBG:ratelimit:w_rl_check: Pipe test1 counter:3 load:0 limit:1 should NOT be blocked (0x7fcae1504888)
2023-10-27T16:52:22.918123 SBC /usr/sbin/opensips[137781]: DBG:ratelimit:w_rl_check: Pipe test1 counter:4 load:0 limit:1 should NOT be blocked (0x7fcae1504888)

Shouldn't the module block calls when the counter goes to 2 ? Or is he checking the load value to block ? If yes, why the load value isn't incremented ?

Regards,

Adrien LACOMME


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20231027/4b2912af/attachment-0001.html>


More information about the Users mailing list