Hi Sven Carstensen,
You can refer to the official Document on Cache management FAQs - Azure Cache for Redis | Microsoft Learn for detailed information.
The timeout exception and the following connection error from StackExchange.Redis
indicate potential client-side performance bottlenecks, particularly related to .NET ThreadPool usage:
RedisServerException) Error: WRONGPASS invalid username-password pair ConnectTimeout, command=HMSET, timeout: 5000, inst: 0, qu: 1, qs: 0, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 9, async-ops: 568, serverEndpoint: XYZ.westeurope.redis.azure.net:10000, conn-sec: 16.79, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: ABC (SE.Redis-v2.8.24.3255), PerfCounterHelperkeyHashSlot: 10240, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (**Busy=77**,Free=32690,Min=1,Max=32767), POOL: (Threads=106,QueuedItems=1,CompletedItems=2321851,Timers=27), v: 2.8.24.3255
This log shows that 77 worker threads were busy at the time of the failure, while the ThreadPool’s minimum thread count was just 1.
When the number of busy threads exceeds the minimum, the .NET ThreadPool throttles thread creation, which can delay Redis operations and lead to TimeoutException
errors. You can read more about this behavior in:
Increase the minimum thread count early in your app's lifecycle. Add this line of code as early as possible (e.g., in Program.cs
, Application_Start()
, or the main method):
System.Threading.ThreadPool.SetMinThreads(200, 200);
- This is not per-core: the values apply globally.
- Start with 200 and monitor; if the busy thread count still exceeds that, increase accordingly.
Monitor CPU and memory usage of the container or VM. If your Redis client is under heavy CPU/memory load, this can exacerbate timeouts.
Scale your application appropriately:
- If utilization remains high, consider scaling out (more instances) or scaling up (larger size).
- Refer to this guide on scaling and resource impact: Redis timeouts and client-side pressure
While these client-side performance improvements are crucial, please note that the "WRONGPASS"
error also indicates a possible authentication issue (e.g., with Managed Identity or token expiration). If you're using Azure Managed Identity, ensure token handling and Redis connection setup are configured correctly.