-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
help request: keeping redis connection alive #11372
Comments
need add red:set_keepalive(...) |
Hello, thank you for support. I managed to get pooled my connections according to the documentation here however it still closes the connection and puts it in pool, then expect me to recall red:connect() function before using it, so it does tcp handshake anyway. I guess its the way resty library is written, so we could close this issue if you don't have any suggestion for me 🙏 |
like this test . |
thank you 🙏 I managed to do so, now connection is created with first request and used many times. |
Description
Hello, I've been working on the limit-req plugin with redis and I realized apisix creates a new connection for every single request, so I think maybe I can alter this behaviour and if I can keep a single connection, it could perform faster after getting rid of three-way handshake.
Maybe you tried it already and it is a bad idea but I really need to get higher numbers 🙏
I've played a little in apisix/plugins/limit-req/limit-req-redis.lua
So it creates a connection once and keeps it under "self". My problem here is that it somehow terminates this connection after first request and the rest throws this error:
2024/06/25 18:29:23 [error] 242482#242482: *3933 [lua] limit-req.lua:171: phase_func(): failed to limit req: closed, client: x.x.x.x, server: _, request: "GET /test1/x HTTP/2.0", host: "xyz.com"
I failed to find the trigger that closes connection. Could you guide me please?
Environment
apisix version
): 3.9uname -a
): Ubuntu 22.04openresty -V
ornginx -V
): openresty/1.21.4.1curl http://127.0.0.1:9090/v1/server_info
):luarocks --version
):The text was updated successfully, but these errors were encountered: