0

I'm setting up a master/slave Redis topology using the Lettuce client. My readPreference is slave_preferred and the topology has three slaves and one master.

The issue I'm experiencing is that once the StatefulRedisMasterSlaveConnection is stablished, all queries go to the same slave, instead of balancing the load between all available slaves.

I have also tried adding a commons-pool2 connection pool as per the documentation, but the behaviour seems to be the same.

I have also tried using a static topology discovery as well as a dynamic one.

Is there a way to balance the load between slaves and not have all queries go to the same slave?

Thank you

GCarbajosa
  • 236
  • 1
  • 4
  • 13

1 Answers1

0

The short answer is no.

The longer answer is:

Lettuce selects a replica per slot hash and uses the selected replica for read operations until the next topology refresh. This is by design to reduce CPU overhead.

You might want to follow ticket #834 as this one is to add capabilities for load balancing/round-robin across read replicas.

mp911de
  • 17,546
  • 2
  • 55
  • 95