分布式重复提交问题架构设计思路

数据列加唯一索引,重复数据保存失败。

有多余两台Web容器时,并发查询,单机锁不能确保查询的准确性。

要用分布式锁:

redis的单线程锁,一般能解决。弊端:redis的锁租期,无法续期,业务逻辑用锁时间不可能确定;单机redis容易单点故障,多节点的话,主从复制时,或者因为单点故障,主备切换数据同步时,都可能导致分布式锁的唯一性不成立的情况。

真正解决分布式锁的组件:zookeeper,yahoo发明了一系列分布式应用后发明的java的分布式事务协调器。

etcd,也是CoreOS(kubenetes集群特定发行版)的核心组件,go语言实现。

https://github.com/etcd-io/etcd

etcd is a distributed reliable key-value store for the most critical data of a distributed system, with a focus on being:

  • Simple: well-defined, user-facing API (gRPC)
  • Secure: automatic TLS with optional client cert authentication
  • Fast: benchmarked 10,000 writes/sec
  • Reliable: properly distributed using Raft

etcd is written in Go and uses the Raft consensus algorithm to manage a highly-available replicated log.

Paxos,算法是莱斯利·兰伯特(Leslie Lamport,就是 LaTeX 中的"La",此人现在在微软研究院)于1990年提出的一种基于消息传递的一致性算法。

猜你喜欢

转载自www.cnblogs.com/rgqancy/p/10506626.html