Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when tested against concurrent requests more than 1000, tcp timeout errors occurred #93

Open
tgxhenry opened this issue Sep 12, 2019 · 1 comment

Comments

@tgxhenry
Copy link

When tested against concurrent requests more than 1000, tcp timeout errors occurred, detailed error message,lua tcp socket connect timed out, when connecting to 127.0.0.1:3306.
Personally, I think the multiple connections to mysql and keep-alive setting lead to the problem.
Any solution to fix the problem, like mysql connection pool ,or global mysql instance?

Below is part of the code used in the test.
###################################################
res, err, errcode, sqlstate = db:query("select * from country limit 1")
if not res then
ngx.say("Bad result", err)
return ngx.exit(500)
end

local json = require "cjson"
ngx.say(json.encode(res))

local ok, err = db:set_keepalive(60000, 100)
if not ok then
ngx.say("Failed to set keep alive")
return
end
###################################################

@zhiyong0804
Copy link
Contributor

when query failed, need to close db connection, so you need to do as below:
res, err, errcode, sqlstate = db:query("select * from country limit 1") if not res then ngx.say("Bad result", err) db:close() return ngx.exit(500) end

in addtion, you can change mysql max connection to a bigger value, and you can enable resty.mysql backlog feature. about this feature pls ref to https://github.com/openresty/lua-nginx-module/blob/master/doc/HttpLuaModule.wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants