Skip to content

Conversation

@ariesdevil
Copy link
Contributor

@ariesdevil ariesdevil commented Nov 28, 2025

Add Multi-Raft Support via openraft-multi Crate

Summary

This PR introduces Multi-Raft support for OpenRaft through a new standalone crate openraft-multi.

It provides network adapters for efficient connection sharing across multiple Raft groups within a single process.

This is a separate crate that does not affect the core openraft crate.

Key Features

  • Connection Sharing - Multiple Raft groups share the same network connections, reducing resource overhead
  • Simple Adapter Pattern - Just implement GroupedRpc on your router, get RaftNetworkV2 for free
  • Type Safety - Full generic support for custom GroupId types
  • Runtime Agnostic - Works with any async runtime (tokio, compio, monoio, etc.)

New Components

Component Description
GroupedRpc trait Defines RPC methods with (target, group_id) routing
GroupNetworkAdapter Wraps GroupedRpc impl, auto-implements RaftNetworkV2
GroupNetworkFactory Simple wrapper holding (factory, group_id)

Fix: #1485

Checklist

  • Updated guide with pertinent info (may not always apply).
  • Squash down commits to one or two logical commits which clearly describe the work you've done.
  • Unittest is a friend:)

This change is Reviewable

@drmingdrmer
Copy link
Member

There are some design issue with this PR, for example, should a MultiRaftNetwork implementation manage connections to more than one nodes? It looks it is a wrapper of a single RaftNetwork, then it should not have multiple connections. But if it does not have multiple connections, how does it route request belonging to different group to corresponding nodes?

IMHO, network sharing is a just a application level task to do, it does not require the lib(openraft) to add any feature to support it.

@ariesdevil
Copy link
Contributor Author

PTAL again

@ariesdevil ariesdevil force-pushed the multi-raft branch 3 times, most recently from 867a863 to 9f38ace Compare November 30, 2025 06:14
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

@drmingdrmer reviewed 5 of 37 files at r1, 7 of 18 files at r2, 10 of 19 files at r3, 23 of 23 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ariesdevil)


multiraft/src/network.rs line 40 at r4 (raw file):

{
    /// Send AppendEntries to target node for a specific group.
    fn send_append_entries(

keep the method names aligned with the RaftNetworkV2 methods: without send_ prefix.


examples/mem-log/Cargo.toml line 18 at r3 (raw file):

[dependencies]
openraft = { path = "../../openraft", default-features = false, features = ["type-alias", "tokio-rt"] }

why does it need to enable tokio-rt?

@ariesdevil
Copy link
Contributor Author

Fixed, PTAL again.

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

@drmingdrmer reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ariesdevil)

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ariesdevil)

@drmingdrmer drmingdrmer added this pull request to the merge queue Nov 30, 2025
Merged via the queue into databendlabs:main with commit 9b6b529 Nov 30, 2025
37 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.

Support Multi-Raft

2 participants