# Raft Configuration

Configuration options for running a Raft cluster in production.

## Cluster Size

For fault tolerance with `f` failures, you need `2f + 1` nodes:

- 3 nodes: tolerates 1 failure
- 5 nodes: tolerates 2 failures  
- 7 nodes: tolerates 3 failures

## Election Timeout

The election timeout should be:

- At least 10x the network round-trip time (RTT)
- Typically 150-300ms in a single datacenter
- 500ms-2s across regions

## Heartbeat Interval

Set to roughly 1/3 to 1/10 of the election timeout:

```
heartbeat_interval = election_timeout / 3
```

## Log Compaction

Configure snapshot creation when the log grows too large:

| Threshold | Description |
|-----------|-------------|
| 10,000 entries | Minimum for frequent writes |
| 100MB | Size-based threshold |
| Daily | Time-based for low-write workloads |
