课前预习
为了有更好的学习效果,建议大家在看视频前把下面的资料看一下:
课件和 Demo 地址
作者回复: Etcd支持以下两种read: 1. Linearizable read(默认): 需要由Leader发起,Leader发送一个请求给所有节点,在收到多数节点的响应之后,才把结果返回给客户端。如果一个follower收到linearizable read的请求,需要转发给leader来处理。 2. Serializable read(使用Get API的话要加WithSerializable选项): Leader和follower都可以在本地处理,时延低。 只有Etcd的leader才能处理write。Follower在接到write请求后,要转发给leader来处理。 参见https://github.com/etcd-io/etcd/blob/master/Documentation/faq.md#do-clients-have-to-send-requests-to-the-etcd-leader: > Raft is leader-based; the leader handles all client requests which need cluster consensus. However, the client does not need to know which node is the leader. Any request that requires consensus sent to a follower is automatically forwarded to the leader. Requests that do not require consensus (e.g., serialized reads) can be processed by any cluster member.