redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

Use single connection instead of connection pool

Open NikolaBorisov opened this issue 1 year ago • 1 comments

Hello,

I was kind of wondering why redis-py is using a connection pool instead of using a single connection for all the requests to redis. Since redis is single threaded a single connection would not impact how quickly this works. Opening a new connection for every redis query is problematic because you can run out of connections if there is a sudden burst of requests.

NikolaBorisov avatar Jul 02 '24 23:07 NikolaBorisov

If you want to use a single connection, Redis.from_url(..., single_connection_client=True).

akx avatar Oct 23 '24 10:10 akx

Usage of single_connection_client=True implies that the next request will be sent only after the previous one has been completed.

I wonder how much more performant it would be to implement command pipelining through single connection in asyncio client, returning futures for command execution methods.

iamdbychkov avatar Nov 15 '24 14:11 iamdbychkov

By the way https://github.com/stackexchange/stackexchange.redis Does that:

https://stackexchange.github.io/StackExchange.Redis/PipelinesMultiplexers https://stackexchange.github.io/StackExchange.Redis/PipelinesMultiplexers#multiplexing

iamdbychkov avatar Nov 15 '24 15:11 iamdbychkov

Closing the issue since the initial question has been answered. Please feel free to reopen it if further assistance is needed.

petyaslavova avatar May 09 '25 14:05 petyaslavova