is it possible to change the error message 'max number of client reached' to null or empty string?
I'm using redis as a cache for my DB values and in cases that I can't get the values from the cache I will get it from the DB. if I could configure it in the redis it self it would be the best option for me because my code won't have to change in order to support that edge case.
if someone has some tips on how to avoid such errors it would be nice as well :) (I'm using php scripts with predis package)
The error message max number of clients reached
is clearly indicate that Redis is reached client limit and unable to serve any new requests.
Predis\Client
in code. Instead to create a connection object once (singleton
) and use it across process lifetime. The code probably create a new object on every request to Redis and keep all these connections open.php
processes are managed by a web server. The web server (e.g. apache prefork
, nginx php-fpm
) might leave processes for a long time both holding connections to Redis and exhaust server resources (mem, cpu).predis
library.Bottom line: the code/web server exhaust maxclients
limit.
If you don't have control over code/web server (e.g. nginx
), to reduce amount of error messages you can:
maxclients
over 10k (depends on your Redis server resources). This will reduce frequency of error messages.timeout
(use it with cautious, as your code may assume that connections are never timeout). This will release old connections from a connection pool.tcp-keepalive
from 300
seconds to less than timeout
. This will close connections to dead peers
(clients that cannot be reached even if they look connected).