Skip to main content

Load Average Pinned at 79 on 8 Cores. How K3s's SQLite Datastore Fell Into a Compaction Death Spiral From Operator Leases Alone

1. The Day Load Average Got Pinned at 79 on 8 Cores

section01

On an 8 vCPU / 16GB K3s master node, API server responses visibly slowed down. Tracing the cause led back to K3s's datastore. kubectl get would hang for seconds at a time, and the API server logs kept emitting 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.

K3s is designed to use SQLite directly for a single node, and switch to embedded etcd or an external RDB (MySQL/PostgreSQL) for multi-node clusters (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.

With a managed K3s like Kubo, a Prometheus/Grafana 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.

2. The Culprit Is kine. The Mechanism Baked Into K3s's "Default"

section02

Part of what makes K3s lightweight is a mechanism called kine. Kine is a "shim" that translates etcd's gRPC API into SQL operations, and it supports not just SQLite but also MySQL/MariaDB and PostgreSQL (k3s-io/kine 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.

The official README, however, spells out a clear constraint: the SQLite backend only supports a single instance, and even on shared storage, multiple kine instances cannot operate against the same DB file (k3s-io/kine repository). In other words, SQLite is built exclusively for single-node setups, and distortions appear easily once it's kept under production-grade load.

In this case, the distortion came from 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 (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.

3. Why Compaction Falls Into a "Death Spiral"

section03

As with etcd, a kine/SQLite setup also needs periodic "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.

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 (Litestream's operational guide). SQLite checkpoints come in four modes — PASSIVE, FULL, RESTART, and TRUNCATE — and only TRUNCATE mode, invoked via PRAGMA wal_checkpoint(TRUNCATE), actually reclaims disk space (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.

Kubo 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.

4. SQLite, Embedded etcd, or External RDB — How to Judge K3s's Three Datastore Options

section04

K3s's datastore comes down to three options depending on your use case.

OptionSupported node countOperational characteristics
SQLiteSingle node onlyBuilt into the binary with near-zero overhead; unusable on multi-server setups (SUSE official documentation)
Embedded etcd3+ nodes (odd number)Raft-based quorum management; K3s automatically handles snapshots and compaction, but requires an odd node count (K3s embedded etcd documentation)
External RDB (MySQL/MariaDB/PostgreSQL/etcd)2+ nodesLets you reuse existing managed-DB operations, but bloat monitoring and vacuuming responsibility stays on you (K3s external datastore documentation)

The decision axis is simple. For single-node dev/test environments, SQLite is enough. For a production HA setup where you don't want to own datastore operations yourself, 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, external RDB is the option. Worth noting: K3s is registered as a CNCF project at Sandbox maturity (CNCF project page), and the datastore decision criteria here largely overlap with standard Kubernetes operational knowledge.

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.

5. Conclusion: Avoiding the "Invisible Debt" of Your Datastore

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.

If you run K3s yourself, monitoring this kind of datastore bloat and making the migration call are entirely your own responsibility. Kubo is K3s-based with Prometheus/Grafana built in standard, reducing the burden of running a cluster for a fixed cost starting around ¥52,800/month (4vCPU/8GB/40GB × 3 nodes). If you'd like to talk through migrating to embedded etcd or designing an external RDB connection, get in touch for a free consultation.

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.

Related articles

← Back to all posts