Skip to content

Conversation

@adam-fowler
Copy link
Collaborator

@adam-fowler adam-fowler commented Oct 23, 2025

  • Add readOnlyReplicaSelection selection to ValkeyClientConfiguration
  • Add new parameter nodeSelection to ValkeyClusterClient.nodeClient(for:). Before calling this work out if commands you want to run are readOnly and then combined with ValkeyClientConfiguration. readOnlyReplicaSelection work out the nodeSelection parameter.

@github-actions
Copy link

github-actions bot commented Oct 23, 2025

✅ Pull request no significant performance differences ✅

Summary

New baseline 'pull_request' is WITHIN the 'main' baseline thresholds.

Full Benchmark Comparison

Comparing results between 'main' and 'pull_request'

Host '83df2ba50b57' with 4 'x86_64' processors with 15 GB memory, running:
#18~24.04.1-Ubuntu SMP Sat Jun 28 04:46:03 UTC 2025

ValkeyBenchmarks

Client: GET benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 75 77 77 81 82 82 82 6
pull_request 74 76 76 79 80 80 80 6
Δ -1 -1 -1 -2 -2 -2 -2 0
Improvement % 1 1 1 2 2 2 2 0

Client: GET benchmark | parallel 20 | 20 concurrent connections metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 73 76 79 82 85 87 87 28
pull_request 73 76 79 84 87 95 95 28
Δ 0 0 0 2 2 8 8 0
Improvement % 0 0 0 -2 -2 -9 -9 0

Connection: GET benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 4 4 4 4 4 4 4 8
pull_request 4 4 4 4 4 4 4 8
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

Connection: GET benchmark – NoOpTracer metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 7 8 8 10 11 11 11 8
pull_request 7 8 8 10 11 11 11 8
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

Connection: Pipeline array benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 33 33 33 34 34 34 34 6
pull_request 33 33 34 34 34 34 34 6
Δ 0 0 1 0 0 0 0 0
Improvement % 0 0 -3 0 0 0 0 0

Connection: Pipeline benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 33 33 33 34 34 34 34 6
pull_request 33 33 33 34 34 34 34 6
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

HashSlot – {user}.whatever metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 18
pull_request 0 0 0 0 0 0 0 18
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

ValkeyCommandEncoder – Command with 7 words metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 754
pull_request 0 0 0 0 0 0 0 755
Δ 0 0 0 0 0 0 0 1
Improvement % 0 0 0 0 0 0 0 1

ValkeyCommandEncoder – Simple GET metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 1908
pull_request 0 0 0 0 0 0 0 1911
Δ 0 0 0 0 0 0 0 3
Improvement % 0 0 0 0 0 0 0 3

ValkeyCommandEncoder – Simple MGET 15 keys metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 343
pull_request 0 0 0 0 0 0 0 360
Δ 0 0 0 0 0 0 0 17
Improvement % 0 0 0 0 0 0 0 17

@adam-fowler adam-fowler marked this pull request as draft October 27, 2025 11:40
@adam-fowler adam-fowler force-pushed the readonly-replica branch 2 times, most recently from 25bf5aa to d16658d Compare October 28, 2025 10:40
@adam-fowler adam-fowler changed the title Readonly replica support Readonly replica selection Oct 28, 2025
@adam-fowler adam-fowler marked this pull request as ready for review October 28, 2025 11:37
Copy link
Collaborator

@nilanshu-sharma nilanshu-sharma left a comment

Choose a reason for hiding this comment

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

Mostly looks good. Added some comments around support for reads from all nodes.

}

@available(valkeySwift 1.0, *)
extension ValkeyClientConfiguration.ReadOnlyReplicaSelection {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is for replica selection, can we just call it ValkeyClientConfiguration.ReplicaSelection ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In future we would also want to add support for other flavors of valkey such as non-cluster mode clusters such as pure client side shared clusters with 1 leader and n replicas. For such configurations the replicas take read by default. So having a generic name like ValkeyClientConfiguration.ReplicaSelection will also make sense for that flavor of Valkey.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I included ReadOnly in the name because it is for readonly commands. To make it clearer I could call it ReadOnlyCommandReplicaSelection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually renamed it to ReadOnlyCommandNodeSelection as it can return the primary node as well

Copy link
Collaborator

@nilanshu-sharma nilanshu-sharma left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!
It's failing some documentation related checks but looks good overall.

Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
- Moved nodeSelection setting into it own function getNodeSelection
- Added `cycleAllNode`
- Renamed `ReadOnlyReplicaSelection` to `ReadOnlyCommandNodeSelection`

Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
Signed-off-by: Adam Fowler <adamfowler71@gmail.com>
@adam-fowler adam-fowler merged commit b813e95 into main Oct 30, 2025
12 of 13 checks passed
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