[][src]Struct actix_raft::config::Config

pub struct Config {
    pub election_timeout_millis: u64,
    pub heartbeat_interval: u64,
    pub max_payload_entries: u64,
    pub metrics_rate: Duration,
    pub snapshot_dir: String,
    pub snapshot_policy: SnapshotPolicy,
    pub snapshot_max_chunk_size: u64,
}

The runtime configuration for a Raft node.

When building the Raft configuration for your application, remember this inequality from the Raft spec: broadcastTime ≪ electionTimeout ≪ MTBF.

In this inequality broadcastTime is the average time it takes a server to send RPCs in parallel to every server in the cluster and receive their responses; electionTimeout is the election timeout described in Section 5.2; and MTBF is the average time between failures for a single server. The broadcast time should be an order of magnitude less than the election timeout so that leaders can reliably send the heartbeat messages required to keep followers from starting elections; given the randomized approach used for election timeouts, this inequality also makes split votes unlikely. The election timeout should be a few orders of magnitude less than MTBF so that the system makes steady progress. When the leader crashes, the system will be unavailable for roughly the election timeout; we would like this to represent only a small fraction of overall time.

What does all of this mean simply? Keep your election timeout settings high enough that the performance of your network will not cause election timeouts, but don't keep it so high that a real leader crash would cause prolonged downtime. See the Raft spec §5.6 for more details.

Fields

election_timeout_millis: u64

The election timeout used for a Raft node when it is a follower.

This value is randomly generated based on default confguration or a given min & max. The default value will be between 200-300 milliseconds.

heartbeat_interval: u64

The heartbeat interval at which leaders will send heartbeats to followers.

Defaults to 50 milliseconds.

NOTE WELL: it is very important that this value be greater than the amount if time it will take on average for heartbeat frames to be sent between nodes. No data processing is performed for heartbeats, so the main item of concern here is network latency. This value is also used as the default timeout for sending heartbeats.

max_payload_entries: u64

The maximum number of entries per payload allowed to be transmitted during replication.

Defaults to 300.

When configuring this value, it is important to note that setting this value too low could cause sub-optimal performance. This will primarily impact the speed at which slow nodes, nodes which have been offline, or nodes which are new to the cluster, are brought up-to-speed. If this is too low, it will take longer for the nodes to be brought up to consistency with the rest of the cluster.

metrics_rate: Duration

The rate at which metrics will be pumped out from the Raft node.

Defaults to 5 seconds.

snapshot_dir: String

The directory where the log snapshots are to be kept for a Raft node.

snapshot_policy: SnapshotPolicy

The snapshot policy to use for a Raft node.

snapshot_max_chunk_size: u64

The maximum snapshot chunk size allowed when transmitting snapshots (in bytes).

Defaults to 3Mib.

Methods

impl Config[src]

pub fn build(snapshot_dir: String) -> ConfigBuilder[src]

Start the builder process for a new Config instance. Call validate when done.

The directory where the log snapshots are to be kept for a Raft node is required and must be specified to start the config builder process.

Trait Implementations

impl Debug for Config[src]

Auto Trait Implementations

impl Send for Config

impl Sync for Config

impl Unpin for Config

impl UnwindSafe for Config

impl RefUnwindSafe for Config

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,