Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 connections per multiplexer created when connecting to Azure Cache For Redis Server #2685

Open
kcormanmsft opened this issue Mar 28, 2024 · 1 comment

Comments

@kcormanmsft
Copy link

Not sure if this is specifically a library issue or more of an azure redis server issue, but azure redis team suggested I file an issue here.

We noticed when we switched our apps from Microsoft.Caching.Redis (so essentially an old fork of SE.Redis) to SE.Redis that our connection count as reported by our azure redis instances increased by 33%. An important point here is that we're connecting to Azure Cache for Redis instances that have clustering enabled, but only one shard. My understanding is that this should mean each multiplexer our app creates should yield 3 connections: one discovery connection, one interactive connection, and one pubsub connection. But when I run the app below to connect to an ACR instance I actually see 4 connections from my machine when I run client list in the server console.

Configuration of the Azure Cache for Redis server is a P1 SKU with Clustering enabled and shard count of 1.

Here's the app (all code is just in this one file, and then it has a nuget dependency on Stackexchange.Redis

using StackExchange.Redis;

namespace RedisTest
{
    internal class Program
    {
        private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
        {
            return ConnectionMultiplexer.Connect("<connection string redacted>");
        });

        public static ConnectionMultiplexer Connection
        {
            get
            {
                return lazyConnection.Value;
            }
        }

        public async Task WriteToCache(string key, string value)
        {
            IDatabase cache = Connection.GetDatabase();
            await cache.StringSetAsync(key, value);
        }

        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
            var prog = new Program();
            await prog.WriteToCache("testkey1", "val1");
            await Task.Delay(TimeSpan.FromMinutes(60));
        }
    }
}

@philon-msft
Copy link
Collaborator

Does CLIENT LIST show all four connections coming from your client machine's IP address? In a clustered cache there will be additional inter-node connections for data replication and coordination. Those will show up with a different IP from your client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants