Redis Timeout optimization. Need suggestions

时间:2018-06-04 16:47:36

标签: c# redis servicestack

I am getting this exception -Redis Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use. I have set ServiceStack.Redis.PoolSizeMultiplier to 100 and ServiceStack.Redis.PoolTimeOutSeconds to 50. But i am still getting errors. What do you suggest. To increase or decrease this timeout value? I need some explanation about this Redis.TimeOutValue. What are advantages of increasing these values?

1 个答案:

答案 0 :(得分:3)

This error message indicates that all Redis connections are currently in use and that the client timed out waiting for a free connection from the pool to be available.

This can also happen if your redis client connections are not properly disposed of after usage. Make sure all your Redis Client instances are disposed after usage, e.g. by using a using {} statement:

using (var redis = redisManager.GetClient())
{
    //...
}

Another solution to avoid this error is to switch to using the RedisManagerPool which will create a new connection outside of the pool after the pool size has been exceeded, however this could be masquerading an issue that your Redis clients are not being properly disposed.