redis / ioredis

🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
MIT License
14.35k stars 1.19k forks source link

ioredis caching host when using a reader endpoint #941

Closed fedebrasburg closed 5 years ago

fedebrasburg 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). I realized when using ioredis with the reader endpoint it always uses the same cache (like it is caching the final host) but when I dig the reader endpoint it works fine (it returns a different cache every time).

Do you know if ioredis is caching the final host? How could I fix it?

Thank you

luin commented 5 years ago

ioredis doesn't cache host, but it does keep a long connection to the host. A reconnection (redis.disconnect(true)) will force ioredis to re-create a new connection, in which case a new host may be selected.

knoxcard commented 5 years ago

@fedebrasburg - close issue?

stale[bot] commented 5 years ago

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.

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

yurik94 commented 4 years ago

We need to add and remove read replicas without code deployes every time, do we need to open and close connections to reader endpoint for every request, so every read replica has a chance to be hit?