[{"data":1,"prerenderedAt":357},["ShallowReactive",2],{"blog-en-k3s-sqlite-kine-compaction-death-spiral":3,"blog-related-en-k3s-sqlite-kine-compaction-death-spiral":308,"blog-en-k3s-sqlite-kine-compaction-death-spiral-alt":295},{"id":4,"title":5,"author":6,"body":7,"date":289,"description":290,"extension":291,"image":292,"locale":293,"meta":294,"navigation":295,"path":296,"seo":297,"stem":298,"tags":299,"updated":306,"__hash__":307},"blog\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral.md","Load Average Pinned at 79 on 8 Cores. How K3s's SQLite Datastore Fell Into a Compaction Death Spiral From Operator Leases Alone","Kubo Team",{"type":8,"value":9,"toc":280},"minimark",[10,15,23,40,51,60,64,70,83,94,107,111,117,124,143,149,153,159,162,233,254,257,261,264,277],[11,12,14],"h2",{"id":13},"_1-the-day-load-average-got-pinned-at-79-on-8-cores","1. The Day Load Average Got Pinned at 79 on 8 Cores",[16,17,18],"p",{},[19,20],"img",{"alt":21,"src":22},"section01","https:\u002F\u002Fcdn.kubo.hexabase.io\u002Fimages\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral\u002Fsection01.webp",[16,24,25,26,30,31,35,36,39],{},"On an 8 vCPU \u002F 16GB K3s master node, API server responses visibly slowed down. Tracing the cause led back to ",[27,28,29],"strong",{},"K3s's datastore",". ",[32,33,34],"code",{},"kubectl get"," would hang for seconds at a time, and the API server logs kept emitting ",[32,37,38],{},"Failed to get storage metrics: context deadline exceeded",". CPU usage was pinned near 100%, and load average on the 8-core box had climbed from the 30s into the high 70s.",[16,41,42,43,50],{},"K3s is designed to use SQLite directly for a single node, and switch to embedded etcd or an external RDB (MySQL\u002FPostgreSQL) for multi-node clusters (",[44,45,49],"a",{"href":46,"rel":47},"https:\u002F\u002Fdocs.k3s.io\u002Fdatastore\u002Fha",[48],"nofollow","K3s official documentation","). This article walks through why the default SQLite setup hit its limit, and how to think about choosing K3s's datastore, based on an actual incident.",[16,52,53,54,59],{},"With a managed K3s like ",[44,55,58],{"href":56,"rel":57},"https:\u002F\u002Fkubo.hexabase.io\u002F",[48],"Kubo",", a Prometheus\u002FGrafana monitoring stack comes standard, making it easier to catch warning signs such as abnormal CPU or load average early. Let's look at what was actually happening, step by step.",[11,61,63],{"id":62},"_2-the-culprit-is-kine-the-mechanism-baked-into-k3ss-default","2. The Culprit Is kine. The Mechanism Baked Into K3s's \"Default\"",[16,65,66],{},[19,67],{"alt":68,"src":69},"section02","https:\u002F\u002Fcdn.kubo.hexabase.io\u002Fimages\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral\u002Fsection02.webp",[16,71,72,73,76,77,82],{},"Part of what makes K3s lightweight is a mechanism called ",[27,74,75],{},"kine",". Kine is a \"shim\" that translates etcd's gRPC API into SQL operations, and it supports not just SQLite but also MySQL\u002FMariaDB and PostgreSQL (",[44,78,81],{"href":79,"rel":80},"https:\u002F\u002Fgithub.com\u002Fk3s-io\u002Fkine",[48],"k3s-io\u002Fkine repository","). K3s can run without spinning up etcd as a separate process precisely because kine translates all reads and writes from the API server into SQL.",[16,84,85,86,89,90,93],{},"The official README, however, spells out a clear constraint: ",[27,87,88],{},"the SQLite backend only supports a single instance, and even on shared storage, multiple kine instances cannot operate against the same DB file"," (",[44,91,81],{"href":79,"rel":92},[48],"). In other words, SQLite is built exclusively for single-node setups, and distortions appear easily once it's kept under production-grade load.",[16,95,96,97,100,101,106],{},"In this case, the distortion came from ",[27,98,99],{},"leader-election lease updates"," from multiple operators running inside the cluster. Kubernetes' default lease update cadence, per client-go, is defined as a 15-second LeaseDuration, a 10-second RenewDeadline, and a 2-second RetryPeriod (",[44,102,105],{"href":103,"rel":104},"https:\u002F\u002Fpkg.go.dev\u002Fk8s.io\u002Fclient-go\u002Ftools\u002Fleaderelection",[48],"client-go leaderelection package documentation","). A single operator's writes at that frequency are negligible, but once multiple operators — monitoring stacks, GitOps controllers, CSI drivers — run side by side, the lease-update writes stack up.",[11,108,110],{"id":109},"_3-why-compaction-falls-into-a-death-spiral","3. Why Compaction Falls Into a \"Death Spiral\"",[16,112,113],{},[19,114],{"alt":115,"src":116},"section03","https:\u002F\u002Fcdn.kubo.hexabase.io\u002Fimages\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral\u002Fsection03.webp",[16,118,119,120,123],{},"As with etcd, a kine\u002FSQLite setup also needs periodic ",[27,121,122],{},"\"compaction\""," to remove old revisions. The problem starts the moment write volume outpaces compaction's processing speed. Old rows that don't get cleaned up pile up, the table bloats, and compaction queries themselves start timing out, letting even more unprocessed rows accumulate — once you're in this loop, it doesn't recover on its own.",[16,125,126,127,132,133,136,137,142],{},"In this incident, the SQLite data file had grown to several gigabytes, and the WAL (Write-Ahead Log) file — never checkpointed — had ballooned past 10GB. SQLite's WAL can grow unbounded when long-running read transactions keep blocking checkpoints (",[44,128,131],{"href":129,"rel":130},"https:\u002F\u002Flitestream.io\u002Fguides\u002Fwal-truncate-threshold\u002F",[48],"Litestream's operational guide","). SQLite checkpoints come in four modes — PASSIVE, FULL, RESTART, and TRUNCATE — and only TRUNCATE mode, invoked via ",[32,134,135],{},"PRAGMA wal_checkpoint(TRUNCATE)",", actually reclaims disk space (",[44,138,141],{"href":139,"rel":140},"https:\u002F\u002Fsqlite.org\u002Fc3ref\u002Fc_checkpoint_full.html",[48],"SQLite official reference","). Forcing that checkpoint works as a stopgap, but it's purely symptomatic treatment — as long as the operator count stays the same, the cluster drifts right back into the same state.",[16,144,145,148],{},[44,146,58],{"href":56,"rel":147},[48]," shows a cluster's CPU and memory usage in its UI, which makes changes like a control plane pinned at full CPU easier to notice.",[11,150,152],{"id":151},"_4-sqlite-embedded-etcd-or-external-rdb-how-to-judge-k3ss-three-datastore-options","4. SQLite, Embedded etcd, or External RDB — How to Judge K3s's Three Datastore Options",[16,154,155],{},[19,156],{"alt":157,"src":158},"section04","https:\u002F\u002Fcdn.kubo.hexabase.io\u002Fimages\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral\u002Fsection04.webp",[16,160,161],{},"K3s's datastore comes down to three options depending on your use case.",[163,164,165,181],"table",{},[166,167,168],"thead",{},[169,170,171,175,178],"tr",{},[172,173,174],"th",{},"Option",[172,176,177],{},"Supported node count",[172,179,180],{},"Operational characteristics",[182,183,184,202,218],"tbody",{},[169,185,186,190,193],{},[187,188,189],"td",{},"SQLite",[187,191,192],{},"Single node only",[187,194,195,196,201],{},"Built into the binary with near-zero overhead; unusable on multi-server setups (",[44,197,200],{"href":198,"rel":199},"https:\u002F\u002Fdocumentation.suse.com\u002Fcloudnative\u002Fk3s\u002Flatest\u002Fja\u002Fdatastore\u002Fdatastore.html",[48],"SUSE official documentation",")",[169,203,204,207,210],{},[187,205,206],{},"Embedded etcd",[187,208,209],{},"3+ nodes (odd number)",[187,211,212,213,201],{},"Raft-based quorum management; K3s automatically handles snapshots and compaction, but requires an odd node count (",[44,214,217],{"href":215,"rel":216},"https:\u002F\u002Fdocs.k3s.io\u002Fdatastore\u002Fha-embedded",[48],"K3s embedded etcd documentation",[169,219,220,223,226],{},[187,221,222],{},"External RDB (MySQL\u002FMariaDB\u002FPostgreSQL\u002Fetcd)",[187,224,225],{},"2+ nodes",[187,227,228,229,201],{},"Lets you reuse existing managed-DB operations, but bloat monitoring and vacuuming responsibility stays on you (",[44,230,232],{"href":46,"rel":231},[48],"K3s external datastore documentation",[16,234,235,236,239,240,243,244,247,248,253],{},"The decision axis is simple. For single-node dev\u002Ftest environments, ",[27,237,238],{},"SQLite is enough",". For a production HA setup where you don't want to own datastore operations yourself, ",[27,241,242],{},"embedded etcd"," is the choice (K3s manages it automatically — you just need an odd number of nodes). If you already have RDS-grade managed-DB operations in place and want to build on it, ",[27,245,246],{},"external RDB"," is the option. Worth noting: K3s is registered as a CNCF project at Sandbox maturity (",[44,249,252],{"href":250,"rel":251},"https:\u002F\u002Fwww.cncf.io\u002Fprojects\u002Fk3s\u002F",[48],"CNCF project page","), and the datastore decision criteria here largely overlap with standard Kubernetes operational knowledge.",[16,255,256],{},"In a cluster where the operator count keeps growing, as in this case, staying on SQLite only makes the eventual migration cost bigger. And if you do migrate, pinpointing the right timing and the right option is the part that matters most.",[11,258,260],{"id":259},"_5-conclusion-avoiding-the-invisible-debt-of-your-datastore","5. Conclusion: Avoiding the \"Invisible Debt\" of Your Datastore",[16,262,263],{},"K3s's appeal is that it \"just works\" out of the box, but that default (SQLite + kine) comes with a clear precondition: it's built for a single node. As operators accumulate in a cluster, the write load on the datastore from leader-election lease updates alone quietly piles up. Rather than noticing only after CPU or load average goes haywire, you need a setup that lets you monitor datastore table size and compaction duration as a matter of routine.",[16,265,266,267,270,271,276],{},"If you run K3s yourself, monitoring this kind of datastore bloat and making the migration call are entirely your own responsibility. ",[44,268,58],{"href":56,"rel":269},[48]," is K3s-based with Prometheus\u002FGrafana built in standard, reducing the burden of running a cluster for a fixed cost starting around ¥52,800\u002Fmonth (4vCPU\u002F8GB\u002F40GB × 3 nodes). If you'd like to talk through migrating to embedded etcd or designing an external RDB connection, ",[44,272,275],{"href":273,"rel":274},"https:\u002F\u002Fwww.hexabase.com\u002Fcontact-us\u002F",[48],"get in touch"," for a free consultation.",[16,278,279],{},"The datastore is the \"foundation\" of your cluster, and getting that choice wrong makes it expensive to move later. If you're running K3s in production, it's worth taking stock now of your current node count and the pace at which operators are growing, and deciding which of SQLite, embedded etcd, or external RDB actually fits.",{"title":281,"searchDepth":282,"depth":282,"links":283},"",2,[284,285,286,287,288],{"id":13,"depth":282,"text":14},{"id":62,"depth":282,"text":63},{"id":109,"depth":282,"text":110},{"id":151,"depth":282,"text":152},{"id":259,"depth":282,"text":260},"2026-11-17","A K3s cluster's default SQLite+kine datastore spiraled into compaction failure from operator lease updates alone, pinning CPU near 100%. Here's how to judge SQLite vs embedded etcd vs external RDB.","md","https:\u002F\u002Fcdn.kubo.hexabase.io\u002Fimages\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral\u002Ftitle.webp","en",{},true,"\u002Fblog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral",{"title":5,"description":290},"blog\u002Fen\u002Fk3s-sqlite-kine-compaction-death-spiral",[300,301,302,75,303,304,305],"k3s","kubernetes","sqlite","etcd","datastore","high-availability",null,"ZUC9mlaQqEJp9nDj7wSdRpPZ-lU8PY8NPUEMz8vL-6w",[309,317,324,332,339,348],{"path":310,"title":311,"description":312,"date":313,"tags":314},"\u002Fblog\u002Fen\u002Fproxmox-corosync-self-fencing-k3s-etcd-quorum","A K3s Cluster Built on 2 Proxmox Hosts Went Down Entirely After a Brief Network Blip. The Culprit Was Corosync's Self-Fencing","A K3s cluster running on 2 Proxmox hosts went down completely after a few seconds of network interruption: both the host and the etcd quorum were taken out together. Here's why Corosync's self-fencing was the real cause, and how node placement design prevents it.","2026-11-11",[300,301,315,303,305,316],"proxmox","quorum",{"path":318,"title":319,"description":320,"date":321,"tags":322},"\u002Fblog\u002Fen\u002Fk3s-kubeadm-ha-etcd-failover-rto-gap","Your RTO Said 30 Seconds. It Took 3 Minutes. Why K3s and kubeadm HA Specs Don't Match Reality","How long does failover really take with K3s embedded etcd versus kubeadm stacked\u002Fexternal etcd? We examine the gap between official RTO targets and real-world recovery times, and how failure domains and node counts differ.","2026-10-09",[300,301,303,305,323],"kubeadm",{"path":325,"title":326,"description":327,"date":328,"tags":329},"\u002Fblog\u002Fen\u002Fk3s-etcd-snapshot-restore-token-cluster-reset-pitfalls","The Automated etcd Snapshots Were Running Every Day. Here's Why K3s Restore Still Failed in Production","K3s's etcd snapshots looked healthy every day, yet restore failed during a real outage. Three real-world traps — token management, S3 restore incidents, and cluster-reset pitfalls — reveal what's really at risk in embedded etcd backups.","2026-09-21",[300,301,303,330,331,305],"backup-restore","disaster-recovery",{"path":333,"title":334,"description":335,"date":336,"tags":337},"\u002Fblog\u002Fen\u002Fk3s-proxmox-live-migration-etcd-quorum-affinity-design","Proxmox Live Migration Quietly Breaks K3s etcd Quorum: When Virtualization Collides with Raft","A deep dive into how live-migrating a K3s control plane VM on Proxmox can break etcd quorum, explained through heartbeat\u002Felection-timeout mechanics and Proxmox affinity design, with concrete operational countermeasures.","2026-09-09",[300,301,315,303,338,305],"live-migration",{"path":340,"title":341,"description":342,"date":343,"tags":344},"\u002Fblog\u002Fen\u002Fk3s-vs-microk8s-ha-etcd-dqlite-edge-production","K3s vs MicroK8s: Which One Actually Wins in Production? The HA Fork Between dqlite and etcd","K3s vs MicroK8s: both are called 'lightweight Kubernetes,' but the real production divide is HA architecture. We compare K3s's embedded etcd and MicroK8s's dqlite using official documentation data.","2026-10-25",[300,345,301,305,346,347],"microk8s","edge-computing","comparison",{"path":349,"title":350,"description":351,"date":352,"tags":353},"\u002Fblog\u002Fen\u002Fk3s-rke2-migration-production-downtime-cis-ha","We Migrated K3s to RKE2 and Production Went Down for Two Hours. What \"Lightweight K8s\" Buyers Overlook","K3s vs RKE2 is often reduced to a feature checklist. Using a real production migration incident, we break down CIS Hardening, HA requirements, and storage assumptions to help you choose the right distribution for production.","2026-10-05",[300,354,301,355,305,356],"rke2","cis-benchmark","production-kubernetes",1795513795794]