Search code examples
apiconsulraft

Peers vs Members - Consul


Peer set - The peer set is the set of all members participating in log replication. For Consul's purposes, all server nodes are in the peer set of the local datacenter.

~ Quote from Official docs

  1. What is the difference between peers and members then?
  2. Why do we have following two APIs then? (one is enough?)

      i. /status/peers  
     ii. /agent/members
    
  3. Could you please shed light on the internal details?

  4. Is there a possibility of inconsistency in results of above APIs?

Solution

  • Here is a comparison of /agent/members/, status/peers/ and catalog/nodes.

    The possible difference in response is because each of the API end point get data from different sources.

    1. /catalog/nodes: The request recieved by any agent is redirected to the leader, and leader provides the response from catalog.
    2. /agent/members/: Agent receives the request and return member information obtained from gossip. This can be different from catalog end point (as obvious from log replication mechanism (Consul uses Raft Prorocol) ).
    3. /status/peers/ : This API return the nodes participating in 'log replication'.
      Ideally, this should be same as /catalog/node. But if there is a partition in the cluster, it is possible that, until the cluster recover, all members are not taking part in log replication. In this case /catalog/nodes/ and /status/peers/ can give different results.

    To understand this proper, you need to know the raft protocol properly. Reference.