Skip to content

Node: add AZ Affinity ReadFrom strategy Support#2686

Merged
adarovadya merged 10 commits intovalkey-io:release-1.2from
mo-amzn:AZ-node-tests
Nov 20, 2024
Merged

Node: add AZ Affinity ReadFrom strategy Support#2686
adarovadya merged 10 commits intovalkey-io:release-1.2from
mo-amzn:AZ-node-tests

Conversation

@mo-amzn
Copy link
Copy Markdown
Collaborator

@mo-amzn mo-amzn 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.

@mo-amzn mo-amzn requested a review from a team as a code owner November 13, 2024 23:22
@mo-amzn mo-amzn 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
@mo-amzn mo-amzn self-assigned this Nov 14, 2024
@mo-amzn mo-amzn requested a review from avifenesh November 14, 2024 10:02
*
* @example
* ```typescript
* configuration.client_az = 'us-east-1a';
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
Member

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
Copy Markdown
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.

@avifenesh
Copy link
Copy Markdown
Member

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
Copy Markdown

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
Copy Markdown
Member

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
Copy Markdown
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

@mo-amzn mo-amzn 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
@mo-amzn mo-amzn 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 <mawawdi@amazon.com>

az NODE tests

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>

CR fixes

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>

CR change

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>

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

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>

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

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>

prettier

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>

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

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>
Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>
@mo-amzn mo-amzn mentioned this pull request Nov 19, 2024
@adarovadya
Copy link
Copy Markdown
Collaborator

inflightRequestsLimit?: number;
/**
* Availability Zone of the client.
* This setting ensures that read operations are directed to nodes within the specified AZ.
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

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

---------

Signed-off-by: Muhammad Awawdi <mawawdi@amazon.com>
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 <mawawdi@amazon.com>
@mo-amzn mo-amzn deleted the AZ-node-tests branch April 16, 2025 13:56
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