Design a Distributed Service Discovery / KV System (Consul)
Problem
Design a distributed service discovery + KV system like Consul, where services register and discover each other and share config.
Requirements
Functional:
- Service register/deregister with health checks
- Discover healthy instances of a service
- Distributed KV for config
- Watch/notify on changes
Non-functional:
- Thousands of nodes across datacenters
- Strong consistency for KV; AP for discovery reads
- Survive node/network failures
Discussion points
- Consensus (Raft) for the KV/state store
- Gossip (SWIM) for membership and failure detection
- Health checking and anti-entropy
- Multi-datacenter replication
- Watches and consistency trade-offs
added …