[OpenSIPS-Users] Ratelimit usage

Ben Newlin Ben.Newlin at genesys.com
Fri Oct 27 16:13:01 UTC 2023


Have you read the description of the RED algorithm? Are you sure you are generating appropriate traffic to cause a drop? That algorithm seems like it would be difficult to control/predict the drops accurately for a test. If you are sending a constant traffic volume to it, it never will drop.

If you are just testing, you may want to go with a simpler algorithm where you can more easily control when/how many are being dropped.

The standard way to use the module for CPS is to use the SBT algorithm with a window_size of 1. [1]

[1] https://opensips.org/docs/modules/3.2.x/ratelimit.html#param_window_size

Ben Newlin

From: Users <users-bounces at lists.opensips.org> on behalf of Adrien LACOMME <adrien.lacomme at appliwave.com>
Date: Friday, October 27, 2023 at 12:03 PM
To: OpenSIPS users mailling list <users at lists.opensips.org>
Subject: Re: [OpenSIPS-Users] Ratelimit usage
 EXTERNAL EMAIL - Please use caution with links and attachments

________________________________
Hello,

I added this line to my code, in fact it's better to decrease the counter if I drop the call.
But my problem is that the rl_check function never drop calls, I do not enter in the IF condition.

For the algorithm, I'm actually just trying the module, I will probably not stay with RED.

________________________________
De : Users <users-bounces at lists.opensips.org> de la part de Wadii ELMAJDI | Evenmedia <wadii at evenmedia.fr>
Envoyé : vendredi 27 octobre 2023 17:39
À : OpenSIPS users mailling list <users at lists.opensips.org>
Objet : Re: [OpenSIPS-Users] Ratelimit usage


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/b625dc73/attachment-0001.html>


More information about the Users mailing list