2

When using ServiceStack.Redis, TimeoutException is thrown since all the pools are being used. How to resolve the timeout exception.

1 Answer 1

1

Possible connection leak

The TimeoutException only happens when the pools are full, i.e. when there are no connections available which is usually an indication that you have a connection leak in which case make sure that all redis clients resolved from the pool are released, which you can ensure by wrapping each usage in a using statement, e.g:

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

RedisManagerPool creates new connections instead when full

Another option to is to use the RedisManagerPool which instead of throwing a TimeoutException will create a new connection outside the pool, however this will usually just mask the problem of a connection leak and it will result in a high open/closed connection count.

Increase Pool Resource Settings

If you believe the TimeoutException is due to heavy load you can increase the pool size and timeout seconds, e.g:

var redisManager = new PooledRedisClientManager(
    redisReadWriteHosts, redisReadOnlyHosts,
    poolSizeMultiplier: 40, //connection pool size * no of hosts
    poolTimeOutSeconds: 5); //how long to block for available connection
1
  • ClientManager is initialized using Sentinel like this var objSentinel = new ServiceStack.Redis.RedisSentinel("127.0.0.1", "6379"); ServiceStack.Redis.IRedisClientsManager objClientManager = sentinel.Start(); How to get PooledRedisClientManager from Sentinel
    – Navaneeth
    Commented Mar 17, 2015 at 8:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.