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

How to create a single redis connection #261

Open
first-mine opened this issue Jan 30, 2023 · 5 comments
Open

How to create a single redis connection #261

first-mine opened this issue Jan 30, 2023 · 5 comments

Comments

@first-mine
Copy link

I have tried creating a connection with pool_size = 1 and backlog=10 but every concurrent request creating new connection.

For 5 concurrent request this is the output.
netstat | grep redis
tcp 0 0 app-server:15174 app-redis-:6375 ESTABLISHED
tcp 0 0 app-server:14600 app-redis-:6375 ESTABLISHED
tcp 1 0 app-server:2666 app-redis-:6375 CLOSE_WAIT
tcp 0 0 app-server:15156 app-redis-:6375 ESTABLISHED
tcp 0 0 app-server:15158 app-redis-:6375 ESTABLISHED
tcp 0 0 app-server:15170app-redis-:6375 ESTABLISHED

Ideally it should have created 1 connection and queued the rest 4. Right ? Is this a issue from my side?

@zhuizhuhaomeng
Copy link
Contributor

did you call the set_keepalive to put the connection to the pool?

@first-mine
Copy link
Author

first-mine commented Jan 30, 2023

Yes, set_keepalive is there after connect.
local ok, err = red:set_keepalive(1000000, 100)

@first-mine
Copy link
Author

Even if set_keepalive wasn't there. It shouldn't have created 5 connection. Right ?

@zhuizhuhaomeng
Copy link
Contributor

Please show your code that can reproduce the problem

@first-mine
Copy link
Author

@zhuizhuhaomeng
One more observation I found.
For red:publish command, new connection is opening every time,
I have called the set_keepalive.
But for other operations like get, set, lpush, etc the same connection getting reused.
Is this a bug or is it supposed to be like this ??

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