Quick revision
The short answer
The likely cause is slow storage: etcd must fsync its write-ahead log before acknowledging a write, and network-attached disks under load make those fsyncs slow, so writes time out, the leader falls behind on heartbeats, followers call elections, and leadership churns. etcd_disk_wal_fsync_duration_seconds (p99 should stay under about 10 ms) and etcd_disk_backend_commit_duration_seconds (p99 under about 25 ms), alongside etcd_server_leader_changes_seen_total and peer round-trip times, confirm it. The fix is storage first, dedicated low-latency SSDs without noisy neighbours, then timeouts tuned to real round trips, plus compaction, defragmentation and a look at controllers that write too much.
What to remember
In this answer, we traced the timeouts, slow-apply warnings and leader churn to etcd's dependence on fast fsync: on busy network-attached disks, every write and every heartbeat waits, followers call elections and leadership churns. WAL fsync and backend commit latency histograms, leader change counts and peer round-trip times confirm it, and fio checks a disk before use. The fix is dedicated low-latency SSD storage and enough CPU first, timeouts tuned to real round trips only afterwards, plus compaction, member-by-member defragmentation, quota monitoring and taming clients that write too much.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The likely cause is slow storage: etcd must fsync its write-ahead log before acknowledging a write, and network-attached disks under load make those fsyncs slow, so writes time out, the leader falls behind on heartbeats, followers call elections, and leadership churns. etcd_disk_wal_fsync_duration_seconds (p99 should stay under about 10 ms) and etcd_disk_backend_commit_duration_seconds (p99 under about 25 ms), alongside etcd_server_leader_changes_seen_total and peer round-trip times, confirm it. The fix is storage first, dedicated low-latency SSDs without noisy neighbours, then timeouts tuned to real round trips, plus compaction, defragmentation and a look at controllers that write too much.
Why this question is asked
When etcd is unhappy, the whole Kubernetes control plane is unhappy: the API server times out, controllers stall and deployments hang. The error messages point at etcd but not at the cause, and the instinct to raise timeouts often makes things worse. Interviewers ask this debugging question because it rewards understanding what etcd does on every write and reading the right metrics. In this answer, we will recap the write path, connect the symptoms to disk latency, confirm it with metrics, fix the storage, tune only afterwards, and check database size and noisy clients.
1A Quick Recap: What etcd Does on Every Write
etcd is a key-value store replicated with Raft. When the API server writes, for example a pod status update, the etcd leader appends the entry to its write-ahead log (WAL) and calls fsync, which forces the data onto stable storage so it survives a power loss. It sends the entry to the followers, which also write and fsync it, and once a majority has it on disk, the entry is committed and applied to the backend database, a bbolt file, which is itself committed to disk periodically.
So every write waits for at least two fsyncs on a majority of machines. etcd is therefore sensitive to disk latency, not throughput: it writes small amounts of data, but it needs each small write to reach the disk in a few milliseconds. The leader also has to send heartbeats every 100 ms by default; if it is stuck behind slow disk work, heartbeats arrive late.
2Connecting the Symptoms to the Disk
Network-attached disks, such as cloud block volumes, add a network round trip to every fsync, and during busy periods other workloads on the same storage or the same host compete for it. fsync latency then jumps from 2 ms to 100 ms or more.
Each symptom follows. Writes wait for slow fsyncs, so the API server's requests exceed their deadline and it logs 'etcdserver: request timed out'. Applying committed entries to the backend takes too long, so etcd warns that apply requests took too long. And when the leader's disk stalls, its heartbeats are delayed past the followers' election timeout of 1,000 ms; a follower starts an election, a new leader is chosen, and the cycle repeats under the same slow disks. Thirty leader changes an hour is the signature of this loop.
- Busy period: shared disk latency risesfsync from 2 ms to 100 ms+
- Leader blocks on WAL fsyncwrites queue up
- API server requests exceed deadline'request timed out'
- Heartbeats late beyond election timeout?YesFollower starts an electionNoWrites slow but leader stays
- New leader on the same slow diskscycle repeats, about 30 changes an hour
5 steps in order. Play them, or step through them one at a time.
3Confirming It With Metrics
etcd exposes Prometheus metrics that tell us directly whether disks are the problem. The most important is etcd_disk_wal_fsync_duration_seconds, a histogram of WAL fsync times; its p99 should stay under about 10 ms. Next is etcd_disk_backend_commit_duration_seconds, the time to commit the backend database; its p99 should stay under about 25 ms. If both are far above these values during the busy periods, storage is the cause.
We correlate them with etcd_server_leader_changes_seen_total, which should be nearly flat in a healthy cluster, and with the peer round-trip time histogram, etcd_network_peer_round_trip_time_seconds, to rule out a network problem between members. etcd's own logs help too: warnings such as 'slow fdatasync' or a leader 'failed to send out heartbeat on time' point at disk.
4Fix Storage First
The real fix is giving etcd fast, dedicated storage. That means low-latency SSD volumes, provisioned for IOPS where the cloud offers it, or local NVMe disks; a volume used only by etcd's data directory, not shared with container images, logs or other databases; and no noisy neighbours on the same physical storage. Enough CPU matters too, because a starved etcd process delays heartbeats as surely as a slow disk.
After moving the data to such a volume, we expect WAL fsync p99 to fall to a few milliseconds and leader changes to drop to nearly zero, and that is how we verify the fix.
5Tune Only Afterwards, Then Check Size and Clients
Only once the disks are healthy do we look at timing settings. heartbeat-interval and election-timeout default to 100 ms and 1,000 ms. If the members are spread over zones with a real round trip of, say, 15 ms, the defaults are fine; across distant regions, we raise both together, keeping the election timeout about ten times the heartbeat interval. Raising the election timeout to hide slow disks only makes real failovers slower while writes stay slow.
We also check the database size. etcd keeps old revisions of keys until compaction removes them, and the file only shrinks after defragmentation. The backend has a quota, 2 GB by default and configurable up to about 8 GB, and if it is reached, etcd raises an alarm and refuses writes. Kubernetes' API server compacts regularly, but we should run defragmentation member by member after compaction and monitor etcd_mvcc_db_total_size_in_bytes.
Finally, we look for clients that write too much: a controller updating a large object every second, a custom resource holding megabytes of data, or events stored in the main etcd. The API server's request metrics by resource reveal them, and moving events to a separate etcd cluster or fixing the controller removes the load.
| Metric or setting | Healthy or default | Seen here |
|---|---|---|
| WAL fsync p99 | under about 10 ms | 184 ms |
| Backend commit p99 | under about 25 ms | 412 ms |
| Leader changes per hour | near 0 | about 30 |
| heartbeat-interval / election-timeout | 100 ms / 1,000 ms | defaults |
| Backend quota | 2 GB default | check db size |
6Follow-up questions
Why not just raise the election timeout to stop the churn?
It hides one symptom and keeps the cause. Writes would still wait for slow fsyncs and still time out, and when a leader really fails, the cluster would take longer to elect a new one. Timeouts should match real network round trips, not compensate for slow disks.
Does adding more etcd members help with slow disks?
No. More members means each write needs more acknowledgements to reach a majority, and each member still fsyncs. Three or five members on fast disks is the right shape.
Why does defragmentation have to be done member by member?
Defragmenting blocks the member while it rewrites its database file. Doing one member at a time keeps a majority available, and starting with followers avoids interrupting the leader.
7Conclusion
In this answer, we traced the timeouts, slow-apply warnings and leader churn to etcd's dependence on fast fsync: on busy network-attached disks, every write and every heartbeat waits, followers call elections and leadership churns. WAL fsync and backend commit latency histograms, leader change counts and peer round-trip times confirm it, and fio checks a disk before use. The fix is dedicated low-latency SSD storage and enough CPU first, timeouts tuned to real round trips only afterwards, plus compaction, member-by-member defragmentation, quota monitoring and taming clients that write too much.
Open with
The most likely cause is slow storage. etcd has to fsync its write-ahead log before it acknowledges a write, on a majority of members, and the leader has to send heartbeats on time.
Then, if they want more
On network-attached disks during busy periods, fsync latency jumps, so writes miss their deadlines and the API server logs request timed out, applying entries is slow, and the leader's heartbeats arrive late, so followers start elections. A new leader on the same slow disks hits the same problem, which is why we see around 30 leader changes an hour.
I'd confirm it with etcd_disk_wal_fsync_duration_seconds, where p99 should be under about 10 milliseconds, and etcd_disk_backend_commit_duration_seconds, under about 25, next to etcd_server_leader_changes_seen_total and the peer round-trip time metrics to rule out the network. The fix is storage first: dedicated low-latency SSD or NVMe volumes just for etcd's data, no noisy neighbours, and enough CPU.
Only after that would I tune heartbeat-interval and election-timeout, defaults 100 milliseconds and one second, to match real round trips, keeping the timeout about ten times the heartbeat. I'd also check database size and compaction, defragment member by member, watch the 2 gigabyte default quota, and look for controllers writing large or very frequent updates.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What is the likely cause, which etcd metrics confirm it, and how do you fix it?": https://scrivio-interview-library.netlify.app/architecture/distributed-systems/165960c0f8/