AP 的应用场景:表现为订单创建后,立即返回短信发送成功,无需等待短信是否发送成功,保证用户体验。但是 AP 有很大的问题,例如爆了一件神话装备,但是服务器宕机了,缓存没有写入磁盘,导致装备丢失。
BASE 最终一致性
AP 缺乏数据一致性的解决方案:BASE,是对 CAP 的补充,让短信尽可能地发送成功
Basically available: reading and writing operations are available as much as possible (using all nodes of a database cluster), but may not be consistent (the write may not persist after conflicts are reconciled, the read may not get the latest write)
基本可用,就是基本实现用户的基本价值和诉求,创建订单后立即返回,就是基本可用的体现
Soft-state: without consistency guarantees, after some amount of time, we only have some probability of knowing the state, since it may not yet have converged
Eventually consistent: If we execute some writes and then the system functions long enough, we can know the state of the data; any further reads of that data item will return the same value
最终一致性,表示通过技术手段,过一段时间后,让数据保持一致性。最终一致性只是对 AP 打补丁,不能 100% 实现 Consistency。