Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set redis connection timeout?

Tags:

redis

Where in the configuration file do I set the connection timeout for Redis?

I know there is a timeout setting in the config file, but that only applies for idle connections. I want the timeout to apply when I want to read from redis. I want it to time out only after N seconds, rather than the default.

like image 255
Henley Avatar asked Feb 09 '13 02:02

Henley


People also ask

How set Redis connection limit?

Redis can handle many connections, and by default, Redis has a maximum number of client connections set at 10,000 connections. You can set the maximum number of client connections you want the Redis server to accept by altering the maxclient from within the redis. conf file.

What is default Redis connection timeout?

From version 3.2 onwards, Redis has TCP keepalive ( SO_KEEPALIVE socket option) enabled by default and set to about 300 seconds.

What can cause Redis timeout?

Redis client uses a single TCP connection and can only read one response at a time. Even when a first operation times out, it does not stop the data being sent to/from the server. Because of this, it blocks other requests and causes timeouts.

What is Redis idle timeout?

By default, Redis will never close idle connections, which means that if you don't close your Redis connections explicitly, you will lock yourself out of your instance. To ensure this doesn't happen, Heroku Redis sets a default connection timeout of 300 seconds.


2 Answers

For anyone who is still looking for this, on a redis connnection string you can specify connectTimeout like below.

<add key="RedisConnectionString" value="your-redis-server,abortConnect=false,connectTimeout=1000,ssl=false,,password=your-password" />
like image 194
Illuminati Avatar answered Oct 17 '22 04:10

Illuminati


On console of redis set this configuration

config set timeout 300
like image 23
Otavio Voiski Avatar answered Oct 17 '22 02:10

Otavio Voiski