資料列加唯一索引,重複資料儲存失敗。
有多餘兩台Web容器時,并發查詢,單機鎖不能確定查詢的準确性。
redis的單線程鎖,一般能解決,但是并不完美。弊端:redis的鎖租期,無法續期,業務邏輯用鎖時間不可能确定;單機redis容易單點故障,多節點的話,主從複制時,或者因為單點故障,主備切換資料同步時,都可能導緻分布式鎖的唯一性不成立的情況。
進一步給redis加上鎖租期的能力就是用Redisson元件。
解決分布式鎖的成熟元件: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年提出的一種基于消息傳遞的一緻性算法。