I think a static object is shared between multiple threads. Nevertheless, I got a high problem with the processor on one of my sites, so I took the windbg dump and was very surprised, I see the following:

We see that there are 10 instances of the ConnectionMultiplexer class. But my code creates ConnectionMultiplexer as a static object. This should mean that only one instance is created for all threads. So how does windbg show multiple instances?
This is my code to create a redis connection
public static class CacheConnection
{
private static StackExchangeRedisCacheClient _newconnectionDb;
public static StackExchangeRedisCacheClient NewConnectionDb
=> _newconnectionDb ?? (_newconnectionDb = NewRedisConnection());
private static IDatabase _connectionDb;
public static IDatabase ConnectionDb => _connectionDb ?? (_connectionDb = RedisConnection());
private static StackExchangeRedisCacheClient NewRedisConnection()
{
var serializer = new NewtonsoftSerializer();
return new StackExchangeRedisCacheClient(Connection, serializer);
}
private static IDatabase RedisConnection()
{
var cacheDatabase = Connection.GetDatabase();
return cacheDatabase;
}
public static ConnectionMultiplexer Connection => LazyConnection.Value;
private static readonly Lazy<ConnectionMultiplexer> LazyConnection = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(
System.Configuration.ConfigurationManager.AppSettings["CacheConnectionString"]), LazyThreadSafetyMode.PublicationOnly);
}
source
share