lua-resty-limit-traffic icon indicating copy to clipboard operation
lua-resty-limit-traffic copied to clipboard

when using "resty.limit.req" to control rate, actual request processing rate might exceed configured rate.

Open NagamineLee opened this issue 5 years ago • 5 comments

http { limit_req_zone $uri zone=one:10m rate=1000r/s; server { location /limit-req { access_by_lua_block { local limit_req = require "resty.limit.req" local lim, err = limit_req.new("my_limit_req_store", 100, 0) ... if delay >= 0.001 then --ngx.sleep(delay) end } ... } } }

When using jmeter(threads=400, interval=300s) to simulate the stress test, jmeter test results show that actual request processing rate(hearly 1000r/s) has exceeded configured rate(100r/s).

even though start delay processing, the result is same.

NagamineLee avatar Oct 25 '18 05:10 NagamineLee

@NagamineLee You should use lua_shared_dict instead of limit_req_zone in your config. They are very different things. Do not mix them and read the docs.

agentzh avatar Oct 25 '18 17:10 agentzh

sorry, this is a mistake. Actually I used lua_shared_dict during testing, but results were also same with above. @agentzh

NagamineLee avatar Oct 26 '18 01:10 NagamineLee

sorry, this is a mistake. Actually I used lua_shared_dict during testing, but results were also same with above. @agentzh

I'm in the same boat as you; i test ngx_http_limit_req_module is OK

xiie avatar Jan 05 '19 09:01 xiie

@NagamineLee Please provide a minimal and self-contained example that we can easily reproduce the problem on our side. We don't want to guess.

agentzh avatar Feb 04 '19 02:02 agentzh

@NagamineLee Also detailed steps to reproduce the problem and your actual output in each step would be very useful.

agentzh avatar Feb 04 '19 02:02 agentzh