A 1-vCPU VM Is a Queueing System, Not a Cheap Server
On one-core KVM guests, p99 depends less on language slogans than on steal time, reclaim, pacing, and bounded event-loop work.
The case for a lean 1-vCPU VM is sound, but tail latency depends on whether CPU time, memory reclaim, and event-loop work stay bounded. Measure steal time and PSI first. Test ZRAM and fq with BBR against your workload, and scale up when a single core cannot keep utilization safely below saturation.
The case for the small VM
The industry consensus has a solid economic argument: a lightly loaded service does not need a fleet of large machines. One vCPU reduces baseline cost, Rust avoids tracing garbage-collection pauses, and Linux can schedule network and application work efficiently. If average CPU utilization is modest, the unused capacity on a larger instance buys little.
The standard remedies also sound reasonable. CUBIC is widely deployed, swap absorbs memory pressure, and an event loop using epoll can handle many sockets without one thread per connection. Keep the stack conventional, avoid premature tuning, and use horizontal scaling when demand rises. For a stable workload with headroom and predictable neighbors, that advice often works.
The one-core queue changes the math
A vCPU is a share of a host processor, not a promise of uninterrupted execution. KVM steal time records intervals when the guest wanted CPU but the host scheduled something else. Inside the guest, top can show low application CPU even as work waits. Background package timers can add another burst of CPU, disk, and page-cache activity at the wrong moment.
Queueing makes these interruptions disproportionately visible at the tail. In an idealized M/M/1 queue, the 99th-percentile response time is approximately 4.605 / (μ − λ), where μ is service capacity and λ is arrival rate. At 90% utilization, that is about 46 average service times. At 70%, about 15. This is a model, not a production prediction, but it explains why a small loss of available CPU can turn acceptable averages into painful p99s.
Measure the contention before changing the protocol. Track steal time alongside CPU and memory PSI, request latency, and the timing of scheduled jobs. A useful first investigation is whether latency spikes line up with steal, reclaim, or a scheduled task. If they do, changing congestion control will not recover the CPU cycles the guest never received.
# Sample guest CPU accounting and pressure during a latency test
mpstat -P ALL 1
cat /proc/pressure/cpu
cat /proc/pressure/memory
vmstat 1
Memory compression is a trade, not free RAM
ZRAM stores swapped pages in compressed memory instead of sending them to a disk-backed swap device. That can avoid slow I/O when the working set barely exceeds RAM, but every page fault still has to decompress data, and compression consumes the same constrained CPU needed by the application. Under sustained swap-in and swap-out, a compressed swap device can relocate the bottleneck rather than remove it.
The algorithm choice matters. Zstd can compress more tightly than faster alternatives, which may reduce memory use, but a one-core VM must pay the compression cost. Test it against the actual page mix and load, comparing p99, CPU time, swap-in rate, and memory PSI. If the working set is far beyond RAM, add memory or reduce it. Do not treat a better compression ratio as a capacity plan.
The same distinction applies to Rust. Rust has no built-in tracing garbage collector, but that does not make an application allocation-free or pause-free. Allocator contention, locks, blocking syscalls, page faults, and host descheduling remain. A language choice can remove one source of pauses; it cannot erase the queue.
BBR helps a different queue
CUBIC grows its congestion window in response to loss, so a full bottleneck queue can mean both packet drops and added delay before the sender backs off. BBR instead estimates bottleneck bandwidth and minimum round-trip time to control pacing and in-flight data. Linux’s BBR documentation recommends the fq queueing discipline for pacing support, though behavior depends on kernel version, traffic mix, and the path. See the kernel BBR documentation.
That is a network-path intervention, not a fix for CPU starvation. A busy guest can miss pacing deadlines. A receiver, middlebox, or competing flow can change results. Compare CUBIC and BBR under representative concurrency, loss, and rate limits, measuring throughput and p95/p99 latency on both ends. Keep the change only if the application’s actual path improves.
Choose by the bottleneck
| Symptom or constraint | First response | Decision rule |
|---|---|---|
| Steal time rises during latency spikes | Check host contention and VM placement | Move or resize if the pattern persists |
| Memory PSI and swap activity rise together | Reduce working set or add RAM | Test ZRAM only when compression cost is affordable |
| Network queueing drives RTT under load | Compare CUBIC with BBR and fq | Keep BBR only when measured tail latency improves |
| One connection or handler monopolizes the loop | Bound work per event and yield | Retest fairness at production concurrency |
| CPU stays near saturation with growing queues | Add a core or reduce work | Do not expect kernel tuning to create capacity |
With epoll, fairness depends partly on what the application does after readiness notification. An edge-triggered handler that drains one busy socket indefinitely can delay other ready sockets. Process a bounded amount, then return to the loop so other work can run. This protects responsiveness, but adds scheduling overhead, so benchmark the budget instead of choosing it by instinct.
The practical counter-thesis is not “small VMs are bad.” It is that low price per vCPU says little about the cost of a queued request. Keep the single-core design when measurements show headroom and stable tails. Tune ZRAM or the network only for a demonstrated bottleneck, and scale out or up when one core cannot sustain the required load with margin.
Discussion (2)
ZRAM’s compression latency is rarely shown in memory PSI. Under memory pressure, do you see the compression CPU cost appear as some pressure in cpu PSI, or is it just folded into the reclaim stall time? This matters for predicting whether a latency spike is from host steal or the guest’s own compression work fighting for the same single vCPU.
ZRAM compression CPU cost should show up as some pressure in cpu PSI because it's executing on the guest CPU. However, if the compression is happening in a high-priority kernel thread, it might not directly contribute to user-space CPU pressure. You'd need to inspect /proc/stat and mpstat output to tease this apart.