Forum Discussion
iRule - URI/Referer Rate limit per minute
Hi Bruno,
the optimal TCL code for rate_limiting algorythms do strongly depend on your functional requirements. Someone may prefer a very fast but not that accurate algorithm (aka. see John's link) and others may want to use a very accurate algorithm using sliding time frames (aka. your posted code).
If your functional requirement mandates an algorythm that "garantees" less than X_Number of request to pass in a time frame of the "last" X_Seconds in every situation, then you have to stick with your solution.
But if you don't require such an accurate algorythm, then you should adopt the sample code provided by John to increase the overall performance. But be aware that the accuracy will then be decreased to some extend so that burst traffic may ocour (e.g. a settings of 3 request within 60 sec allows a well-timed request burst of up to 5 request within 1 secs (e.g. Burst Rate = rate_limit * 2 - 1 ).
Regarding your coding issues....
At least for the "set variable" and "main condition" part I can't find any coding issues. In my opinion your code represents is a good implementation of a typical sliding time frame algorithm. The only stuff I would like to recommentd, is to set a different KEY_VALUE. Instead of storing the URI as KEY_VALUE I would recommend to store a rather simple "1" (e.g. "table set -subtable $limiter $get_count 1 indef $static::windowSecs").
BTW: If the coding problems still persist then add some additional debug lines, to see whats happening behind the scenes and to allow pinpointing the section, command or variable that is causing trouble?
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com