Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

330
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda