perf(cassandra): token-aware host policy + parallel point reads for GetMessagesByIDs#257
Conversation
|
Warning Review limit reached
More reviews will be available in 37 minutes and 1 second. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
gocql defaults to round-robin coordinator selection, so single-partition queries often land on a non-replica that forwards to a replica — an extra intra-cluster hop on every read/write. Routing token-aware sends queries straight to a replica. Applies to all Cassandra consumers. https://claude.ai/code/session_01SH3qPffAG99zH4zJj9cvSN
…t reads GetMessagesByIDs used WHERE message_id IN ? — a multi-partition scatter funnelled through one coordinator that can't be token-routed and fails all-or-nothing on the slowest partition. Replace with bounded-concurrency single-partition point reads (each token-aware) via a testable fetchByIDs helper; results returned in input order, missing IDs omitted as before. https://claude.ai/code/session_01SH3qPffAG99zH4zJj9cvSN
cb9f5a9 to
f4ecb23
Compare
Summary
Split out of #239 — implements findings #5 and #7 from
docs/superpowers/specs/2026-05-28-history-service-performance-analysis.md, both of which target the Cassandra read path. The remaining findings (#2, #4) stay on #239; finding #1 (caching) is in #254.cassutilsetsTokenAwareHostPolicy(RoundRobinHostPolicy())so single-partition queries route straight to a replica instead of gocql's default round-robin coordinator. Repo-wide — affects every Cassandra consumer (history-service, room-service, message-worker, tools/loadgen). Compression deliberately out of scope.GetMessagesByIDsreplaces the multi-partitionINscatter with bounded-concurrency, token-aware single-partition point reads via a unit-testedfetchByIDshelper (errgroup+SetLimit(16)). Input order preserved, missing IDs omitted (contract unchanged). Each leg is now token-routed, compounding with #7.Why these two together
#5and#7are complementary: a multi-partitionINhas no single routing key, so even with token awareness it can't be routed to a replica — it falls back to round-robin coordinator selection. Converting theINinto N independent single-partition reads is what lets#7actually apply to the thread-parent hydration path. Shipping them together keeps the read-path improvement coherent.Test plan
make lintclean repo-widemake testgreen under-race— includes newfetchByIDstests (input order preserved, missing IDs omitted, concurrency limit respected, error propagation, race-safe writes) and the token-aware policy assertionmake test-integration SERVICE=history-service— to run in CI. ExistingGetMessagesByIDsintegration tests use order-independentElementsMatch+ empty/missing cases, compatible with the new implementation#7token-aware routing on a multi-node Cassandra (staging) — single-node testcontainers can't show the winNotes
docs/client-api.mdis untouched.#7is a shared-package change; default Cassandra routing is strictly better for partition-keyed access, but every Cassandra consumer should be sanity-checked before merge.https://claude.ai/code/session_01SH3qPffAG99zH4zJj9cvSN
Generated by Claude Code