Skip to content

Instantly share code, notes, and snippets.

@armon
Last active September 27, 2020 17:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armon/465c52249cccd48f7324 to your computer and use it in GitHub Desktop.
Save armon/465c52249cccd48f7324 to your computer and use it in GitHub Desktop.
Running Consul as a global K/V store

Simplest way to do this with Consul is to run a single "global" datacenter.

This means the timing for the LAN gossip need to be tuned to be WAN appropriate. In consul/config.go (https://github.com/hashicorp/consul/blob/master/consul/config.go#L267) Do something like:

// Make the 'LAN' more forgiving for latency spikes
conf.SerfLANConfig.MemberlistConfig = memberlist.DefaultWANConfig()

Then we need to tune the Raft layer to be extremely forgiving. In that same method I'd add the following:

// Make Raft more WAN friendly
conf.RaftConfig.HeartbeatTimeout = 5000 * time.Millisecond
conf.RaftConfig.ElectionTimeout = 5000 * time.Millisecond
conf.RaftConfig.CommitTimeout = 100 * time.Millisecond
conf.RaftConfig.LeaderLeaseTimeout = 2500 * time.Millisecond
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment