Adds a max raft multiplier and tweaks documentation.

pull/2303/head
James Phillips 2016-08-25 15:36:05 -07:00
parent 2822334bce
commit 17b70c7efd
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
4 changed files with 31 additions and 14 deletions

View File

@ -942,6 +942,11 @@ func DecodeConfig(r io.Reader) (*Config, error) {
result.AdvertiseAddrs.RPC = addr 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 return &result, nil
} }

View File

@ -966,6 +966,12 @@ func TestDecodeConfig_Performance(t *testing.T) {
if config.Performance.RaftMultiplier != 3 { if config.Performance.RaftMultiplier != 3 {
t.Fatalf("bad: multiplier isn't set: %#v", config) 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) { func TestDecodeConfig_Services(t *testing.T) {

View File

@ -18,9 +18,14 @@ const (
DefaultLANSerfPort = 8301 DefaultLANSerfPort = 8301
DefaultWANSerfPort = 8302 DefaultWANSerfPort = 8302
// See docs/guides/performance.html for information on how this value // DefaultRaftMultiplier is used as a baseline Raft configuration that
// was obtained. // will be reliable on a very basic server. See docs/guides/performance.html
// for information on how this value was obtained.
DefaultRaftMultiplier uint = 5 DefaultRaftMultiplier uint = 5
// MaxRaftMultiplier is a fairly arbitrary upper bound that limits the
// amount of performance detuning that's possible.
MaxRaftMultiplier uint = 10
) )
var ( var (

View File

@ -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 Consul. See the [Server Performance](/docs/guides/performance.html) guide for more details. The
following parameters are available: following parameters are available:
* <a name="raft_multiplier"></a><a href="#raft_multiplier">`raft_multiplier`</a> - An integer * <a name="raft_multiplier"></a><a href="#raft_multiplier">`raft_multiplier`</a> - An integer
multiplier used by Consul servers to scale key Raft timing parameters. Tuning this affects multiplier used by Consul servers to scale key Raft timing parameters. Omitting this value
the time it takes Consul to detect leader failures and to perform leader elections, at the or setting it to 0 uses default timing described below. Lower values are used to tighten
expense of requiring more network and CPU resources for better performance.<br><br>A value timing and increase sensitivity while higher values relax timings and reduce sensitivity.
of 0, the default, means that Consul will use a lower-performance timing that's suitable for Tuning this affects the time it takes Consul to detect leader failures and to perform
[minimal Consul servers](/docs/guides/performance.html#minumum), currently equivalent to leader elections, at the expense of requiring more network and CPU resources for better
setting this to a value of 5 (this default may be changed in future versions of Consul, performance.<br><br>By default, Consul will use a lower-performance timing that's suitable
depending if the target minimum server profile changes). Above 0, higher values imply lower for [minimal Consul servers](/docs/guides/performance.html#minumum), currently equivalent
levels of performance. Setting this to a value of 1 will configure Raft to its to setting this to a value of 5 (this default may be changed in future versions of Consul,
highest-performance mode, equivalent to the default timing of Consul prior to 0.7, and is depending if the target minimum server profile changes). Setting this to a value of 1 will
recommended for [production Consul servers](/docs/guides/performance.html#production). See configure Raft to its highest-performance mode, equivalent to the default timing of Consul
the note on [last contact](/docs/guides/performance.html#last-contact) timing for more prior to 0.7, and is recommended for [production Consul servers](/docs/guides/performance.html#production).
details on tuning this parameter. 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.
* <a name="ports"></a><a href="#ports">`ports`</a> This is a nested object that allows setting * <a name="ports"></a><a href="#ports">`ports`</a> This is a nested object that allows setting
the bind ports for the following keys: the bind ports for the following keys: