StackExchange / StackExchange/StackExchange.Redis

How to connect to AWS ElastiCache instance where Multi-AZ feature is enabled (Cluster Mode Disabled)

Open
#2,129 2 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

Hi,

We have a Redis instance in AWS ElastiCache with one primary node and single replica node (just for the sake of enabling Multi-AZ feature on with Automatic Failover enabled), and we have so-called Cluster Mode Disabled. The first picture probably describes our setup in the best way - https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Replication.Redis-RedisCluster.html

Main motivation of re-creating our Redis cache instance with described setup (before we're being using just a single node) is to improve high availability. But as a bonus, also improving scalability by distributing read requests among 2 nodes instead of 1 is also nice.

But I am puzzled with how to correctly configure connection using ConnectionMultiplexer.Connect()?

We have next endpoints in AWS ElastiCache terminology (https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Endpoints.html#Endpoints.Find.Redis):
Primary Endpoint: myserver.hbqmsl.ng.0001.usw1.cache.amazonaws.com
Reader Endpoint: myserver-ro.hbqmsl.ng.0001.usw1.cache.amazonaws.com
Node 1 Endpoint: myserver-001.hbqmsl.0001.usw1.cache.amazonaws.com
Node 2 Endpoint: myserver-002.hbqmsl.0001.usw1.cache.amazonaws.com

So, could you please suggest the correct option to configure the connection to have both HA and scalability (requests not only always hit primary but also replica in round-robin manner):

  1. ConnectionMultiplexer.Connect("myserver.hbqmsl.ng.0001.usw1.cache.amazonaws.com:6379") (only primary endpoint)
  2. ConnectionMultiplexer.Connect("myserver.hbqmsl.ng.0001.usw1.cache.amazonaws.com:6379, myserver-ro.hbqmsl.ng.0001.usw1.cache.amazonaws.com:6379") (primary and replica endpoints)
  3. ConnectionMultiplexer.Connect("myserver-001.hbqmsl.0001.usw1.cache.amazonaws.com:6379, myserver-002.hbqmsl.0001.usw1.cache.amazonaws.com:6379") (node 1 and node 2 endpoints)

And can I still safely use a single instance of ConnectionMultiplexer in my web API application? I mean is there any issue when let say resolved nodes' IPs are cached, and when, for example, primary does down and replica switches to primary, then ConnectionMultiplexer tries to connect to not existing old primary node IP? Should we use any additional options to always respect DNS changes?

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 with the ConnectionMultiplexer.Connect entry point and the AWS ElastiCache endpoint documentation linked in the issue. Clarify the endpoint configuration for failover, read distribution, and DNS changes, with the work complete when those connection and single-multiplexer questions are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
backend, databases
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.