redis: max number of clients reached

A client connection will remain open forever if you don't close it.

https://redis.io/topics/clients

Client timeouts By default recent versions of Redis don't close the connection with the client if the client is idle for many seconds: the connection will remain open forever.

However if you don't like this behavior, you can configure a timeout, so that if the client is idle for more than the specified number of seconds, the client connection will be closed.

You can configure this limit via redis.conf or simply using CONFIG SET timeout .


I think your redis connection is instantiating on every request causing it to reach the max connection limit, you should keep your redis instance in the global this will share the same redis instance, this should not cause too many connections anymore. The redis instance will have its own connection pool, you can limit your connection nums by set max_connections parameter to redis.ConnectionPool. If max_connections is set, then this object raises redis.ConnectionError when the pool's limit is reached.

POOL = redis.ConnectionPool(host= host, port=6379, db=0)
r = redis.StrictRedis(connection_pool=POOL)

Tags:

Python

Redis