Skip to content

Conversation

@petetanton
Copy link

I would like to be able to load balance read replicas to avoid overwhelming a particularly fast replica. With the ReadFromSlavePreferred class, I found that one or two nodes would end up taking the vast majority of the traffic whilst other nodes are doing very little work.

@mp911de
Copy link
Collaborator

mp911de commented Jan 8, 2018

Thanks for your pull request. Workload distribution depends on three factors when looking at slave/slave-preferred mechanisms:

  1. Response time of nodes
  2. The selected node (derives from response time as Nodes contains nodes ordered by response time)
  3. Caching (Cluster client selects a node once and caches the result until topology refresh)

In general, there is a primary decision, whether the actual node list should be sorted or random in general. It looks to me as this should be the bit where we look into as we could:

  1. Reuse existing ReadFrom settings without the need to create new ones
  2. Skip the PING roundtrip to determine response times
  3. Shuffle nodes beforehand

WDYT?

@petetanton
Copy link
Author

Sorry for my slow response.

Ideally, I would prefer a random list as this will ensure equal traffic between each read node.
It would be good to keep the PING as this will verify that the nodes are actually avaliable however there would be no need to measure the latency.
Any thoughts?

@mp911de
Copy link
Collaborator

mp911de commented Jan 30, 2018

I'm fine with keeping PING. I think I would add two options:

  1. Option to disable sort by latency
  2. Option to enable randomizing

There are no common configuration bits between Redis Cluster and Master/Slave right now and I'd like to keep Master/Slave fairly simple, without additional configuration options. Therefore, I'd introduce system properties that allow configuration without introducing config API in the first place.

@mp911de mp911de added the type: feature A new feature label Jan 30, 2018
mp911de added a commit that referenced this pull request Jan 30, 2018
Lettuce now allows to adjust how Redis Cluster and Master/Slave implementations sort their node list. The node list is sorted by default by latency to allow ReadFrom.NEAREST mode. By setting a system property, this behavior can be adjusted:

-Dio.lettuce.core.topology.sort=BY_LATENCY (default)
-Dio.lettuce.core.topology.sort=NONE (leave nodes as they were reported by Redis)
-Dio.lettuce.core.topology.sort=RANDOMIZE (shuffle nodes)
mp911de added a commit that referenced this pull request Jan 30, 2018
Lettuce now allows to adjust how Redis Cluster and Master/Slave implementations sort their node list. The node list is sorted by default by latency to allow ReadFrom.NEAREST mode. By setting a system property, this behavior can be adjusted:

-Dio.lettuce.core.topology.sort=BY_LATENCY (default)
-Dio.lettuce.core.topology.sort=NONE (leave nodes as they were reported by Redis)
-Dio.lettuce.core.topology.sort=RANDOMIZE (shuffle nodes)
@mp911de
Copy link
Collaborator

mp911de commented Jan 30, 2018

I added configuration options via System properties to Lettuce 4.5 and 5.1:

-Dio.lettuce.core.topology.sort=BY_LATENCY (default)
-Dio.lettuce.core.topology.sort=NONE (leave nodes as they were reported by Redis)
-Dio.lettuce.core.topology.sort=RANDOMIZE (shuffle nodes)

Closed via 2138dc6 and 90103db, snapshot builds are available via OSS Sonatype.

@adityak93
Copy link

For people stumbling here from google search (like me 2 weeks ago), please do check: https://aws.amazon.com/about-aws/whats-new/2019/06/amazon-elasticache-launches-reader-endpoint-for-redis/ for balancing load among read replicas. this was recently introduced by AWS (June 19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants