Chubby: What the Paper Means in Production
Google's Chubby paper showed why a coarse-grained lock service built on Paxos became infrastructure for naming, election and configuration.
The paper in brief
"The Chubby Lock Service for Loosely-Coupled Distributed Systems" by Mike Burrows appeared at OSDI in 2006. Chubby is a service that offers coarse-grained locks and a small, reliable file system interface. Google used it inside systems such as GFS and Bigtable for electing a master, storing small pieces of metadata, and letting clients discover each other.
Key ideas
A lock service rather than a consensus library. The paper argues that offering a service with a familiar file and lock interface is easier for application developers than asking each of them to embed a consensus protocol. Developers who have never read a Paxos paper can still use a lock.
Coarse-grained locking. Locks are meant to be held for hours or days, not for fractions of a second. That keeps load on the service low and means a brief outage of Chubby does not immediately disturb clients that already hold locks.
Cells and replication. A Chubby cell is a small set of replicas, typically five, that use a consensus protocol to agree on a master and replicate a database. One replica serves as the master for a period, and clients find it through naming. Reads are served by the master, so adding replicas raises durability, not read throughput.
Sessions, leases and caching. Clients maintain a session with the master through periodic keep-alive messages. Clients cache file data and the master invalidates caches before applying changes. If a session expires, locks and cached state are dropped. The paper describes a grace period that lets a client ride through a master failover without losing its session.
Advisory locks and sequencers. Locks are advisory, meaning they do not stop an uncooperative client from touching the protected resource. For delayed or reordered requests, the paper describes sequencers, a token a lock holder can present to the resource so that stale holders are rejected.
What breaks in practice
The sequencer point is the one most often learned painfully. A process can hold a lock, pause for a long garbage collection or be partitioned away, lose its lease, and then resume believing it is still the owner. Unless the protected resource checks a token, two actors act as leader. A lock alone does not give mutual exclusion in a system with unbounded pauses and delays.
Chubby becomes a dependency of everything. The Bigtable paper notes that Chubby unavailability can make Bigtable unavailable. Because so much depends on it, the Chubby paper reports on how clients and operators misuse it, and the authors describe adding quotas and guidance because developers used it as a general storage or high-rate publish service, which it was not built for.
Keep-alive traffic and session timeouts are a tuning problem. Timeouts that are too short cause spurious failovers under load, and timeouts that are too long delay recovery. This tension appears in every lease-based system.
Developers also tended to build elections and locks incorrectly even with a lock service, and the paper says so. The convenience of the interface does not remove the need to reason about failure.
Modern descendants
Chubby itself is internal to Google. The outside world received the pattern through Apache ZooKeeper, which was developed at Yahoo and offers a hierarchical namespace, ephemeral nodes and watches. Later systems such as etcd and HashiCorp Consul fill similar roles with Raft as the consensus protocol. Kubernetes uses etcd as its source of truth for cluster state, and many databases and queues use these systems for leader election and configuration.
The enduring lesson is to keep consensus in a small, well-understood, heavily operated service and have everything else lean on it with leases and fencing tokens.
Key takeaways
- Chubby packages consensus as a coarse-grained lock and small-file service.
- Leases and sessions let clients tolerate short outages, but they depend on bounded clock behavior.
- A lock without a fencing token cannot protect against paused or partitioned holders.
- A central coordination service becomes a critical dependency, so quotas and clear usage rules matter.
- ZooKeeper, etcd and Consul carry the pattern into open-source infrastructure.
Research papers
The papers and primary sources behind this article.
- The Chubby Lock Service for Loosely-Coupled Distributed Systems
Burrows, M. ยท OSDI ยท 2006
- ZooKeeper: Wait-free Coordination for Internet-scale Systems
Hunt, P., Konar, M., Junqueira, F. P., Reed, B. ยท USENIX ATC ยท 2010
- Paxos Made Simple
Lamport, L. ยท ACM SIGACT News ยท 2001
- The Part-Time Parliament
Lamport, L. ยท ACM TOCS ยท 1998