Struct agreed::config::Config [−][src]
pub struct Config { pub cluster_name: String, pub election_timeout_min: u64, pub election_timeout_max: u64, pub heartbeat_interval: u64, pub max_payload_entries: u64, pub replication_lag_threshold: u64, pub snapshot_policy: SnapshotPolicy, pub snapshot_max_chunk_size: u64, pub catch_up_cancellation_policy: CatchUpCancellationPolicy, }
Expand description
The runtime configuration for a Raft node.
The default values used by this type should generally work well for Raft clusters which will be running with nodes in multiple datacenter availability zones with low latency between zones. These values should typically be made configurable from the perspective of the application which is being built on top of Raft.
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; andMTBF
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 thanMTBF
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
cluster_name: String
The application specific name of this Raft cluster.
This does not influence the Raft protocol in any way, but is useful for observability.
election_timeout_min: u64
The minimum election timeout in milliseconds.
election_timeout_max: u64
The maximum election timeout in milliseconds.
heartbeat_interval: u64
The heartbeat interval in milliseconds 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.
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.
replication_lag_threshold: u64
The distance behind in log replication a follower must fall before it is considered “lagging”.
This configuration parameter controls replication streams from the leader to followers in the cluster. Once a replication stream is considered lagging, it will stop buffering entries being replicated, and instead will fetch entries directly from the log until it is up-to-speed, at which time it will transition out of “lagging” state back into “line-rate” state.
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.
catch_up_cancellation_policy: CatchUpCancellationPolicy
The cancellation policy of the configuration change catch-up process used on this Raft node.
Implementations
impl Config
[src]
impl Config
[src]pub fn build(cluster_name: String) -> ConfigBuilder
[src]
pub fn build(cluster_name: 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.
pub fn new_rand_election_timeout(&self) -> u64
[src]
pub fn new_rand_election_timeout(&self) -> u64
[src]Generate a new random election timeout within the configured min & max.
Trait Implementations
impl<'de> Deserialize<'de> for Config
[src]
impl<'de> Deserialize<'de> for Config
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
impl<T> WithSubscriber for T
[src]fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>
[src]
fn with_current_subscriber(self) -> WithDispatch<Self>
[src]Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,