TECHNICAL GUIDE · COMPUTE OPTIMIZATION

Bare metal vs tuned KVM virtualization: latency analysis and database throughput

While hypervisors provide unmatched provisioning agility, high-frequency transactional databases and microsecond-sensitive services can suffer from CPU steal time and TLB virtualization overhead. We analyze exactly when bare metal is necessary and how to tune KVM to within 1.5% of bare metal performance.

Updated october 2026
7 min read
Altovar Technical Editorial Team

1. What the hypervisor really costs

Virtualization adds a layer between the workload and the hardware. For most business applications that layer costs little: CPU instructions run natively, and the hypervisor intervenes only on specific events such as interrupts, device emulation and memory management. The costs show up mainly in tail latency and jitter rather than in average throughput, which is why averages alone can hide the problem. A database that answers in a few milliseconds on average can still stall for a noticeable time at the worst moments.

Two effects matter most for databases. CPU steal time measures the time a virtual CPU waited because the physical CPU was serving another virtual machine. Memory translation adds work for the processor when the translation lookaside buffer (TLB) misses, which happens more often with small pages and large working sets. Both are measurable with standard monitoring tools, and both can be reduced by tuning, though never removed completely.

2. When bare metal is the right answer

Dedicated hardware makes sense when the workload is latency sensitive and predictable performance matters more than provisioning speed. Typical cases include high-volume transactional databases, in-memory systems with tight response targets, and storage nodes that need direct access to drives and network cards. In these cases the simplicity of one workload per machine is itself a benefit, because there are fewer variables to explain when something slows down.

It is much less justified for stateless web tiers, batch jobs, development environments and workloads that scale horizontally. For those, virtual machines or containers give better utilization and faster recovery, because a failed instance can be replaced in minutes rather than repaired. The decision should follow measured requirements, not the assumption that physical hardware is always faster. Ask for the same test on both platforms before deciding.

3. Tuning KVM for database workloads

KVM (Kernel-based Virtual Machine) can be tuned to remove most of the common sources of variance. The table lists the techniques that matter most and the trade-off each one introduces. Apply them one at a time and measure the effect of each, so that you know which change actually helped. Keep a record of each setting so the configuration can be rolled back if a later change causes trouble.

Each technique trades flexibility for predictability, which is why it belongs to workloads that have been sized and measured, not to every virtual machine by default. Transparent HugePages deserve a specific note: automatic promotion of memory pages can cause latency spikes during memory compaction. Many database teams prefer explicit, pre-allocated HugePages and disable transparent promotion on the database host. Check the documentation of your database engine before changing kernel settings, because recommendations differ between engines and versions.

TechniquePurposeWatch out for
NUMA pinningKeep memory and vCPUs on the same socketUneven sizing across sockets causes remote memory access
Static HugePagesReduce TLB misses for large buffer poolsMemory reserved in advance is not available to other guests
CPU pinningAvoid scheduler migrations and keep caches warmWastes capacity when the guest is idle
SR-IOV or device passthroughGive guests near-native access to network cards and NVMe drivesLive migration and snapshots become harder

4. Measuring the difference properly

A fair comparison runs the same database version, the same data set, the same queries and the same client load on both platforms. Measure throughput and latency percentiles, not only averages. A p99 or p99.9 latency shows the jitter that transactional applications actually feel, because one slow request in a hundred can be enough to degrade a user-facing page. Averages and medians will look healthy while those requests still arrive.

Watch for hidden variables: power and frequency governor settings, BIOS options, noisy neighbours on shared hosts and storage caches. Run each test long enough to reach steady state, and repeat it at different times of the day if the hosts are shared. A single run that looks better than the other is not evidence of anything, and a benchmark that is not written down before the tests start can easily be tuned until it favours the expected answer.

5. Storage and network paths in virtual databases

Storage is often where virtualized databases lose performance, more than in CPU. Emulated disk controllers add overhead, while paravirtualized drivers or passthrough devices reduce it. Choose the disk path explicitly and test write-heavy workloads, because flush and fsync behaviour can surprise you when the path changes. A configuration that looks identical on paper can behave very differently once the write cache is involved.

The same logic applies to networking. Replication and client traffic should not compete for the same queue during peak load. Where latency matters, plan dedicated interfaces and check how interrupts are distributed across CPU cores, since a single busy core can become the limit. Passthrough trades some flexibility for performance, so document which guests use it and why, and keep that list up to date.

6. How to start: a benchmark plan

Do not decide the architecture from a single benchmark. Start with a representative test that reflects your real database and let the results choose the next step. A plan that is written down before the tests start protects against tuning the setup until it favours one platform, and it makes the result easy to explain to the people who will approve the decision.

If the tuned virtual machine meets the latency target, keep the flexibility of virtualization. If it does not, the evidence will show which component is responsible, and bare metal becomes a targeted decision instead of a guess. In both cases the team leaves with a documented configuration that can be reviewed later, when the workload changes. A tuned configuration with no written record is hard to reproduce, so keep the notes with the platform documentation.

  1. Capture the current workload: query mix, concurrency, data size and latency targets.
  2. Build a baseline on the current platform with the same database version and configuration.
  3. Run the same test on a tuned KVM guest with NUMA pinning, HugePages and a suitable disk path.
  4. Compare steady-state throughput and tail latency over several runs.
  5. Check CPU steal, memory pressure and storage latency during each test.
  6. Choose the platform that meets the targets with the simplest operating model.

Frequently Asked Questions

When should an enterprise choose bare metal over virtual machines?

When a workload has tight, predictable latency requirements that a tuned virtual machine cannot meet, or when it needs direct hardware access that virtualization restricts. Examples include high-volume transactional databases and storage nodes. For stateless or horizontally scaled services, virtual machines usually give better operational value.

Does KVM always add a noticeable performance penalty?

Not usually for CPU-bound work with a good configuration. The penalty is more visible in tail latency, in memory-intensive workloads and on I/O paths that use emulated devices. Measuring with your own workload is the only reliable way to know, because results depend on the hardware, the kernel version and the tuning.

Are HugePages always beneficial?

They often help databases with large memory footprints, because fewer TLB misses means less translation overhead. However, they reserve memory that other guests cannot use, and sizing errors leave memory idle or cause allocation failures. Pre-allocate them to match the database buffer configuration and monitor their actual usage.

Is CPU pinning a good default?

Not for every virtual machine. Pinning helps a latency-critical database by avoiding scheduler migrations and keeping caches warm, but it reduces flexibility and wastes capacity when the guest is idle. Use it for workloads that have been measured and justify the trade-off, and document the layout.

What should I check first if a database feels slow on a virtual machine?

Start with evidence: CPU steal time, storage latency at both guest and host level, memory pressure, and whether NUMA placement is correct. Compare these metrics during the slow period with a quiet period. Often the cause is storage or memory placement rather than the hypervisor itself.

About this content

General informational guide. Regulations and technical requirements change over time: always check the official sources and assess your specific case with a qualified technical or legal advisor.

GET IN TOUCH

Talk to our team.

We'll show how Altovar integrates into your infrastructure. No commitment, no sales pitch. Just a technical conversation.

BOOK A DEMO →