A versioned key-value control-plane store#
etcd fits configuration, membership, leader election, and controller metadata that needs strong ordering and observation. Kubernetes is a concrete association, but the interview lesson is the control-plane problem: small important state whose updates participants must agree on.
Raft-backed agreement exposes revisions to clients#
The keyspace is flat and versioned by revisions. Watches stream changes from revisions while history is available. Transactions provide atomic compare/then/else operations, useful for compare-and-swap and higher-level coordination.
Leases represent liveness, not timeless ownership#
A lease has a TTL and is refreshed with keep-alives; attached keys are removed when it expires or is revoked. A paused or partitioned client can mistakenly believe it still owns work after the cluster expires its lease. Use a monotonically newer fencing token or validate authority at the protected resource.
etcd vs ZooKeeper#
| Dimension | etcd | ZooKeeper |
|---|---|---|
| Data model | Flat versioned key-value space | Hierarchical znode namespace |
| Observation | Revision-based watch streams | Standard one-shot watches plus persistent variants |
| Liveness | Lease-bound keys | Session-bound ephemeral znodes |
| Consensus family | Raft | ZooKeeper Atomic Broadcast |
| Ecosystem example | Kubernetes control-plane state | Distributed-system coordination recipes and legacy ecosystems |
Neither is a universal winner. Generic interviews value why coordination stores exist more than product API recall.
- Using etcd for large, rapidly changing user datasets.
- Assuming watch consumers never fall behind or cross compaction boundaries.
- Equating a lease with permanent external ownership.
- Saying Raft means the service is always available.
- Name-dropping Kubernetes without describing the metadata requirement.
Use these prompts to extend the design. The useful answer is a reasoned change, not a memorized sentence.
- Which keys need linearizable coordination?
- How does a watcher recover after disconnection?
- What happens when the cluster loses quorum?
- How are stale lease holders fenced?
- Why not ZooKeeper or a transactional database?
Related practice problems
Use the manifest-backed prompts below to apply this lesson in a complete design.
- etcd v3.6 API designetcd Documentation
- etcd for distributed coordinationetcd Documentation