Hi ,
I was building a small nosql db (for learning purpose) backed by raft consensus for replication . I was going to through various document and links how cockroachdb has optimized Heartbeat mechanism .
Here is my understanding from design docs :
-
Each Node will represent single store.
-
Each store consists of Regions (Range of keys)
2.1 Leader Regions
2.2 Replica Regions ( Replica or peers of regions which are leaders on other nodes/store) -
Each Region (Leader or Replica ) will be backed by single raft node . So for each store (no of raft node == no of regions )
-
Since each raft node coordinate via messages sent through heartbeats , cockroachdb coalesces all heartbeats of single node /store and send to other store . Message will contain region id and node id which will multiplexed at receiver end and changes in state machines will happen .
Let me know if anything is misunderstood .
What I am not able to understand is how “coalesces all heartbeats” is happening at low level (code level). It would be great help if I get some details and code pointers .
Thanks
Sohi