Raghav
Raghav

Reputation: 9628

Timeout exception while using Redis

I am using StackExchange.Redis in my application to store key/values. The issue I am getting is that while fetching/checking the cache for a key I am getting TimeOut Exception:

enter image description here

Here is the detailed exception:

System.TimeoutException was unhandled HResult=-2146233083
Message=Timeout performing EXISTS GlobalSettings, inst: 0, mgr: ExecuteSelect, err: never, queue: 56, qu: 56, qs: 0, qc: 0, wr: 0, wq: 1, in: 0, ar: 0, IOCP: (Busy=0,Free=1000,Min=2,Max=1000), WORKER: (Busy=20,Free=32747,Min=2,Max=32767), clientName: WIN-VDIGHSLJUBV
Source=StackExchange.Redis.StrongName StackTrace: at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor1 processor, ServerEndPoint server) at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor1 processor, ServerEndPoint server) at StackExchange.Redis.RedisDatabase.KeyExists(RedisKey key, CommandFlags flags)

I have the following code:

    IDatabase db = GetDatabase();
    return db.KeyExists(cacheKey);

and the exception I am getting is at line "db.KeyExists(cacheKey)".

Based on the issue I thought increasing timeout might help and therefore I did this in initialization:

redis = ConnectionMultiplexer.Connect(string.Format("{0},allowAdmin=true,syncTimeout=30000,connectTimeout=30000", redisConfig));

i.e I added the "syncTimeout=30000,connectTimeout=30000"

but that didn't help either.

Do I need to add timeouts to some other locations?

Do I need to look the fix for this issue at some other point of Redis logic?

Upvotes: 4

Views: 1411

Answers (1)

blakejwc
blakejwc

Reputation: 65

I just read through the following stack overflow post, and I think it might provide another piece of the puzzle: StackExchange.Redis.RedisTimeoutException: Timeout awaiting response

MÇT points out that one might need to increase the minimum thread count in the application's ThreadPool when, as I saw in your exception message,

WORKER: (Busy=20,Free=32747,Min=2,Max=32767)

The number of Busy worker threads is greater than the Min value, which represents the number of worker threads initially created.

Please take a look and his answer for the specific details. This posting is a simple attempt to direct an unanswered question to actionable information.

Upvotes: 2

Related Questions