Skip to content

[v3.x] Use Replicas For Read#1430

Open
Cardmarket-Sijing wants to merge 6 commits into
predis:mainfrom
Cardmarket-Sijing:3.x-clusterLoadBalancing
Open

[v3.x] Use Replicas For Read#1430
Cardmarket-Sijing wants to merge 6 commits into
predis:mainfrom
Cardmarket-Sijing:3.x-clusterLoadBalancing

Conversation

@Cardmarket-Sijing
Copy link
Copy Markdown

original PR: #1411
PR for v2.x: #1414

This is a proposition on how load could be balanced for replicated clusters.

See:
#595 #392 #173 #579

Added separate pool and slot map for cluster replicas
Use replicas to serve read requests
This adds a dependency on the replication strategy for detecting read commands. The detection could be moved to the redis cluster strategy or to a separate class included in both strategies.

Also this doesn't allow for the user to configure how the replicas should be used. Future improvements could be:

prefer replicas for reads, fallback to primary
randomly select between replicas and primaries to evenly distribute
This splits up the slots of the primary between replicas. Another idea would be to share the slots between all replicas and select the replica (randomly) for each command

Cardmarket-Sijing and others added 5 commits January 22, 2024 10:40
* Added separate pool and slot map for cluster replicas
* Use replicas to serve read requests

This adds a dependency on the replication strategy for detecting read commands. The detection could be moved to the redis cluster strategy or to a separate class included in both strategies.

Also this doesn't allow for the user to configure if and how the replicas should be used. Future improvements could be:
* prefer replicas for reads, fallback to primary
* randomly select between replicas and primaries to evenly distribute

This splits up the slots of the primary between replicas. Another idea would be to share the slots between all replicas and select the replica (randomly) for each command
Disable load balancing behavior by default to ensure backwards compatibility.
Redis Cluster now takes the `loadBalancing` option into account
Added documentation for the cluster load balancing option
@Cardmarket-Sijing Cardmarket-Sijing marked this pull request as ready for review January 22, 2024 10:00
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 22, 2024

Coverage Status

coverage: 92.444% (+0.008%) from 92.436%
when pulling c45dbeb on Cardmarket-Sijing:3.x-clusterLoadBalancing
into cf28b2a on predis:main.

@Cardmarket-Sijing
Copy link
Copy Markdown
Author

Linting errors in unchanged files seem out of scope

@tillkruss tillkruss changed the title v3.x feat: Use Replicas For Read [v3.x] Use Replicas For Read Jan 22, 2024
@tillkruss
Copy link
Copy Markdown
Member

@vladvildanov Should we try to do this without a breaking change, or niche enough?

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

Development

Successfully merging this pull request may close these issues.

3 participants