lua-resty-limit-traffic
lua-resty-limit-traffic copied to clipboard
when using "resty.limit.req" to control rate, actual request processing rate might exceed configured rate.
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 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.
sorry, this is a mistake. Actually I used lua_shared_dict
during testing, but results were also same with above. @agentzh
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
@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.
@NagamineLee Also detailed steps to reproduce the problem and your actual output in each step would be very useful.