StackExchange / StackExchange/StackExchange.Redis

ConnectionMultiplexer opens multiple connections to Sentinel and Standalone

Open
#2,395 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Hello,

Currently we are using StackExchange.Redis and custom connection pooling implementation that opens multiple connections to Redis as we have high volume of operations and usage in our applications which sometimes caused Timeouts. As of today we are using the following code:

multiplexer = ConnectionMultiplexer.Connect(redisConfiguration.ConfigurationOptions);

We recently updated our StackExchange.Redis version to the latest stable (v2.6.96) and I saw that there is a fix regarding the Endpoints collection which was getting modified on every other Connect method call after the first one. Another change we saw in one of the threads here in Github was that the CommandMap is now handled internally and does not need to be set when using Sentinel. I passed a logger to see what is happening and modified the code like this:

multiplexer = ConnectionMultiplexer.Connect(redisConfiguration.ConfigurationOptions, streamWriter);

What I saw from the logs surprised me. First there is a connection to Sentinel and then to Standalone. However if we use SentinelConnect only one connection to Sentinel gets opened:

multiplexer = ConnectionMultiplexer.SentinelConnect(redisConfiguration.ConfigurationOptions, streamWriter);

The reason we are updating to the latest version and to the usage of ConnectionMultiplexer.SentinelConnect is because when we open more connections we are getting the following error:

Sentinel: The ConnectionMultiplexer is not a Sentinel connection. Detected as: Standalone

In our case, we only need Sentinel connection as we do not need multiple Standalone connections being opened. Can you advise us on whether we should use Connect or SentinelConnect and why does Connect opens connections to Sentinel and Standalone?

Here are the logs when using ConnectionMultiplexer.Connect: https://pastebin.com/pLbdVgtH
Here are the logs when using ConnectionMultiplexer.SentinelConnect: https://pastebin.com/Y1Y1y5qy

Regards,
Martin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ConnectionMultiplexer.Connect and SentinelConnect entry points, then compare the two linked log captures to trace why Sentinel and Standalone connections are opened. Review the issue comments for the current understanding; done means documenting which method is intended for this configuration and whether the observed connection behavior is a bug.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.