-
Notifications
You must be signed in to change notification settings - Fork 52
add AZ_AFFINITY_REPLICAS_AND_PRIMARY read strategy example and diagram #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add AZ_AFFINITY_REPLICAS_AND_PRIMARY read strategy example and diagram #236
Conversation
Signed-off-by: Muhammad Awawdi <[email protected]>
@stockholmux @madolson |
add yourself to the authors as well |
@@ -28,6 +28,7 @@ GLIDE provides flexible options tailored to your application’s needs: | |||
* ```PRIMARY```: Always read from the primary to ensure the freshness of data. | |||
* ```PREFER_REPLICA```: Distribute requests among all replicas in a round-robin manner. If no replica is available, fallback to the primary. | |||
* ```AZ_AFFINITY```: Prioritize replicas in the same AZ as the client. If no replicas are available in the zone, fallback to other replicas or the primary if needed. | |||
* ```AZ_AFFINITY_REPLICAS_AND_PRIMARY```: Prioritize replicas in the same AZ as the client. If no replicas are available in the zone, fallback to the primary in the same AZ. If neither are available, fallback to other replicas or the primary in other zones. | |||
|
|||
In Valkey 8, ```availability-zone``` configuration was introduced, allowing clients to specify the AZ for each Valkey server. GLIDE leverages this new configuration to empower its users with the ability to use AZ Affinity routing. At the time of writing, GLIDE is the only Valkey client library supporting the AZ Affinity strategy, offering a unique advantage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change it to strategies
instead strategy
In this case, the client attempts to read from a replica in the same AZ. Since none are available in az-2, it falls back to a replica in another AZ, such as az-1 or az-3. | ||
and the average latency is, for example, about 800 microseconds. | ||
|
||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's confusing that in the first example the "super" client is the AZ_AFFINITY user, but later the "super" client becomes the AZ_AFFINITY_REPLICAS_AND_PRIMARY user.
I suggest having one example that clearly shows all three cases, and explaining when a user should prefer AZ_AFFINITY over AZ_AFFINITY_REPLICAS_AND_PRIMARY, and vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this a bit differently. The new example visually clarifies the differences between AZ_AFFINITY and AZ_AFFINITY_REPLICAS_AND_PRIMARY, illustrating real-world scenarios where each one fits best. I'd prefer to retain both examples.
Signed-off-by: Muhammad Awawdi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm generally fine with the content, but I think you need to add an update notice at the bottom of the blog.
@@ -28,8 +28,9 @@ GLIDE provides flexible options tailored to your application’s needs: | |||
* ```PRIMARY```: Always read from the primary to ensure the freshness of data. | |||
* ```PREFER_REPLICA```: Distribute requests among all replicas in a round-robin manner. If no replica is available, fallback to the primary. | |||
* ```AZ_AFFINITY```: Prioritize replicas in the same AZ as the client. If no replicas are available in the zone, fallback to other replicas or the primary if needed. | |||
* ```AZ_AFFINITY_REPLICAS_AND_PRIMARY```: Prioritize replicas in the same AZ as the client. If no replicas are available in the zone, fallback to the primary in the same AZ. If neither are available, fallback to other replicas or the primary in other zones. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general thoughts on updating blogs is... don't. Typically, blogs represent a slice-in-time picture of the technology. However, if you feel like it's important to update, I would add a small note (maybe in italics) at the bottom that the blog post was updated: include what you added and when. Something like "This blog was updated in May 2025 to include AZ_AFFINITY_REPLICAS_AND_PRIMARY
and related example"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we often attach this blog and send to users/customers, we prefer that it stays up-to-date
I added a notice regarding the blog update
Signed-off-by: Muhammad Awawdi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Adding documentation for the new read strategy AzAffinityReplicasAndPrimary
relates to issues valkey-io/valkey-glide#2792 and valkey-io/valkey-glide#3085
Issues Resolved
Check List
--signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the BSD-3-Clause License.