Is there any chance this feature will be added? It seems like a pretty common use case for folks who don't need sharding but do want a read backup.
Hi @vanrysss , what problem did you experience when using ioredis with Elastiche Redis?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.
Hi @luin, I came across this ticket while evaluating ioredis for use with Elasticache with cluster mode disabled, and can provide some more details.
Elasticache supports two types of replication, Cluster Mode enabled/disabled. See here
With cluster mode disabled, attempting to connect via ioredis's Cluster module yields the unsurprising error of:
ERR This instance has cluster support disabled
However, it would be nice if we could bypass the majority of the cluster-mode code, and just take advantage of the connection management and read-write splitting features.
This could potentially be achieved by manually specifying the master/slave roles in the nodes array when initializing the cluster. E.g.,
const cluster = new Redis.Cluster(
[
{host: 'r/w primary endpoint', port: 6379, role: 'master'},
{host: 'r/o slave endpoint 1', port: 6379, role: 'slave'}
{host: 'r/o slave endpoint 2', port: 6379, role: 'slave'}
],
{scaleReads: 'slave'}
);
@emadum Thanks for suggesting! Redis.Cluster is designed to communicate with the official Redis cluster (https://redis.io/topics/cluster-spec, cluster mode enabled with Elasticache), so we may have another class (like Redis.ReplicaGroup) for that use case. Currently there's no plan to implement that, but I'll revisit this about two or three months later. Pull requests for this feature will be always welcome.
@luin is there a workaround? Or we can just instantiate two separate clients and use them for writes and reads separately?
@luin is there a workaround? Or we can just instantiate two separate clients and use them for writes and reads separately?
Yeah the possible workaround would be using two client instances, one for master and the other for slave.
Most helpful comment
@emadum Thanks for suggesting!
Redis.Clusteris designed to communicate with the official Redis cluster (https://redis.io/topics/cluster-spec, cluster mode enabled with Elasticache), so we may have another class (likeRedis.ReplicaGroup) for that use case. Currently there's no plan to implement that, but I'll revisit this about two or three months later. Pull requests for this feature will be always welcome.