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

Connection pool garbage collection of idle connections

Open jmspereira opened this issue 1 year ago • 1 comments

Version: What redis-py and what redis version is the issue happening on? redis-py 5.2.0 with redis 7.2.4

Platform: What platform / version? Python 3.10.12 on Ubuntu 22.04

Description:

Hey everyone,

I have an application that uses a Redis connection created from a connection from a connection pool. The pool works as expected, but there is a point during the lifetime of my application where a connection is not used for some time (i.e., it stays in the pool as an available connection). There is some configuration that I am not finding to discard unused connections after some time? Or do I have to manually close those connections?

Best regards, Jorge

jmspereira avatar Nov 08 '24 13:11 jmspereira

Hi, I haven't seen such a configuration in the code. The connections are stored in the connection_pool and reused - when a connection is acquired from the list with available connections - a health check is performed - the flow includes a validation that ensures the connection is healthy - in case it isn't - it is reconnected, but there is not logic to discard unused connections after predefined period.

petyaslavova avatar May 27 '25 10:05 petyaslavova

Since the question has been answered, I’ll close the issue for now. Feel free to reopen it if you need further assistance.

petyaslavova avatar Oct 09 '25 13:10 petyaslavova