Skip to content

perf: check cluster routing with one read of the state - #453

Merged
kacy merged 2 commits into
mainfrom
perf/cluster-slot-check
Nov 14, 2026
Merged

kacy merged 2 commits into
mainfrom
perf/cluster-slot-check

Conversation

@kacy

@kacy kacy commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Cluster mode served about 320k requests a second whether or not the client pipelined, against 870k (no pipeline) and 2.7M (pipeline of 16) standalone. Every command locked the migration state, a tokio mutex shared by every connection, and read the cluster state's async RwLock up to three times.

  • the migration state is a std::sync::RwLock. no holder awaits while holding it, and the per-command check only reads it
  • ClusterCoordinator::check_command makes the whole decision from one read of the cluster state: paused writes, replica redirects, the majority fence, CROSSSLOT and the slot check. it replaces is_replica/primary_addr_for_slot/reaches_majority_of_primaries/check_slot_with_migration/check_crossslot on the hot path
  • unit tests call check_command, and a new one checks that a replica sends writes to its primary with MOVED and serves reads

One-node cluster owning every slot against standalone, 50 clients, 1M requests, 32 cores:

standalone cluster before cluster after
SET, P=1 870k 327k 855k
GET, P=1 880k 319k 870k
SET, P=16 2.67M 318k 2.28M
GET, P=16 2.79M 316k 2.43M

With a pipeline of 16 cluster mode is still about 15% below standalone, from the one shared read lock each command takes.

@kacy
kacy merged commit 9deda12 into main Nov 14, 2026
12 checks passed
@kacy
kacy deleted the perf/cluster-slot-check branch November 14, 2026 16:27
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.

1 participant