PAPER EXPLAINED
The Chubby Lock Service for Loosely-Coupled Distributed Systems
IntermediateAbout 45 min to read the paper
TL;DR
Chubby is Google's replicated lock service with a small-file interface, built for coarse-grained coordination such as leader election. The paper describes its design and what years of real use revealed, including its unexpected role as the company's main name service.
What problem does Chubby solve?
Google's distributed systems needed a reliable way to elect primaries and agree on small pieces of shared information, such as who the master is. Before Chubby, teams used ad hoc election methods or relied on human operators when correctness mattered. Doing this correctly means solving asynchronous consensus, where messages can be lost, delayed or reordered and machines fail independently. Most developers do not structure their code for consensus protocols, and they tend to misuse locks in distributed settings.
The core idea
Rather than handing developers a consensus library, offer a highly available central service that looks like a simple file system with advisory locks. A small cell of replicas uses consensus to elect a master. Clients acquire locks to become primaries and write small files to advertise themselves. Clients cache data consistently and receive change notifications. Leases and sessions keep locks and caches safe across failures. The design prioritizes reliability, availability and easy-to-understand semantics over throughput and storage capacity.
IN THE AUTHORS’ WORDS
“Building Chubby was an engineering effort required to fill the needs mentioned above; it was not research.”
The Chubby Lock Service for Loosely-Coupled Distributed Systems, p. 1
“Even though Chubby was designed as a lock service, we found that its most popular use was as a name server.”
The Chubby Lock Service for Loosely-Coupled Distributed Systems, p. 12
“Chubby was never intended to be used as a storage system for large amounts of data, and so it has no storage quotas.”
The Chubby Lock Service for Loosely-Coupled Distributed Systems, p. 13
How Chubby works
- A Chubby cell is a handful of replicas, typically five. They use a consensus protocol to elect a master, which holds a master lease during which no other master can be chosen. Only the master serves reads. Writes are acknowledged once a majority of replicas have them.
- Clients see a simple tree of files and directories. Nodes can be permanent or ephemeral. Each carries ACL names and monotonically increasing numbers, such as content and lock generation numbers, that make changes easy to detect.
- Any node can serve as an advisory reader-writer lock. A lock holder can request a sequencer that it passes to other servers so they can reject stale requests. For servers that cannot check sequencers, a lock-delay keeps a lock from being reclaimed for a while after its holder fails.
- Clients keep a consistent write-through cache of data, metadata and handles. Before a change is applied, the master sends invalidations to every client that might have the data cached. The change waits until each client acknowledges or lets its cache lease expire.
- Each client keeps a session alive with KeepAlive RPCs, which also carry events and cache invalidations back to the client. If the client's lease runs out, its session enters jeopardy and the client waits a grace period (45s by default) before giving up.
- A newly elected master picks a new epoch number and rebuilds session and lock state from the database. It sends a fail-over event so clients flush their caches, waits for acknowledgements or expiry, and then resumes normal operations, recreating old handles when they are used.
- To scale, Chubby runs many cells, lengthens leases under load, relies heavily on client caching, and uses protocol-conversion servers. Proxies and namespace partitioning had been designed but were not yet in production.
Results
The paper reports operational observations, not controlled experiments. A snapshot of one cell, described as typical, showed 22k direct and 32k proxied clients and an RPC rate of 1-2k/s, about 93% of it KeepAlives. Exclusive locks numbered 1k and shared locks were zero. On a sample of cells, 61 outages occurred over 700 cell-days, and 52 of them lasted under 30s. Data was lost six times in a few dozen cell-years, caused by software and operator errors. Mean server latency stayed a small fraction of a millisecond until overload, which typically occurred above about 90,000 sessions. A single master was seen serving 90 thousand direct clients. The most popular use turned out to be name service.
Limitations and what came later
- The author states that Chubby was engineering, not research. The paper claims no new algorithms and omits consensus protocol details.
- The evidence comes from one company's environment and from snapshot statistics, not controlled comparisons. The outage count is based on an optimistic definition of a cell being up.
- Proxies and partitioning were designed but not used in production at the time, so their scaling benefits are expectations rather than measurements.
- Chubby supports only coarse-grained locking and was not built for large data storage or publish/subscribe. Misusing it in these ways caused load problems.
- The fail-over design had flaws, such as young read-only sessions possibly being lost, and the author notes the fail-over code was a rich source of bugs.
Why Chubby matters
Chubby shows how to package consensus behind a familiar file-and-lock interface so that many teams can rely on correct leader election without implementing consensus themselves. The paper notes that GFS and Bigtable use it to elect primaries and store root metadata, and that it became Google's primary internal name service. Its account of how developers actually used and abused a shared service offers durable lessons for anyone designing infrastructure.
This is a candid engineering report rather than an algorithms paper. The author says outright that Chubby claims no new techniques. Its value lies in showing how a Paxos-replicated service is wrapped in an interface ordinary developers will actually use: a small file system with advisory locks, consistent caching and event notifications. The paper explains why a centralized lock service was chosen over a consensus library, how leases, KeepAlives and grace periods let clients ride out master fail-overs, and how sequencers guard against delayed requests. It then compares the intended design with real use. The most popular use turned out to be name service, not locking. Developers wrote abusive polling loops, stored oversized files and crashed on fail-over events. The author also names design choices he now regrets. For anyone building or depending on coordination services, these lessons about human behaviour, load and availability are as instructive as the mechanisms.
Before you read
Who it’s for
Engineers and students interested in distributed systems, coordination services, leader election, or the practical side of running a shared infrastructure service. It also suits anyone who uses GFS or Bigtable-style systems and wants to know how they elect masters.
What to know first
- Basic idea of distributed consensus and why leader election is hard over unreliable networks
- Familiarity with locks and mutual exclusion
- Rough understanding of RPC and client–server systems
- Basic notion of caching and cache consistency
- Awareness of DNS and time-to-live caching (helpful for Section 4.3)
Glossary
- Chubby cell
- One Chubby instance: a small set of replicas, usually five, that together serve clients through an elected master.
- Master lease
- A period of a few seconds during which the replicas promise not to elect a different master. This lets the master serve reads safely on its own.
- Coarse-grained lock
- A lock held for a long time, such as hours or days, for example to elect a primary. This contrasts with fine-grained locks held for seconds or less.
- Advisory lock
- A lock that only conflicts with other attempts to acquire the same lock. It does not stop anyone from accessing the associated file or resource.
- Sequencer
- An opaque string describing a lock right after acquisition: its name, mode and generation number. Other servers use it to check that a request is still protected by the lock.
- Lock-delay
- A period, of up to one minute, during which a lock whose holder failed cannot be claimed by others. It protects servers that do not check sequencers.
- Ephemeral node
- A file or directory that is deleted automatically when no client has it open. It is often used to signal that a client is alive.
- KeepAlive
- A periodic RPC from client to master that extends the session lease and carries events and cache invalidations back to the client.
- Grace period
- Extra time, 45s by default, that a client waits after its local lease expires before declaring its session dead. It lets sessions survive long master fail-overs.
- Epoch number
- A number chosen by each new master that clients must present on every call. It lets the master reject packets meant for a previous master.
What to pay attention to
- The rationale in Section 2.1 for building a lock service instead of a Paxos library. It shapes everything else.
- How sequencers and the lock-delay deal with delayed or reordered requests that arrive after a lock has changed hands.
- The cache invalidation protocol: writes block until every caching client acknowledges the invalidation or lets its lease expire.
- Figure 2 and the grace period, which let a client keep its session across a long master fail-over.
- The numbered steps a new master follows after fail-over, including epoch numbers and recreating handles.
- The usage table in Section 4.1. KeepAlives dominate traffic, and few clients hold locks.
- Section 4.3 on why Chubby became a name service, and Section 4.5 on abusive clients.
Questions to keep in mind
- Why does the author argue that a lock service lets a client system make progress safely with fewer of its own servers than a consensus library would require?
- What problem does a sequencer solve that an ordinary lock does not, and why is the lock-delay described as only an imperfect substitute?
- Why does Chubby invalidate cached data rather than push updates to clients?
- How do the jeopardy and grace-period mechanisms change what an application sees during a master outage?
- Since most RPCs are KeepAlives, which scaling techniques does the paper rely on, and why does it consider raw server speed relatively unimportant?
Chubby quiz: check your understanding
1. How many replicas does a typical Chubby cell have, and how many must be running for the cell to be up?
Show the answer
A cell usually has five replicas, and three of them (a majority) must be running for the cell to be up.
2. What does a sequencer contain, and what is the receiving server expected to do with it?
Show the answer
A sequencer is an opaque byte-string that describes the lock's state just after acquisition. It holds the lock name, the mode (exclusive or shared) and the lock generation number. A server that receives one should check that it is still valid and has the right mode, and reject the request if not.
3. Why are Chubby locks advisory rather than mandatory?
Show the answer
Chubby locks often protect resources in other services, so enforcing them would have required extensive changes to those services. The designers also did not want to force applications to shut down when locked files needed debugging or administration. And developers already check locks with assertions, so mandatory checks added little value.
4. What happens when a client's local lease timeout expires?
Show the answer
The client is unsure whether the master has ended its session. It empties and disables its cache, and the session is said to be in jeopardy. It then waits a grace period (45s by default). If a KeepAlive succeeds within that period, the cache is re-enabled. Otherwise the session is assumed to have expired.
5. According to the usage snapshot, what dominates Chubby's RPC traffic?
Show the answer
Session KeepAlives make up about 93% of RPCs. Reads are few, and writes and lock acquisitions are very rare.
6. What turned out to be Chubby's most popular use, and why did it beat DNS for this purpose?
Show the answer
Its most popular use was as a name server. DNS caching depends on time-to-live values, and short TTLs can overload DNS servers. Chubby's explicit invalidations let a steady rate of KeepAlives keep any number of cache entries fresh until something actually changes.
7. Why does a newly elected master pick a new client epoch number?
Show the answer
Clients must present the epoch number on every call, and the master rejects calls carrying older numbers. This stops the new master from responding to very old packets sent to a previous master, even one that ran on the same machine.
8. Why were KeepAlives moved from TCP to UDP?
Show the answer
TCP's back-off policies ignore higher-level timeouts such as Chubby leases. As a result, TCP-based KeepAlives caused many lost sessions during heavy network congestion.
Go a little deeper
Chubby bundles locks, small-file storage and session/lease failure detection into one service, while Boxwood splits them into separate components. Using the paper's arguments about audience and familiarity, when would each approach be the better choice, and what does bundling cost?
Read next
Related reading lists
Cite Chubby
Burrows, M. (2006). The Chubby Lock Service for Loosely-Coupled Distributed Systems. USENIX OSDI.
@inproceedings{burrows2006chubby,
title = {{The Chubby Lock Service for Loosely-Coupled Distributed Systems}},
author = {Mike Burrows},
year = {2006},
booktitle = {USENIX OSDI},
url = {https://www.usenix.org/legacy/event/osdi06/tech/full_papers/burrows/burrows.pdf}
}Study Chubby in ReadingTrack
Add the paper to your ReadingTrack library with its authors, venue and year, and get this page’s quiz as suggested review cards. You choose which cards to keep; nothing enters your reviews until you accept it.