feat(raft): 节点间 RPC 连接池(先量化 → 优化 → ShardKV 受益) - #232
Conversation
先量化:dial-per-call vs 池,串行 5.2x、并发 12.4x(多分片真实场景),分配 428→16。 确认瓶颈后建 rpcPool:每对端缓存复用一个并发安全的 *rpc.Client,DialTimeout 拨号、ErrShutdown 重拨、callTimeout 支持 Propose 超时;包级共享池令每对端只一条多路复用连接。Raft Send*/callPropose 改用池,ShardKV 无需改动即受益(Put→ProposeToGroup→池,各组复制 Send*→池)。集群+shard+-race 全绿。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 13 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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 |
🐯 BanGD 数据库内核评审整体风险:🟡 中 变更总结:本 PR 将 Raft 节点间的 RPC 调用从「每次调用都 rpc.Dial+Call+Close」(每次一次 TCP 三次握手)改为连接池复用:新增
架构问题(共 2 项)
本次评审消耗 token:共 103771 tokens(输入 87991,输出 4900,缓存命中 10880,缓存写入 0)|维度 [concurrency, memory, lock, storage, performance]|补充阅读周边文件 [Raft/raft.go]|对抗式复核 3 票/条,过滤疑似误报 0 条 |
你说「链接池能做好优化吗,做好了就更新 shardkv」——按测量优先:先量化是不是真瓶颈,证实了再做,做好接进 ShardKV。
量化(measure-first)
BenchmarkRPC_*:并发下差距拉大到 12×(多分片真实场景,dial-per-call 卡 TCP 握手)。瓶颈证实。
优化
rpcPool:每对端缓存复用一个*rpc.Client(net/rpc Client 并发安全、单连接多路复用)。DialTimeout拨号、ErrShutdown重拨、callTimeout支持 Propose 超时。包级共享池 → 每对端一条多路复用连接。更新 ShardKV
Raft
Send*/callPropose改用池 → ShardKV 无需改动即受益(Put→ProposeToGroup→callPropose→池;各分片组复制Send*→池)。验证
集群 + shardkv 测试全绿、
-race净、集群稳定 10/10、全仓 18 包全绿、零依赖不变。详见docs/iteration-2026-08-05-rpc-connection-pool.md。🤖 Generated with Claude Code