<story><title>How to build a distributed throttling system with Nginx, Lua, and Redis</title><url>https://leandromoreira.com.br/2019/01/25/how-to-build-a-distributed-throttling-system-with-nginx-lua-redis/</url></story><parent_chain></parent_chain><comment><author>cobbzilla</author><text>For those working in a Java JAX-RS environment and looking for an additional rate filter on the app server itself, here is a similar Redis+Lua rate limiter implemented as a Jersey&amp;#x2F;JAX-RS filter [1].&lt;p&gt;It supports multiple limits, for example max 100 requests&amp;#x2F;minute and 10000&amp;#x2F;day, etc. The lua magic is here [2].&lt;p&gt;[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;cobbzilla&amp;#x2F;cobbzilla-wizard&amp;#x2F;blob&amp;#x2F;master&amp;#x2F;wizard-server&amp;#x2F;src&amp;#x2F;main&amp;#x2F;java&amp;#x2F;org&amp;#x2F;cobbzilla&amp;#x2F;wizard&amp;#x2F;filters&amp;#x2F;RateLimitFilter.java&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;cobbzilla&amp;#x2F;cobbzilla-wizard&amp;#x2F;blob&amp;#x2F;master&amp;#x2F;wi...&lt;/a&gt;&lt;p&gt;[2] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;cobbzilla&amp;#x2F;cobbzilla-wizard&amp;#x2F;blob&amp;#x2F;master&amp;#x2F;wizard-server&amp;#x2F;src&amp;#x2F;main&amp;#x2F;resources&amp;#x2F;org&amp;#x2F;cobbzilla&amp;#x2F;wizard&amp;#x2F;filters&amp;#x2F;api_limiter_redis.lua&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;cobbzilla&amp;#x2F;cobbzilla-wizard&amp;#x2F;blob&amp;#x2F;master&amp;#x2F;wi...&lt;/a&gt;</text></comment>
<story><title>How to build a distributed throttling system with Nginx, Lua, and Redis</title><url>https://leandromoreira.com.br/2019/01/25/how-to-build-a-distributed-throttling-system-with-nginx-lua-redis/</url></story><parent_chain></parent_chain><comment><author>bratao</author><text>Awesome post, from a fellow Brazilian!&lt;p&gt;We did a very similar implementation (although not distributed) for a similar problem, using Redis and Laravel.&lt;p&gt;We had MANY people crawling our website, and we would prefer that they use our API for that. Using Redis we block IPs who accessed our website more than X times not logged-in (200 URLs right now).&lt;p&gt;We also had the requirement that all good bots(Bing, Baidu, Google) should pass-thru without blocks or any slowdown.
Another requirement, was that those good bots should be verified(Reverse &amp;amp; Forward DNS Lookup) before entering out good bot list.&lt;p&gt;It is working great for our high-traffic website ( 2 Mi hits&amp;#x2F;day). You can check our work here:
&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;Potelo&amp;#x2F;laravel-block-bots&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;Potelo&amp;#x2F;laravel-block-bots&lt;/a&gt;</text></comment>