Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease rate of Raft heartbeat messages. #3708

Merged
merged 4 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conn/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func NewNode(rc *pb.RaftContext, store *raftwal.DiskStorage) *Node {
Store: store,
Cfg: &raft.Config{
ID: rc.Id,
ElectionTick: 100, // 2s if we call Tick() every 20 ms.
HeartbeatTick: 1, // 20ms if we call Tick() every 20 ms.
ElectionTick: 20, // 2s if we call Tick() every 100 ms.
HeartbeatTick: 1, // 100ms if we call Tick() every 100 ms.
Storage: store,
MaxInflightMsgs: 256,
MaxSizePerMsg: 256 << 10, // 256 KB should allow more batching.
Expand Down
6 changes: 5 additions & 1 deletion worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,11 @@ func (n *node) Run() {
firstRun := true
var leader bool
// See also our configuration of HeartbeatTick and ElectionTick.
ticker := time.NewTicker(20 * time.Millisecond)
// Before we used to have 20ms ticks, but they would overload the Raft tick channel, causing
// "tick missed to fire" logs. Etcd uses 100ms and they haven't seen those issues.
// Additionally, using 100ms for ticks does not cause proposals to slow down, because they get
// sent out asap and don't rely on ticks. So, setting this to 100ms instead of 20ms is a NOOP.
ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()

done := make(chan struct{})
Expand Down