diff --git a/command/agent/config.go b/command/agent/config.go index ae1138ec8c..96a7071548 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -942,6 +942,11 @@ func DecodeConfig(r io.Reader) (*Config, error) { result.AdvertiseAddrs.RPC = addr } + // Enforce the max Raft multiplier. + if result.Performance.RaftMultiplier > consul.MaxRaftMultiplier { + return nil, fmt.Errorf("Performance.RaftMultiplier must be <= %d", consul.MaxRaftMultiplier) + } + return &result, nil } diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 34c9b47206..ed174a9f82 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -966,6 +966,12 @@ func TestDecodeConfig_Performance(t *testing.T) { if config.Performance.RaftMultiplier != 3 { t.Fatalf("bad: multiplier isn't set: %#v", config) } + + input = `{"performance": { "raft_multiplier": 11 }}` + config, err = DecodeConfig(bytes.NewReader([]byte(input))) + if err == nil || !strings.Contains(err.Error(), "Performance.RaftMultiplier must be <=") { + t.Fatalf("bad: %v", err) + } } func TestDecodeConfig_Services(t *testing.T) { diff --git a/consul/config.go b/consul/config.go index eb7e2947c5..0e094f305b 100644 --- a/consul/config.go +++ b/consul/config.go @@ -18,9 +18,14 @@ const ( DefaultLANSerfPort = 8301 DefaultWANSerfPort = 8302 - // See docs/guides/performance.html for information on how this value - // was obtained. + // DefaultRaftMultiplier is used as a baseline Raft configuration that + // will be reliable on a very basic server. See docs/guides/performance.html + // for information on how this value was obtained. DefaultRaftMultiplier uint = 5 + + // MaxRaftMultiplier is a fairly arbitrary upper bound that limits the + // amount of performance detuning that's possible. + MaxRaftMultiplier uint = 10 ) var ( diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index 208fb38b33..7d439cd357 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -581,18 +581,19 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass Consul. See the [Server Performance](/docs/guides/performance.html) guide for more details. The following parameters are available: * `raft_multiplier` - An integer - multiplier used by Consul servers to scale key Raft timing parameters. Tuning this affects - the time it takes Consul to detect leader failures and to perform leader elections, at the - expense of requiring more network and CPU resources for better performance.

A value - of 0, the default, means that Consul will use a lower-performance timing that's suitable for - [minimal Consul servers](/docs/guides/performance.html#minumum), currently equivalent to - setting this to a value of 5 (this default may be changed in future versions of Consul, - depending if the target minimum server profile changes). Above 0, higher values imply lower - levels of performance. Setting this to a value of 1 will configure Raft to its - highest-performance mode, equivalent to the default timing of Consul prior to 0.7, and is - recommended for [production Consul servers](/docs/guides/performance.html#production). See - the note on [last contact](/docs/guides/performance.html#last-contact) timing for more - details on tuning this parameter. + multiplier used by Consul servers to scale key Raft timing parameters. Omitting this value + or setting it to 0 uses default timing described below. Lower values are used to tighten + timing and increase sensitivity while higher values relax timings and reduce sensitivity. + Tuning this affects the time it takes Consul to detect leader failures and to perform + leader elections, at the expense of requiring more network and CPU resources for better + performance.

By default, Consul will use a lower-performance timing that's suitable + for [minimal Consul servers](/docs/guides/performance.html#minumum), currently equivalent + to setting this to a value of 5 (this default may be changed in future versions of Consul, + depending if the target minimum server profile changes). Setting this to a value of 1 will + configure Raft to its highest-performance mode, equivalent to the default timing of Consul + prior to 0.7, and is recommended for [production Consul servers](/docs/guides/performance.html#production). + See the note on [last contact](/docs/guides/performance.html#last-contact) timing for more + details on tuning this parameter. The maximum allowed value is 10. * `ports` This is a nested object that allows setting the bind ports for the following keys: