StackExchange / StackExchange/StackExchange.Redis
How to connect to AWS ElastiCache instance where Multi-AZ feature is enabled (Cluster Mode Disabled)
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):
ConnectionMultiplexer.Connect("myserver.hbqmsl.ng.0001.usw1.cache.amazonaws.com:6379")(only primary endpoint)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)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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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