I don't see how it could fail to be "fast enough", since $shtinc() is atomic. In other words if you were running 600 children (theoretically, please don't actually set children to 600), the operation $var(cps) = $shtinc(caps=>$var(cps)) will only happen one at a time, all other processes will wait until it is free before they can change it.
Regards, Kaufman ________________________________ From: Jon Bonilla (Manwe) via sr-users <[email protected]> Sent: Monday, December 8, 2025 1:20 PM To: [email protected] <[email protected]> Cc: Jon Bonilla (Manwe) <[email protected]> Subject: [SR-Users] High volume ratelimit CPS CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. Hi all Some time ago I asked about a way of limiting the CAPS sent to differnet gateways and in high CPS environment. I ended up implementing a htable based solution suggested by one member of the list. The solution was more or less like this one: modparam("htable", "htable", "caps=>size=11;initval=0;autoexpire=5;") modparam("htable", "timer_interval", 10) modparam("htable", "timer_procs", 4) $var(cps) = $rd + ":" + $timef(%S); $var(cps) = $shtinc(caps=>$var(cps)); if ($var(cps) > $var(capslimit)) { sl_send_reply("503", "CAPS limit reached for this destination $rd"); exit; } The problem with this approach is that it's not fast enough detecting the limit. If I set 500 CAPS as limit it will sometimes reach 550, 600, or even 700 before it rejects the rest of the requests during that second. I have complains from the destination and they are asking me to be more precise in the ratelimit process. Would ratelimit/pipelimit improve this? I don't even know if they would accept handling 1 second intervals at this rate. Any other suggestion? cheers, Jon -- PekePBX, the multitenant PBX solution https://urldefense.com/v3/__https://pekepbx.com__;!!KWzduNI!cnP3s-DaOIIkGX7GyYCRAewrQqO2H5MtlW7KCb5ctRj8Vi007BHhEKfFGehvRrmPmkMxV7YnOvXOy4z9AeBHy9U$
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
