# Requirements
# Functional Features
Key: string
Value: string
# Non-Functional Features
- Availability
- Scalable Capacity
# Estimations
# Memory Estimations
# Domain Model
# Single Server
Performance: In-memory Cache of KV
Elimination Strategies: LRU, LFU
# Multiple Servers
Availability: Master-Slave Replication
Failover: Zookeeper, Sentinels
Follower register a listener on zookeeper, if the leader fails, the follower register themselves on zookeeper, one and only one
Implement follower using Zookeeper’s ephemeral node, it’s maintained when session is not expired. And if the session is expired, then the ephemeral nodes created by that session are all deleted and notify all listeners.
Constantly set the expire time with the interval of a heart beat.
# Clusters
Key Sharding Using Consistent Hashing
Masters cluster
# Practical
# Redis
# ZooKeeper
# Etcd
etcd — 架构原理
etcd.io Learning
ETCD介绍—etcd概念及原理方面分析
# Etcd vs ZooKeeper
一致性协议: ETCD使用[Raft]协议, ZK使用ZAB(类PAXOS协议),前者容易理解,方便工程实现;
运维方面:ETCD方便运维,ZK难以运维;
项目活跃度:ETCD社区与开发活跃,ZK已经快死了;
API:ETCD提供HTTP+JSON, gRPC接口,跨平台跨语言,ZK需要使用其客户端;
访问安全方面:ETCD支持HTTPS访问,ZK在这方面缺失;
# Applications
配置管理
服务注册于发现
选主
应用调度
分布式队列
分布式锁
# Performance
按照官网给出的[Benchmark], 在2CPU,1.8G内存,SSD磁盘这样的配置下,单节点的写性能可以达到16K QPS, 而先写后读也能达到12K QPS。这个性能还是相当可观的。
# Cassandra