We have a current Azure Premium instance running with no problems at around 1k operations per second.
We've created a new Azure Managed Redis instance. We naively thought just updating the connection string would allow us to easily move, but we cannot get it to work. The errors we get are:
The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: It was not possible to connect to the redis server(s) REDACTED/Subscription. ConnectTimeout, command=SUBSCRIBE, timeout: 5000, inst: 0, qu: 0, qs: 0, aw: False, bw: SpinningDown, rs: NotStarted, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 1, async-ops: 1, serverEndpoint: REDACTED, conn-sec: n/a, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: REDACTED(SE.Redis-v2.10.1.65101), IOCP: (Busy=0,Free=1000,Min=2,Max=1000), WORKER: (Busy=2,Free=32765,Min=2,Max=32767), v: 2.10.1.65101 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server, T defaultValue) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2110
at StackExchange.Redis.RedisSubscriber.Subscribe(RedisChannel channel, CommandFlags flags) in /_/src/StackExchange.Redis/RedisSubscriber.cs:line 416
It was not possible to connect to the redis server(s) REDACTED/Subscription. ConnectTimeout
We previously tried to upgrade our Premium Redis instance to Enterprise, but ran into similar problems. I beleive Managed Redis instances are also Enterprise, so am wondering if there's some issue with how we're connecting to Redis. Our class to get the Redis connection is as follows:
private static ConcurrentDictionary> Connections;
[UsedImplicitly]
public static void Initialize(ConnectionSettings settings)
{
ConnectionSettings = settings;
Connections = new ConcurrentDictionary>();
for (var i = 0; i < settings.RedisConnectionPoolCount; i++)
{
Connections.TryAdd(i, new Lazy(() =>
ConnectionMultiplexer.Connect(settings.ConnectionString)));
}
}
public static IDatabase GetDatabase()
=> GetConnection().GetDatabase();
private static bool AllLazyConnectionsLoaded;
private static object InitConnectionLock => new();
private static IConnectionMultiplexer GetConnection()
{
if (!AllLazyConnectionsLoaded)
{
lock (InitConnectionLock)
{
if (!AllLazyConnectionsLoaded)
{
var loadedLazyCount = Connections.Count(lazy => lazy.Value.IsValueCreated);
if (loadedLazyCount == Connections.Count)
{
AllLazyConnectionsLoaded = true;
}
else
{
return Connections.First(lazy => !lazy.Value.IsValueCreated).Value.Value;
}
}
}
}
var connectionID = FastConnectionPicker.GetRandomConnectionID(Connections.Count);
return Connections[connectionID].Value;
}