rivven-cluster
Distributed cluster coordination for the Rivven event streaming platform.
Overview
rivven-cluster provides the distributed coordination layer for Rivven, including leader election, failure detection, and partition assignment.
Features
| Feature | Description |
|---|---|
| Raft Consensus | Leader election and log replication using OpenRaft |
| redb Storage | Pure Rust persistent storage (zero C dependencies) |
| SWIM Gossip | Failure detection and membership management |
| Partitioning | Consistent hashing for partition assignment |
| QUIC Transport | Efficient, secure node-to-node communication |
Why redb?
Rivven uses redb instead of RocksDB for Raft log storage:
| Aspect | redb | RocksDB |
|---|---|---|
| Build time | ~10s | 2-5 min |
| Binary size | Minimal | +10-15 MB |
| Cross-compile | ✅ Works everywhere | ❌ Needs C++ toolchain |
| Docker musl | ✅ Works | ❌ Needs musl-g++ |
| ACID | ✅ Full | ✅ Full |
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ rivven-cluster │
├─────────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Raft │ │ SWIM │ │ Partition │ │
│ │ Consensus │ │ Gossip │ │ Manager │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ └───────────────────┼───────────────────┘ │
│ │ │
│ ┌────────────────┐ │
│ │ QUIC Transport │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Components
Raft Consensus
Used for metadata replication and leader election:
use ;
let config = RaftConfig ;
let node = new.await?;
SWIM Gossip
Decentralized failure detection:
use ;
let config = SwimConfig ;
let node = new.await?;
Partition Assignment
Consistent hashing with virtual nodes:
use ;
let ring = new; // 128 virtual nodes per physical node
ring.add_node?;
ring.add_node?;
let owner = ring.get_partition_owner?;
Configuration
cluster:
node_id: 1
bind_address: "0.0.0.0:9093"
raft:
peers:
- "node2:9093"
- "node3:9093"
election_timeout_min_ms: 150
election_timeout_max_ms: 300
gossip:
bind_port: 7946
known_peers:
- "node2:7946"
protocol_period_ms: 1000
partitioning:
virtual_nodes: 128
replication_factor: 3
Documentation
License
Apache-2.0. See LICENSE.