Reputation: 1492
I am getting the following error when trying to query a very simple string (my application log level) from my azure redis cache that just suddenly appeared in my production environment (this query occurs frequently):
Failed to deserialize loglevel from Redis Cache: Timeout performing GET (5000ms), next: GET LoggingLevel:ApplicationAPI, inst: 2, qu: 0, qs: 1289, aw: False, rs: ReadAsync, ws: Idle, in: 130355, serverEndpoint: XXXX mgr: 10 of 10 available, clientName: application-api-67cdbb4cfd-lkqdk, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=3515,Free=29252,Min=1,Max=32767), v: 2.0.601.3402 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
I have read the thread that they are suggesting and I have also have read How to troubleshoot Azure Cache for Redis
Based on the metrics I have read in Azure dashboard, I do not believe I am exceeding my current memory or connection limits. It seems to have to do with my number of worker threads set in the thread pool. I am reading that I should:
"set the minimum configuration value for IOCP and WORKER threads to something larger than the default value"
I have also read that I can set my min thread count using ThreadPool.SetMinThreads(Int32, Int32)
api in .NET Core.
So basically my questions are:
Upvotes: 13
Views: 12338
Reputation: 1143
I will directly try to answer your questions since you have already understand the underlying problem.
It is safe if you know what you are doing (and I think you know what you are doing). If you would run it on another Kubernetes cluster service or even in IIS, it would also be safe.
You can set the value in the Main
method of Program.cs.
Yes, you should set it to something above 3515 (busy count in your exception message) and monitor your application and node metrics. You can start with 4000. However, it is a high number (I'm not saying "too high", just "high"). Therefore, you may need to create more pods instead of increasing minimum worker threads value this much. Unfortunately, there is no silver bullet here. You have to try a value, monitor your application (response times, CPU, RAM, etc.), and tweak the value.
Upvotes: 7