question

LataRajput-4031 avatar image
0 Votes"
LataRajput-4031 asked OuryBa-MSFT commented

Timeout errors in clients application which is connected with Windows Redis Server

Hi ,

I have implmentated multiple instances of StackExchange.Redis ConnectionMultiplexer, storing those objects and when I want to communicate with Redis server I take the least used one from the pool. in my web application by following the link "https://stackoverflow.com/questions/68549760/stackexchange-redis-connectionmultiplexer-pool-for-synchronous-methods/69264124#69264124" . Now i am calling the methods in Application start method like below -

var t = new ConnectionMultiplexerPool(10, ConfigurationManager.ConnectionStrings["RedisConnectionString"].ConnectionString + ",allowAdmin=True,connectTimeout=60000,Ssl=false");

IDatabase db = t.GetDatabase();
Now , i have used the loop to create 10 keys with 1mb size value of each. The issue is I am still getting the timeout error, and observed when i am accessing the application and using the code from shared link in GetDatabase method only one Redis instance is creating in pool and it comes out of the loop. And it never checking this condition var pending = connection.GetCounters().TotalOutstanding; So please help me i am calling this methods wrongly? or is there any other way of doing this. i have googled so many sites but i didnt get solution.

for (int i = 0; i < _pool.Length; i++)
{
var connection = _pool[i]; // at i=0 connection as null
if (connection == null)
{
_pool[i] = ConnectionMultiplexer.Connect(_redisConfigurationOptions);
return _pool[i].GetDatabase(); // at this line it create the instance for 1st count of loop and returns the db
}

var pending = connection.GetCounters().TotalOutstanding;
if (pending < leastPendingTasks)
{
leastPendingTasks = pending;
leastPendingDatabase = connection.GetDatabase();
}
}

return leastPendingDatabase;

azure-cache-redis
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

OuryBa-MSFT avatar image
0 Votes"
OuryBa-MSFT answered OuryBa-MSFT commented

Hi @LataRajput-4031 Thank you for posting your question.

With current versions of StackExchange.Redis, connection pools are not necessary or recommended. A single ConnectionMultiplexer instance can support a high load and many concurrent requests when configured properly and accessing data using the *Async methods. A pool of ConnectionMultiplexer instances running in the same process can actually add overhead and introduce conflicts and contention issues that lead to errors.

1MB is very large – Redis’s design is optimized to serve smaller pieces of data with very low latency. Transmitting such large values is likely to cause problems at multiple points in the system, especially where clients read and process the responses. I’d recommend breaking the data into smaller pieces or looking into another data store designed for large values.

General guidance for diagnosing timeouts:


Regards,
Oury


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@LataRajput-4031 Checking it the above answer was helpful. Please mark as accepted answer if it is helpful. Otherwise let us know how we can better assist.

Regards,
Oury

0 Votes 0 ·