Skip to content

cluster-mode: report endpoint count and connection fan-out - #489

Merged
fcostaoliveira merged 6 commits into
masterfrom
feat/cluster-endpoint-summary
Jun 25, 2026
Merged

fcostaoliveira merged 6 commits into
masterfrom
feat/cluster-endpoint-summary

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

What

In --cluster-mode, surface the discovered cluster topology at two places so operators can see how many nodes the load generator actually fans out to.

Startup (stderr, once per run)

[RUN #1] Cluster topology: 6 endpoints discovered (3 primaries, 3 replicas)
           127.0.0.1:7000         primary   slots 0-5460          (1 slot range)
           ...
           127.0.0.1:7003         replica   -> 127.0.0.1:7000     (1 slot range)
[RUN #1] Total connections: 4 threads x 50 conns/thread x 6 endpoints = 1200
[RUN #1] Rate limit: 100 req/s/conn -> 60000 req/s aggregate target

Results summary (text + JSON)

6         Cluster endpoints (3 primaries, 3 replicas)
1200      Total connections (4 x 50 x 6)
60000     Aggregate rate-limit target (req/s)

Notes

  • Non-cluster runs are unchanged.
  • Both print sites derive counts from the same topology snapshot (build_topology_snapshot(), committed shard-group members only), so they agree and exclude the bootstrap seed connection / dead sockets.
  • The aggregate rate-limit target counts only request-generating connections — primaries always; replicas only when --read-preference routes reads to them — since idle replica connections never hit their per-connection limiter.
  • The startup block self-gates to print exactly once per run, after the bootstrap CLUSTER SLOTS commits (when slot ranges are known).

Review

Diff was put through a 7-lens adversarial review + verification pass (concurrency, slot-range reconstruction, count consistency, memory safety, output format, build/API integration, edge cases). All confirmed findings were fixed — notably a count discrepancy between the two print sites when the seed address differs from the CLUSTER-SLOTS-advertised address.

🤖 Generated with Claude Code


Note

Low Risk
Observability and reporting only; routing and benchmark logic are unchanged aside from calling the summary after topology commit.

Overview
In --cluster-mode, the PR adds operator-visible topology reporting at startup and in the final run summary, both driven by the same build_topology_snapshot() view (distinct host:port nodes from committed shard groups, not bootstrap/dead sockets).

After each successful CLUSTER SLOTS commit, print_topology_summary() logs to stderr (mutex-gated per run and per topology signature): endpoint counts, a capped per-node slot/range list, total connections (threads × conns/thread × endpoints), and when --rate-limiting is set, an aggregate req/s target that counts only traffic-bearing connections (primaries plus replicas when reads can use them).

benchmark_config::current_run_id is set at the start of run_benchmark() so those lines are labeled [RUN #N]. At run end, run_stats stores topology counts from one client snapshot; the text/JSON “run information” block adds cluster endpoints, total connections, and the same aggregate rate-limit figure so it matches the stderr startup block.

Non-cluster runs are unchanged.

Reviewed by Cursor Bugbot for commit 9ba2ed9. Bugbot is set up for automated code reviews on this repo. Configure here.

When --cluster-mode is set, surface the discovered topology at both the
start of each run and in the results summary:

- Startup (stderr, once per run): "[RUN #N] Cluster topology: K endpoints
  discovered (P primaries, R replicas)" followed by a per-endpoint list
  with the slot ranges each serves, then the total opened-connection
  fan-out (threads x conns/thread x endpoints) and, when --rate-limiting
  is set, the aggregate rate target.
- Results summary (text + JSON): Cluster endpoints, Total connections, and
  the aggregate rate-limit target.

Both sites derive counts from the same topology snapshot
(build_topology_snapshot, group members only), so they agree and exclude
the bootstrap seed connection. The aggregate rate target counts only
request-generating connections (primaries always; replicas only when
reads route to them), since idle replica connections never hit their
per-connection limiter.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@jit-ci

jit-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

A striped cluster advertises each node's slots as many disjoint CLUSTER
SLOTS ranges, one shard_group each, all pointing at the same reused
shard_connection. The previous snapshot emitted one entry per group, so a
9-node cluster reported "120 endpoints", inflated Total connections 13x
(each client opens one connection per node, not per range), and printed
120 lines.

Coalesce the snapshot by distinct host:port, merging each node's ranges,
so endpoint count == node count == per-client connection fan-out. Print
one compact line per node (slot count + range count) instead of the full
range enumeration, capped at 40 with an "... and N more" footer.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 633db8f. Configure here.

Comment thread cluster_client.cpp Resolved
fcostaoliveira and others added 4 commits June 25, 2026 10:57
Single-slot node printed '1 slots in 1 range'; derive the slot-word
suffix from the slot count too.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…948)

The startup stderr block printed once per run (first CLUSTER SLOTS
commit) while the results summary snapshots the topology at run end, so
a mid-run topology refresh could leave the two reporting different
endpoint/connection counts.

Gate the startup print on a (run id, topology signature) pair instead of
run id alone: it prints on the first commit and reprints whenever the
endpoint/role/slot-range shape changes, so the last stderr block matches
the run-end summary. Snapshot is also built before the gate now, so an
empty topology never consumes the gate.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@fcostaoliveira
fcostaoliveira merged commit 4f9d656 into master Jun 25, 2026
123 checks passed
fcostaoliveira added a commit that referenced this pull request Jun 25, 2026
Follow-up to #489 fixing two Cursor Bugbot findings: hold the print-gate mutex across the whole topology emit (no interleaving/superseded blocks), and label Total connections / rate-limit target 'at full ramp' under --clients-start so the figure isn't read as the count already opened.
fcostaoliveira added a commit that referenced this pull request Jun 25, 2026
…ort) (#490)

Backport of #489 (+ #491 fixes) to 2.4, re-implemented against 2.4's primary-only cluster model (m_slot_to_shard[16384]). Reports discovered endpoint count, total connection fan-out, and aggregate rate-limit target at benchmark start and in the results summary (text + JSON). Also enables the full CI matrix for the 2.4 branch.
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