redis / node-redis

Redis Node.js client
https://redis.js.org/
MIT License
16.91k stars 1.89k forks source link

No round robin between cache instances when using a reader endpoint #1453

Closed tutecano1995 closed 2 years ago

tutecano1995 commented 5 years ago

Hi

I am trying to use the reader endpoint of an aws redis cache (https://aws.amazon.com/about-aws/whats-new/2019/06/amazon-elasticache-launches-reader-endpoint-for-redis/?nc1=f_ls). When I dig the reader endpoint it works fine (it returns a different cache every time). But, I realized when using node_redis with the reader endpoint it always uses the same cache, instead of doing round robin between the different cache instances. It seems like it keeps the connection with the final host, instead of using the reader endpoint each time.

How could I fix it? Do you know if there is a way of not keeping a long connection to the final host?

Thank you

knoxcard commented 5 years ago

I've switched over to this library https://github.com/luin/ioredis and everything works for me in my cluster environment.

Please let me know...thanks!

tutecano1995 commented 5 years ago

@knoxcard I tried with ioredis but I have the same problem. Did you use a specific configuration for making it work?

timschlechter commented 4 years ago

I struggled a while with this, but it turned out my expectations where wrong. I thought using the AWS reader endpoint it would evenly split incoming Redis commands over the replica nodes.

But it evenly splits incoming connections: https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Replication.Endpoints.html

So as long as you have more application instances (connections) then you have Redis replicas this is not a problem I guess.

KashyapPutta commented 4 years ago

@tutecano1995 I am also having same issue. Did you find a solution for this?

leibale commented 2 years ago

https://github.com/redis/node-redis/issues/1453#issuecomment-574841798