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

Reduce heartbeat message #309

Open
NingLin-P opened this issue Oct 29, 2019 · 9 comments · May be fixed by #313
Open

Reduce heartbeat message #309

NingLin-P opened this issue Oct 29, 2019 · 9 comments · May be fixed by #313
Labels
Request for Comment A proposal to be considered. Analogous to an RFC in TiKV/Rust.

Comments

@NingLin-P
Copy link
Member

With current implement, a MsgHeartbeat do these things:

  • update( or correct ) a peer's status like commit index, StateRole, ect.
  • confirm quorum for quorum check or read index request

While the MsgAppend already do the first, and the second are also easy to done
by attach the ctx with MsgAppend, we can reduce MsgHeartbeat by :

  1. when sending a MsgAppend check if the heartbeat_elapsed reach a threshold
  2. if it does reset the heartbeat_elapsed and attach the ctx on this msg if there is one

is it possible to implement and improve a bit performance ?

@NingLin-P NingLin-P added the Request for Comment A proposal to be considered. Analogous to an RFC in TiKV/Rust. label Oct 29, 2019
@Fullstop000
Copy link
Member

Do you mean reducing the size of MsgHeartbeat or just canceling heartbeats?

@NingLin-P
Copy link
Member Author

Canceling heartbeats.

@Fullstop000
Copy link
Member

How does a follower keep not becoming a candidate without receiving heartbeats? OTOH, what if the current leader steps down?

@NingLin-P
Copy link
Member Author

  1. when follower received messages from leader, it reset election_elapsed:
            MessageType::MsgAppend => {
                self.election_elapsed = 0;
                self.leader_id = m.from;
                self.handle_append_entries(&m);
            }
            MessageType::MsgHeartbeat => {
                self.election_elapsed = 0;
                self.leader_id = m.from;
                self.handle_heartbeat(m);
            }
            MessageType::MsgSnapshot => {
                self.election_elapsed = 0;
                self.leader_id = m.from;
                self.handle_snapshot(m);
            }
  1. if the current leader steps down, it will be handle as before.

BTW canceling heartbeats do not mean cancel all heartbeats, just reset the heartbeat_elapsed
and delay or avoid a heartbeat.

@BusyJay
Copy link
Member

BusyJay commented Oct 30, 2019

Do you mean not to send a heartbeat if an append message is sent within an heartbeat_elapsed ticks?

I think it can bring little improvement. When under high load, heartbeat message count is way too smaller than the count of message append; when group is idle, there is too few append messages that heartbeat message is always sent out. There should still be an improvement depends on the configuration of heartbeat-elapsed though.

@Fullstop000
Copy link
Member

Fullstop000 commented Oct 30, 2019

Ok, I think I've gotten the idea you described: only sending heartbeats when there are no MsgAppend msgs sent in a heartbeat_timeout.

It sounds like a good idea :).

@NingLin-P
Copy link
Member Author

Yes, what you guy said is right.

@Fullstop000
Copy link
Member

As for implementation should be quite simple I think, you can try to just set the leader's heartbeat_elasped to 0 when sending MsgAppend (or MsgSnapshot) @NingLin-P

@NingLin-P
Copy link
Member Author

OK, let me try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Request for Comment A proposal to be considered. Analogous to an RFC in TiKV/Rust.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants