Raft Consensus
TensorDB’s clustering layer will use the Raft consensus protocol for leader election and log replication.
Architecture
┌─────────┐ ┌─────────┐ ┌─────────┐│ Node 1 │◄──►│ Node 2 │◄──►│ Node 3 ││ (Leader) │ │(Follower)│ │(Follower)│└─────────┘ └─────────┘ └─────────┘Design Goals
- Strong consistency: All reads and writes go through the Raft leader
- Automatic failover: If the leader fails, followers elect a new leader
- Append-only replication: TensorDB’s immutable fact model maps naturally to Raft’s replicated log
- Bitemporal preservation: All temporal metadata is replicated faithfully
How It Will Work
- Leader election: Raft elects a leader node among cluster members
- Write path: Writes go to the leader, which replicates to followers via the Raft log
- Commit: Once a majority acknowledge, the write is committed
- Read path: Reads can be served from any node (with configurable consistency)
Consistency Levels
| Level | Description | Latency |
|---|---|---|
| Strong | Read from leader only | Higher |
| Bounded staleness | Read from follower within time bound | Medium |
| Eventual | Read from any node | Lowest |