Skip to content

Instantly share code, notes, and snippets.

Last active September 27, 2020 17:54
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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 ( 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