#[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
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: NodeIdThis 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: u32Upper 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: u32Upper 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: u32How many slots this replica may drive concurrently.
max_outstanding_proposals: u32How many local proposals may be pending before Error::Busy.
retransmit_interval: u64How 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: u64Lower bound of the adaptive hedge delay, in nanoseconds.
hedge_max: u64Upper 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: boolWhether 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: boolWhether 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: u64How 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: u64After any change of the leader order, how long, in nanoseconds, placement leaves it alone. Default 10 minutes.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(
cluster_id: [u8; 16],
id: NodeId,
members: Vec<NodeId>,
seed: [u8; 32],
) -> Self
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.