Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I kill idle redis clients

Tags:

redis

I want to timeout and kill idle redis clients. Is there a setting I can set to do this? I seem to remember setting a configuration somewhere but I can't seem to find it again.

I want this to be done automatically, rather than manually calling the client kill command.

like image 308
MonkeyBonkey Avatar asked Dec 19 '12 15:12

MonkeyBonkey


People also ask

What is Redis idle timeout?

The parameter connectTimeout is the timeout for attempting to connect Redis server instead of the close time of idle connections. Redis is not able to configure timeout for a specified Redis connection. But if you want to configure timeout for all Redis connections, you can configure it in Redis server ahead of time.

Do I need to close Redis connection?

Continuously opening connections without closing is not a good practice. This will not only consume your resources but may also lead to program crash. The maximum number of file descriptors that you can open simultaneously is 1024.


1 Answers

Have a look into the Redis configuration file (the one you use to launch Redis).

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0

Just check the parameter is not commented out, and change the timeout parameter to put a non zero value in seconds. The instance should be restarted to take this parameter in account.

To change this parameter on a running Redis instance, you can use a client command:

> src/redis-cli config set timeout 10
OK
> src/redis-cli config get timeout
1) "timeout"
2) "10"
like image 96
Didier Spezia Avatar answered Oct 19 '22 12:10

Didier Spezia