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

Connection pool not creating #260

Open
first-mine opened this issue Jan 26, 2023 · 2 comments
Open

Connection pool not creating #260

first-mine opened this issue Jan 26, 2023 · 2 comments

Comments

@first-mine
Copy link

`local red = redis:new()
red:set_timeout(10000)
local options_table = {}
options_table.pool_size = 1
options_table.backlog = 1

local ok, err = red:connect(redis_endpoint, redis_port, options_table)
ngx.say("reused times: ", red:get_reused_times())`

How to make sure that connection pool is created ???
For testing purpose kept the pool_size as 1, so that the same connection get reused.
But every time the red:get_reused_times() returns 0, that means new connection getting created everytime, instead of using the existing pool.

Is their any issue with the code ?

@zhuizhuhaomeng
Copy link
Contributor

you need to put the connection to the connection pool via set_keepalive.
go to https://github.com/openresty/lua-resty-redis#set_keepalive for deatail

@first-mine
Copy link
Author

@zhuizhuhaomeng I have tried that, using set_keepalive returning closed for every subsequent request.

The issue I am trying to solve here is, ERR max number of clients reached
This error is coming due to large number of redis connection in my application.
So, I thought creating a connection pool with backlog, would queue up those extra requests to process later instead of throwing that error.

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