Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

325
Views
AWS Redis Reader endpoint and ioredis

We want our Redis to be more scalable and we want to be able to add more read instances.

I am trying to use this new Reader endpoint: https://aws.amazon.com/about-aws/whats-new/2019/06/amazon-elasticache-launches-reader-endpoint-for-redis

However I dont see any easy or automated way for ioredis to use that approach where I can set up which endpoint will be for writes and which one for reads. Even here I can see the recommended approach at the end is to "manually split": https://github.com/luin/ioredis/issues/387

Do you know any existing solution or good approach where I can set up which endpoints will be used for writes and which one will be used for reads?

The most straightforward for me right now is some kind of "proxy" layer, where I will create two instances of Redis and I will send all writes to the primary endpoint and all reads to Reader endpoint. However I would prefer some better (or well tested) approach.

PS: I tried to "hack it" with Cluster functionality of ioredis, but even the simple connection without any functionality and one - primary endpint - fails with ClusterAllFailedError: Failed to refresh slots cache. (To have Reader endpoint enabled - the Cluster mode must be off)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Just keep in mind how it ended

We had two instances (or reused the same instance if the URL was the same)

 redis = new Redis(RKT_REDIS_URL.href, redisOptions) if (RKT_REDIS_READER_URL.href === RKT_REDIS_URL.href) { redisro = redis } else { redisro = new Redis(RKT_REDIS_READER_URL.href, redisOptions) }

And then it is used first for writes and another one for reads.

 redis.hmset(key, update) redisro.hmget(key, field)

However, after a while we have adopted clustered Redis and it is much better and we can recommend it. In addition, the ioredis npm module is able to use it without problems (you don't have to configure anything, you only have to configure the endpoint that, for example, is provided by AWS and that's it).

This was our setup

 redisOptions.scaleReads = 'master' redis = new Redis.Cluster([RKT_REDIS_URL.href], redisOptions)

The options for scaleReads are

scaleReads is "master" by default, which means that ioredis will never send queries to slaves. There are three other options available:

"all": Send write queries to masters and read queries to random masters or slaves. "slave": sends write queries to the masters and read queries to the slaves.

https://github.com/luin/ioredis

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!