Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config {
Show 16 fields pub cluster_id: [u8; 16], pub id: NodeId, pub members: Vec<NodeId>, pub seed: [u8; 32], pub max_batch_bytes: u32, pub max_message_bytes: u32, pub max_in_flight_slots: u32, pub max_outstanding_proposals: u32, pub retransmit_interval: u64, pub hedge_min: u64, pub hedge_max: u64, pub silent_leader_takeover: bool, pub leader_order: Vec<NodeId>, pub placement: bool, pub placement_sustain: u64, pub placement_hold: u64,
}
Expand description

Configuration of one replica, checked by crate::Replica::new.

Every member must use the same cluster_id, members (the initial membership), leader_order and max_batch_bytes; seed must be fresh CSPRNG output on every start, including restarts. Config::new fills the limits and timers with defaults for a LAN; guide::tuning explains each field and when to change it.

§Examples

use quepaxa::{Config, NodeId};

const MILLI: u64 = 1_000_000;
let members = vec![NodeId(0), NodeId(1), NodeId(2)];
let mut cfg = Config::new(*b"orders-cluster-1", NodeId(1), members, [3; 32]);
// A cluster spread over regions with ~150 ms round trips:
cfg.retransmit_interval = 400 * MILLI;
cfg.hedge_max = 3_000 * MILLI;
cfg.leader_order = vec![NodeId(1), NodeId(0), NodeId(2)];

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§cluster_id: [u8; 16]

Identifies the cluster; messages from other clusters are dropped.

§id: NodeId

This replica.

§members: Vec<NodeId>

All replicas, including this one.

§seed: [u8; 32]

Randomness for proposal priorities. Liveness relies on the network being unable to predict it, so never reuse a seed across starts.

§max_batch_bytes: u32

Upper bound on the encoded entries of one batch (one slot), at least 64. Cluster-wide: every member must use the same value.

§max_message_bytes: u32

Upper bound on one encoded network message; larger inputs are dropped unread. Must be at least 2 * max_batch_bytes + 1024 (a reply can carry two full values).

§max_in_flight_slots: u32

How many slots this replica may drive concurrently.

§max_outstanding_proposals: u32

How many local proposals may be pending before Error::Busy.

§retransmit_interval: u64

How often an unanswered record request is re-sent, in nanoseconds. The default (50 ms) suits a LAN; across regions set it above the round trip to the farthest member of a majority, or every request is sent several times.

§hedge_min: u64

Lower bound of the adaptive hedge delay, in nanoseconds.

§hedge_max: u64

Upper bound of the adaptive hedge delay, in nanoseconds; a quarter of it is used until a commit latency has been observed. Keep it above the slowest client commit path (through the leader) or followers hedge routinely, which costs throughput.

§silent_leader_takeover: bool

Whether a follower stops waiting for a leader that has said nothing at all since it forwarded entries, after about one commit latency instead of the hedge delay: it hands its entries to the next member of the leader order and takes over the leader’s unfinished slots. Across regions this cuts recovery from a lost leader region from several seconds to about one commit latency. A leader acknowledges forwards at once, before any write (at most once per eighth of retransmit_interval per follower), so one stalled on its disk is not taken for silent. On by default; off, a follower waits the hedge delay as it always did.

§leader_order: Vec<NodeId>

Preferred leaders, first to last: every member once. Empty (the default) means by id. Put the member with the fastest path to a majority first: on a WAN the placement alone can change client latency about 2x. The leader moves down this order only when it stops getting its values decided.

Members with different orders would disagree on who leads, so the order is folded into the cluster identity on the wire: such members ignore each other. It is fixed for the life of the cluster’s state: a replica refuses to start from, or install, a snapshot built under another order.

§placement: bool

Whether this member takes part in leader placement: while writes flow it probes every member once a second for round trips and counts where writes come from, and while it leads it moves the leader to the member that gives writers the lowest commit latency, by an ordinary leader-order change. Members with it off neither probe nor answer, so enable it on every member. Off by default. See guide::tuning.

§placement_sustain: u64

How long, in nanoseconds, a member must keep a gain of at least 20% over the leader before placement moves the leader to it. Default 3 minutes.

§placement_hold: u64

After any change of the leader order, how long, in nanoseconds, placement leaves it alone. Default 10 minutes.

Implementations§

Source§

impl Config

Source

pub fn new( cluster_id: [u8; 16], id: NodeId, members: Vec<NodeId>, seed: [u8; 32], ) -> Self

A configuration with default limits and timers (see the table in guide::tuning): 1 MiB batches, 16 MiB messages, 8 slots in flight, 4096 outstanding proposals, 50 ms retransmission, hedging between 1 ms and 1 s, leaders by id.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Config

§

impl Freeze for Config

§

impl Move for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnsafeUnpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.