request help: apisix.plugins.limit-count.limit-count-redis performance downgraded for continuous pressure
Issue description
Performance downgraded dramatically when pressure limit-count-redis continuously.
The qps is 6000+ and 90% latency is 30+ for 10000 requests.

But it downgraded to 500+ and 400+ for 100000 requests.

For 100000 requests you can see error logs like this: 2020/02/07 15:14:59 [crit] 32437#0: *149168 connect() to 10.112.16.139:6379 failed (99: Cannot assign requested address), client: 127.0.0.1, server: , request: "GET /index.html?jwt=... HTTP/1.0", host: "127.0.0.1:9080" 2020/02/07 15:14:59 [error] 32437#0: *149168 [lua] custom.lua:120: phase_fun(): failed to limit req: cannot assign requested address, client: 127.0.0.1, server: , request: "GET /index.html?jwt=... HTTP/1.0", host: "127.0.0.1:9080"
10.112.16.139 is the ip address of the redis server, it seems all redis connections are busy. But if I try to use the original limit count plugin(with redis policy), the performance looks good with the 100000 requests.
The code is like this:
local limit_redis_new = require("apisix.plugins.limit-count.limit-count-redis").new
below parts are in function _M.access(conf, ctx)
local function create_limit_obj(conf)
core.log.warn("create new limit-count plugin instance")
return limit_redis_new("plugin-"..plugin_name, 100000, 60, conf)
end
...
local conf = {
redis_host = "10.112.16.139",
redis_port = 6379,
redis_timeout = 1000,
}
local lim, err = core.lrucache.plugin_ctx(plugin_name, ctx, create_limit_obj, conf)
if not lim then
core.log.error("error create limit: ", err)
return 500
end
local delay, remaining = lim:incoming(accountId, true)
if not delay then
local err = remaining
if err == "rejected" then
return 503
end
core.log.error("failed to limit req: ", err)
return 500
end
core.response.set_header("X-RateLimit-Limit", limit,
"X-RateLimit-Remaining", remaining)
Environment
- apisix version (cmd:
apisix version): 1.0 - OS: Ubuntu 16.04.6 LTS
@membphis please have a look.
@JanLi-air please make a try with this PR: https://github.com/apache/incubator-apisix/pull/1110
old issue