Skip to content
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

Node: add AZ Affinity ReadFrom strategy Support #2686

Merged
merged 10 commits into from
Nov 20, 2024

Conversation

Muhammad-awawdi-amazon
Copy link
Collaborator

@Muhammad-awawdi-amazon Muhammad-awawdi-amazon commented Nov 13, 2024

Issue link

This Pull Request is linked to issue (URL): #643

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Commits will be squashed upon merging.

@Muhammad-awawdi-amazon Muhammad-awawdi-amazon requested a review from a team as a code owner November 13, 2024 23:22
@Muhammad-awawdi-amazon Muhammad-awawdi-amazon force-pushed the AZ-node-tests branch 3 times, most recently from b2bd25d to 512af5e Compare November 13, 2024 23:45
@Yury-Fridlyand Yury-Fridlyand added node Node.js wrapper testing Everything about testing labels Nov 14, 2024
node/src/BaseClient.ts Outdated Show resolved Hide resolved
*
* @example
* ```typescript
* configuration.client_az = 'us-east-1a';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this is the only type possible? should we restrict to one working standard or making sure we tell the user he was wrong?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdym here? enforcing the client_az to be in a certain format? and if not, throw an error message?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not throwing, loging.
Its more for the core level as its mutual, but the question is do we know what should be the right form and help the user more in order to not make mistakes.
Even on the level of saying known optional forms: AWS EC2 uses ... AWS EKS uses ... GCP uses ... so at least its easy for him to validate it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everyone has their own technical area and things can be confusing when you meet them first time.
Somebody might think its 1a for example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidentally deleted Yuri's comment here.

node/src/BaseClient.ts Outdated Show resolved Hide resolved
@avifenesh
Copy link
Collaborator

Some comments.
For the testing logic i will let @adarovadya review and approve. I know some of my questions might be relevant to Adar and not to you directly, feel free to tell her to address it.

| "preferReplica"
/** Spread the requests between replicas in the same client's AZ (Availability zone) in a round robin manner.
If no replica is available, route the requests to the primary.*/
| "AZAffinity"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| "AZAffinity"
| { type: "AZAffinity", clientAz?: string; }

That is more correct location of clientAz.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible that in the future we will want to support fully baked support for EC2, EKS and all the known and widely used platform. Meaning, the user will provide something else than clientAz, and I'm afraid that putting those together will make issues later.
Try to think about the possible design and let me know if you don't think it will affect. IDK, the designs options doc is existing, but no decision has been taken, so I can speculate as you. I can share the doc if you want to dive into this question more deeply.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sticked to the original, as when I updated it to what you're suggesting errors started appearing. LMK what you guys think

@Muhammad-awawdi-amazon Muhammad-awawdi-amazon force-pushed the AZ-node-tests branch 4 times, most recently from f045df9 to 5469747 Compare November 17, 2024 10:26
@valkey-io valkey-io deleted a comment from Yury-Fridlyand Nov 17, 2024
@Muhammad-awawdi-amazon Muhammad-awawdi-amazon force-pushed the AZ-node-tests branch 2 times, most recently from 00f12ef to ff525d7 Compare November 19, 2024 12:26
Signed-off-by: Muhammad Awawdi <[email protected]>

az NODE tests

Signed-off-by: Muhammad Awawdi <[email protected]>

CR fixes

Signed-off-by: Muhammad Awawdi <[email protected]>

CR change

Signed-off-by: Muhammad Awawdi <[email protected]>

Modified tests to dynamically pull the replicas number, and added more replicas to cluster config

Signed-off-by: Muhammad Awawdi <[email protected]>

updated number of replicas for the cluster, dropped the part for CMD as its irrelevant

Signed-off-by: Muhammad Awawdi <[email protected]>

prettier

Signed-off-by: Muhammad Awawdi <[email protected]>

Created a new cluster for AzAffinity in CME, and added Standalone tests for CMD

Signed-off-by: Muhammad Awawdi <[email protected]>
@adarovadya
Copy link
Collaborator

@@ -574,6 +574,19 @@ export interface BaseClientConfiguration {
* used.
*/
inflightRequestsLimit?: number;
/**
* Availability Zone of the client.
* This setting ensures that read operations are directed to nodes within the specified AZ.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If ReadFrom strategy is AZAffinity, this setting ensures that readonly commands are directed to replicas within the specified AZ if exits.

getServerVersion,
);

azCluster = await ValkeyCluster.createCluster(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can check the version before and to create it only for valkey 8 and above

!("value" in value)
)
return false;
return value.value.includes(get_cmdstat);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test will fail. The AZ strategy searching foe replica in the same az, if not exits it will other replica in round robin. so in this case every replica will run the get command once

@Muhammad-awawdi-amazon Muhammad-awawdi-amazon changed the title Az node tests Node: add AZ Affinity ReadFrom strategy Support Nov 20, 2024
Signed-off-by: Muhammad Awawdi <[email protected]>
Signed-off-by: Muhammad Awawdi <[email protected]>
Signed-off-by: Muhammad Awawdi <[email protected]>
Signed-off-by: Muhammad Awawdi <[email protected]>
Signed-off-by: Muhammad Awawdi <[email protected]>
Signed-off-by: Muhammad Awawdi <[email protected]>
@adarovadya adarovadya merged commit 3c25ab9 into valkey-io:release-1.2 Nov 20, 2024
19 checks passed
Muhammad-awawdi-amazon added a commit to Muhammad-awawdi-amazon/valkey-glide that referenced this pull request Nov 20, 2024
* Added AZAffinity strategy to Node.js

---------

Signed-off-by: Muhammad Awawdi <[email protected]>
prateek-kumar-improving pushed a commit that referenced this pull request Nov 26, 2024
* Added AZAffinity strategy to Node.js

---------

Signed-off-by: Muhammad Awawdi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node Node.js wrapper testing Everything about testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants