Struct foca::Config

source · []
pub struct Config {
    pub probe_period: Duration,
    pub probe_rtt: Duration,
    pub num_indirect_probes: NonZeroUsize,
    pub max_transmissions: NonZeroU8,
    pub suspect_to_down_after: Duration,
    pub remove_down_after: Duration,
    pub max_packet_size: NonZeroUsize,
}
Expand description

A Config specifies the parameters Foca will use for the SWIM protocol.

Fields

probe_period: Duration

Specifies how often a random member will be probed for activity.

At the end of this period, if the member didn’t reply (directly or indirectly, see crate::Message) it’s declared crate::State::Suspect.

Should be strictly larger than Self::probe_rtt. Preferably more than twice its value since we need to wait for the indirect ping cycle. If unsure, err on the safe side with probe_rtt * 3 and tune later.

Must not be zero.

probe_rtt: Duration

How long to wait for a direct reply to a probe before starting the indirect probing cycle.

It should be set to a value that describes well your transport round-trip time. A reasonable value would be a high quantile (p99, for example) of your cluster-wide ICMP PING RTT.

Must be strictly smaller than Self::probe_period.

Must not be zero.

num_indirect_probes: NonZeroUsize

How many members will be asked to perform an indirect ping in case the probed member takes too long to reply.

This doesn’t need to be a large number: we’re essentially fanning out to ensure a message actually reaches the original ping target in case of poor transmission quality or weird partitions.

Setting this to 3-5 should be more than enough for a “modern” network.

max_transmissions: NonZeroU8

Specifies how many times a single update/broadcast will be sent along with a normal message.

A high value trades off bandwidth for higher chances of fully disseminating broadcasts throughout the cluster.

Reasonable values range from 5, for small clusters to 15 for very large clusters.

suspect_to_down_after: Duration

How long a Suspect member is considered active before being declared Down.

Here you want to give time for the member to realize it has been declared Suspect and notify the cluster that its actually active.

Higher values give more time for a member to recover from a false suspicion, but slows down detection of a failed state.

Very application-dependent. Smaller clusters likely want this value to be a small multiplier of Self::probe_period whereas large clusters can easily tolerate several seconds of wait.

Must not be zero.

remove_down_after: Duration

Governs how long Foca will remember an identity as being Down.

A high value is recommended to avoid confusing cluster members with partial joins. If in doubt use a high multiplier over the probe period, like 10 * probe_period.

max_packet_size: NonZeroUsize

The maximum packet size Foca will produce AND consume.

This is transport-dependent. The main goal is reducing fragmentation and congestion.

If using UDP as a transport, use rfc8085 guidelines and stick to a value smaller than your network’s MTU. 1400 is a good value for a in a non-ancient network.

Implementations

A simple configuration that should work well in a LAN scenario.

Generate a configuration for a LAN cluster given an expected total number of active members.

The cluster_size parameter is used to define how many times updates are disseminated (Config::max_transmissions) and how long Foca will wait before declaring a suspected member as down (Config::suspect_to_down_after).

Settings derived from memberlist’s DefaultLanConfig.

Generate a configuration for a WAN cluster given an expected total number of active members.

Settings derived from memberlist’s DefaultWanConfig.

See Config::new_lan.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more