class

Raft::RTTMonitor

Inherits Reference < Object

Measures round-trip time to peers and auto-tunes heartbeat/election timeouts.

Only the leader sends Ping probes and computes tuned values. After tuning, the leader distributes a ConfigUpdate RPC to all peers so the entire cluster uses consistent timeouts (per etcd best practices).

Followers passively receive ConfigUpdate messages — they do not probe. All nodes respond to Ping with Pong regardless of role.

Tuning formula (from etcd):

  • Heartbeat interval = ~1.5x median RTT (clamped to 10ms–5000ms)
  • Election timeout min = 10x median RTT
  • Election timeout max = 20x median RTT

Enable via Config#rtt_tuning = true.

Constructors

new(node_id : String, transport : Transport, config : Config, is_leader : -> Bool)
Source

Instance methods

record_pong(from : String, sequence : UInt64) : Nil

Called by the node when a Pong is received. Records the RTT sample.

Source
rtt_stats

Returns current RTT statistics per peer.

Source
start(peers : Array(String)) : Nil

Starts the background measurement fiber.

Source
stop

Stops the measurement fiber.

Source

Nested types