Raft算法以超半数写入即确认保存成功, 那如果访问的正好是没写入那个节点,怎么保证一致

问题 就是说强一致性被破坏了

  • Raft算法以超半数写入即确认保存成功, 那如果访问的正好是没写入那个节点,怎么保证一致 ?

首先分布式系统的前提是CAP理论

CAP理论

  • P Partition tolerance 分区容错性
    • 分布式多个服务 位于不同服务器 可能之间会失败
  • C Consistency 一致性
    • 写入或者更新数据后,必须读取必须返回这个写入或者更新的值
  • A Availability 可用性
    • 就是啥时候访问必须给响应 基于reuqust/response

P 天然会使用

  • 网络是不可靠的,因此分区容错任何时候都无法避免 P总是成立

raft 论文

5.1 Raft basics
A Raft cluster contains several servers; five is a typical number, which allows the system to tolerate two failures. At any given time each server is in one of three states: leader, follower, or candidate. In normal operation there is exactly one leader and all of the other servers are fol- lowers. Followers are passive: they issue no requests on their own but simply respond to requests from leaders and candidates. The leader handles all client requests (if a client contacts a follower, the follower redirects it to the leader). The third state, candidate, is used to elect a new leader as described in Section 5.2. Figure 4 shows the states and their transitions; the transitions are discussed below.
  • 大意是讲 就算你把请求发给follower 一样会转发leaderc处理
真像就是 raft是强leader模式
  • 任何请求只能是leader 来处理,就算你发给follewer 一样是leader处理
  • 所以问题本身就是不成立
posted @ 2022-08-12 18:08  vx_guanchaoguo0  阅读(22)  评论(0编辑  收藏  举报