How etcd-io/etcd works
etcd is a distributed, Raft-backed key-value store. The principal workflow is a user issuing a command or application request through the client API; a member serves it over gRPC and replicates state across the cluster. The graph also preserves documented client capabilities and the watch-backed cache. The README and excerpts establish the public workflow and selected implementation details; several internal server-stage links are therefore shown as unverified rather than asserted as source-verified calls.
Main entry points: v3rpc gRPC handlers · server.go Etcd server · client.go Go client · storage.go Raft storage adapter
Components 22
Client entry points
- etcdctl commands
etcdctl/ctlv3/command/put_command.go - Go client
client/v3/client.go - gRPC API definitions
api/etcdserverpb/rpc.proto
Member serving
- Embedded server
server/embed/etcd.go - Etcd server
server/etcdserver/server.go - gRPC handlers
server/etcdserver/api/v3rpc
Consensus and storage
- Raft consensus
server/etcdserver/raft.go - Peer transport
server/etcdserver/api/rafthttp - Raft storage adapter
server/storage/storage.go - Write-ahead log
server/storage/wal/wal.go - Persistent backend
server/storage/backend/backend.go
Data services
- MVCC key store
server/storage/mvcc/kvstore.go - Transactions
server/etcdserver/txn/txn.go - Authentication
server/auth/store.go - Leases
server/lease/lessor.go - Watch service
server/etcdserver/api/v3rpc/watch.go - Cluster membership
server/etcdserver/api/membership/cluster.go - Snapshot operations
server/etcdserver/api/snap/snapshotter.go
Client capabilities
- Watch-backed cache
cache/cache.go - Concurrency recipes
client/v3/concurrency/session.go
Other components
- User or application
- Peer members
Connections 23
- User or application → etcdctl commands: issues commands
- User or application → Go client: uses API
- etcdctl commands → Etcd server: requests keys
- Go client → gRPC API definitions: uses gRPC
- gRPC API definitions → gRPC handlers: defines services
- Embedded server → Etcd server: starts server
server/embed/etcd.go - Etcd server → gRPC handlers: serves requests
- Etcd server → Raft consensus: coordinates consensus
- Raft consensus → Peer transport: exchanges Raft traffic
- Raft consensus → Raft storage adapter: persists Raft state
- Raft storage adapter → Write-ahead log: writes entries
server/storage/storage.go - Raft storage adapter → Snapshot operations: releases snapshots
server/storage/storage.go - Raft storage adapter → Persistent backend: stores state
- gRPC handlers → Transactions: dispatches transactions
- Transactions → MVCC key store: updates key state
- gRPC handlers → Authentication: checks access
- gRPC handlers → Leases: serves lease calls
- gRPC handlers → Watch service: serves watches
- gRPC handlers → Cluster membership: serves membership
- Go client → Watch-backed cache: supplies watch and KV
cache/cache.go - Watch-backed cache → MVCC key store: reads revisions
- Go client → Concurrency recipes: supports recipes
- Etcd server → Peer members: replicates with peers