Skip to content

Instantly share code, notes, and snippets.

View JonCole's full-sized avatar

Jon Cole JonCole

  • Microsoft Corporation
View GitHub Profile
@JonCole
JonCole / DiagnoseRedisErrors-ClientSide.md
Last active January 6, 2020 17:52
Diagnosing Redis errors caused by issues on the client side
@JonCole
JonCole / DiagnoseRedisErrors-ServerSide.md
Last active December 2, 2021 16:25
Diagnosing Redis errors on the server side
@JonCole
JonCole / SE.Redis-SetAbortConnectToFalse.md
Last active March 25, 2021 15:55
StackExchange.Redis - "disconnected multiplexer" error

The Symptom

An application is using StackExchange.Redis to connect to their Redis instance and everything is working fine until suddenly exceptions like this start happening.

It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail.
at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Func`1 multiplexerFactory, TextWriter log)
at MyApp.Web.Redis.StackExchangeClientConnection..ctor(ProviderConfiguration configuration)
at MyApp.Web.Data.GetInventoryData()

The Cause

@JonCole
JonCole / ThreadPool.md
Last active March 6, 2024 05:03
Intro to CLR ThreadPool Growth

ThreadPool Growth: Some Important Details

The CLR ThreadPool has two types of threads - "Worker" and "I/O Completion Port" (aka IOCP) threads.

  • Worker threads are used when for things like processing Task.Run(…) or ThreadPool.QueueUserWorkItem(…) methods. These threads are also used by various components in the CLR when work needs to happen on a background thread.
  • IOCP threads are used when asynchronous IO happens (e.g. reading from the network).

The thread pool provides new worker threads or I/O completion threads on demand (without any throttling) until it reaches the "Minimum" setting for each type of thread. By default, the minimum number of threads is set to the number of processors on a system.

Once the number of existing (busy) threads hits the "minimum" number of threads, the ThreadPool will throttle the rate at which is injects new threads to one thread per 500 milliseconds. This means that if your system gets a burst of work needing an IOCP thread, it will proces