Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Config is a plain struct with public fields. Defaults come from Config::new(node_id, peers).

#![allow(unused)]
fn main() {
let mut config = Config::new(node_id, peers);
config.election_timeout_min_ticks = 10;
config.election_timeout_max_ticks = 20;
config.heartbeat_interval_ticks = 3;
config.tick_interval = Duration::from_millis(50);
}

Timing

FieldDefaultNote
election_timeout_min_ticks10§5.2 minimum election timeout.
election_timeout_max_ticks20Exclusive. Actual timeout is uniform in [min, max).
heartbeat_interval_ticks3Leader heartbeat interval. Must be < min.
tick_interval50msWall-clock duration of one engine tick.

The engine is tick-driven. A tick is whatever you say it is.

Backpressure

FieldDefaultNote
max_pending_proposals1024propose / add_peer / remove_peer return Busy above this in-flight count.
max_pending_applies4096Capacity of the driver → apply-task channel. When full, the driver awaits space.

Batching

Off by default. Turn it on if you have many concurrent proposals.

FieldDefaultNote
max_batch_delay_ticks0 (off)Hold proposals for up to this many ticks before flushing.
max_batch_entries64Flush immediately when the buffer reaches this size.

With batching on, N concurrent propose calls can commit in a single broadcast and fsync.

Snapshotting

FieldDefaultNote
snapshot_hint_threshold_entries1024The engine emits Action::SnapshotHint every time this many entries have been applied past the current floor. Set to 0 to disable.
max_log_entries0 (off)Live-log guardrail. When the number of log entries above the current snapshot floor exceeds this, the engine emits a SnapshotHint regardless of the applied-entries band. Protects against runaway log growth when apply is lagging.
snapshot_chunk_size_bytes64 KiBMaximum bytes per InstallSnapshot chunk.

Elections

FieldDefaultNote
pre_votetrue§9.6 pre-vote. A disrupted follower probes peers before bumping its term, so flapping nodes can’t force the rest of the cluster to step down on every reconnect.

Reads

FieldDefaultNote
lease_duration_ticks0 (off)§9 leader-lease. When the leader has received a majority AE ack within this many ticks, linearizable reads skip the ReadIndex round-trip and return immediately. Must be strictly less than election_timeout_min_ticks - heartbeat_interval_ticks, otherwise Config::validate rejects it.

See rustdoc for Config for the full type.