Skip to content
Snippets Groups Projects
Unverified Commit f1ac05ee authored by Sam Hughes's avatar Sam Hughes
Browse files

Decrease tick interval to 20 ms.

It was previously 1000 ms.

This has the benefit of making log entries replay faster when a node
reconnects (or starts up fresh).  It might have other benefits, too.

The heartbeat and election tick parameters are the same (1 tick and 10
ticks) -- so they also get scaled down.
parent 9e6dad36
No related branches found
No related tags found
No related merge requests found
......@@ -239,8 +239,8 @@ func newNode(gid uint32, id uint64, myAddr string) *node {
store: store,
cfg: &raft.Config{
ID: id,
ElectionTick: 10,
HeartbeatTick: 1,
ElectionTick: 10, // 200 ms if we call Tick() every 20 ms.
HeartbeatTick: 1, // 20 ms if we call Tick() every 20 ms.
Storage: store,
MaxSizePerMsg: 4096,
MaxInflightMsgs: 256,
......@@ -709,7 +709,8 @@ func (n *node) retrieveSnapshot(peerID uint64) {
func (n *node) Run() {
firstRun := true
var leader bool
ticker := time.NewTicker(time.Second)
// See also our configuration of HeartbeatTick and ElectionTick.
ticker := time.NewTicker(20 * time.Millisecond)
defer ticker.Stop()
rcBytes, err := n.raftContext.Marshal()
x.Check(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment