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

Support for reading from replicas in valkey-benchmark #1392

Open
wants to merge 8 commits into
base: unstable
Choose a base branch
from

Conversation

bluayer
Copy link

@bluayer bluayer commented Dec 5, 2024

Background
When conducting performance tests using valkey-benchmark, reading from replicas was not supported. Consequently, even in cluster mode, all reads were directed to the primary nodes. This limitation made it challenging to obtain accurate metrics during workload stress testing for performance measurement or before a version upgrade.

Related issue : #900

Changes

  1. Replaced the use of CLUSTER NODES with CLUSTER SLOTS when fetching cluster configuration. This allows for easier identification of replica slots.
  2. Support for reading from replicas by executing the client in READONLY mode.
  3. Support reading from replicas even during slot migrations.
  4. Introduced two CLI options --rfa to enable reading from all cluster nodes and --rfro to enable reading from replicas only. A warning added to indicate that write requests might not be handled correctly when using this option.

@bluayer bluayer force-pushed the benchmark-read-from-replica branch 2 times, most recently from e4e100b to 3882216 Compare December 5, 2024 09:31
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 3.89610% with 74 lines in your changes missing coverage. Please review.

Project coverage is 70.90%. Comparing base (105509c) to head (3882216).
Report is 8 commits behind head on unstable.

Files with missing lines Patch % Lines
src/valkey-benchmark.c 3.89% 74 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1392      +/-   ##
============================================
+ Coverage     70.83%   70.90%   +0.07%     
============================================
  Files           118      118              
  Lines         63549    63494      -55     
============================================
+ Hits          45013    45021       +8     
+ Misses        18536    18473      -63     
Files with missing lines Coverage Δ
src/valkey-benchmark.c 61.04% <3.89%> (+3.09%) ⬆️

... and 17 files with indirect coverage changes

@bluayer
Copy link
Author

bluayer commented Dec 8, 2024

I fully understand that the maintainers of this project are extremely busy and prioritize tasks based on the importance. However, I believe this PR could be a good contribution to this project. If you don't mind, can I ask for a PR review or a reviewer assignment? @zuiderkwast, @madolson

@madolson
Copy link
Member

@ranshid Can you take a look?

@madolson madolson requested a review from ranshid December 10, 2024 01:55
Copy link
Member

@ranshid ranshid left a comment

Choose a reason for hiding this comment

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

Mostly LGTM. some comments. specifically I did not understand why we are not supporting reading form the primnaries as well

src/valkey-benchmark.c Outdated Show resolved Hide resolved
src/valkey-benchmark.c Outdated Show resolved Hide resolved
src/valkey-benchmark.c Outdated Show resolved Hide resolved
src/valkey-benchmark.c Outdated Show resolved Hide resolved
src/valkey-benchmark.c Show resolved Hide resolved
@bluayer bluayer force-pushed the benchmark-read-from-replica branch 2 times, most recently from 76545cb to d1a13ed Compare December 11, 2024 14:53
bluayer and others added 8 commits December 12, 2024 02:17
1. The CLUSTER NODES command does not provide replicas' slot range. Therefore, I have changed to use the CLUSTER SLOTS command to implement read from the Replica.

2. If you use the CLUSTER NODES command, the string parsing is so long and complex that it makes the code difficult to read. In comparison, CLUSTER SLOTS makes the code much simpler and more concise.

3. As noted in the TODO comment, the migrating and importing information is not used.

Signed-off-by: bluayer <[email protected]>
Signed-off-by: bluayer <[email protected]>
1. Add CLI option and description for reading from replicas with cluster option.
2. If the user uses the replicas option, the READONLY command is automatically used when the client is created.

Signed-off-by: bluayer <[email protected]>
Signed-off-by: bluayer <[email protected]>
1. Update the slot by distinguishing whether it is a primary or a replica.

2. With the above change, the variable name "primaries" has been changed to "nodes".

Signed-off-by: bluayer <[email protected]>
Signed-off-by: bluayer <[email protected]>
Added a warning about writing requests with replicas option

Signed-off-by: bluayer <[email protected]>
Signed-off-by: bluayer <[email protected]>
Signed-off-by: bluayer <[email protected]>
Signed-off-by: bluayer <[email protected]>
No longer managing attributes about slots migration at the cluster node struct, so remove it.

Signed-off-by: bluayer <[email protected]>
The `CLUSTER SLOTS` command returns a node that is responsible for multiple slot ranges multiple times. Therefore, I modify it for creating a node only once using dict, even if there are multiple slot ranges.

Signed-off-by: bluayer <[email protected]>
- When users enable rfa(read_from_all) option, they can read from replica and primary.
- When users enable rfro(read_from_replicas only) option, they can read from replicas only.
- If users don't use any option related to replicas, they can read from primaries only.
- Add READONLY when enabling option for reading all nodes

Signed-off-by: bluayer <[email protected]>
@bluayer bluayer force-pushed the benchmark-read-from-replica branch from 9de2f81 to bd44040 Compare December 11, 2024 17:17
@bluayer
Copy link
Author

bluayer commented Dec 11, 2024

@ranshid Thanks for your review and suggestion. I fixed the lines based on your review and suggestion. Please take a look the changes.

@ranshid
Copy link
Member

ranshid commented Dec 11, 2024

@ranshid Thanks for your review and suggestion. I fixed the lines based on your review and suggestion. Please take a look the changes.

Thank you @bluayer I will try to take a look today but might not get to it and I will be on vacation till Monday. So sorry in advance if this will delay to next week.

@bluayer
Copy link
Author

bluayer commented Dec 12, 2024

Thank you @bluayer I will try to take a look today but might not get to it and I will be on vacation till Monday. So sorry in advance if this will delay to next week.

Thank you @ranshid for telling me that. Of course, I completely understand you because it's the holiday season! Don't worry about being postponed and have a great vacation ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants