Proxmox VE: Performance of KVM vs. LXC

Supermicro Server with Intel CPU

Since the company’s inception in 2011, we have used a variety of virtualization technologies. These technologies’ benefits are rather indisputable: cost reduction and ease of management (backup, migration, cloning, etc.) In fact, virtualization has become a must in the field of information technology.

Although we have good amount of experience with virtualization technologies such as VirtualBox and VMWare, our use of KVM and LXC is fairly recent. For some time now, we have migrated our entire infrastructure to Proxmox, an all-in-one virtualization solution.

To get the most out of this new infrastructure, we want to establish the best configurations to get the maximum performance possible from our Virtual Machines.

To begin our analysis, we want to compare the performance between the two virtualization technologies available with Proxmox, KVM and LXC:

  • KVM (Kernel-based Virtual Machine) is a hyperviseur built into the Linux core. KVM is a virtualization technology similar to what is offered by VirtualBox or VMWare. The hypervisor emulates all the material. Thus, the operating system believes it is running on a physical machine. It is, therefore, possible to install an operating system without alteration.
  • LXC (Linux Containers) is another virtualization technology that is also integrated into the Linux core. However, it uses isolation to separate the performance of each machine. Compared to KVM, the hardware is not emulated; the host system shares it. Thus, each Virtual Machine uses the same core. It would therefore be impossible to install MS Windows in an LXC container. LXC is a virtualization technology similar to what is offered by OpenVZ and Docker.

Given the nature of LXC, it is expected to outperform KVM. This is what we want to confirm with our tests.

To execute all our performance tests reliably and reproducibly, we used Phoronix Test Suite.

Here are the technical specifications of the physical server and the two Virtual Machines.

Results

Multiple Sequence Alignment

In this test, which verifies the CPU’s power by performing DNA alignment calculations (no multi-thread), we see that KVM has a considerable lead over LXC. The big difference between the physical host and KVM is explained by the number of CPUs allocated: 16 CPU for the host vs. 2 CPU for KVM.

CAMELLIA256-ECB Cipher

This test also allows you to check the performance of a single CPU by performing cryptography calculations (no multi-thread). All three tests yield similar results. We note that LXC has a slight lead over KVM.

AI Chess Performance

This test verifies the performance of a single CPU by simulating a game of chess (no multi-thread). All three tests yield similar results. We note that LXC has a slight lead over KVM.

Poisson Pressure Solver

This test also verifies the performance of a single CPU by solving linear equations (no multi-thread). All three tests yield similar results. We note that LXC has a slight lead over KVM.

7zip Compress Speed Test

This test essentially verifies the performance of the CPU by compressing data (with multi-thread). The physical host has a large lead due to the number of CPUs allocated: 16 CPU for the host vs. 2 CPU for KVM. We note that LXC has a slight lead over KVM.

C-Ray Total Time

This test verifies the performance of the CPU by calculating ray tracing. This test allows you to check the CPU’s performance in calculating floating numbers (with multi-thread). The physical host has a large lead due to the number of CPUs allocated: 16 CPU for the host vs. 2 CPU for KVM. We note that LXC has a slight lead over KVM.

WAV To FLAC

This test verifies the performance of a single CPU by converting a music file from THE WAV format to FLAC (no multi-thread). All three tests yield similar results. We note that LXC has a slight lead over KVM.

WAV To MP3

This test verifies the performance of a single CPU by converting a music file from THE WAV format to MP3 (no multi-thread). All three tests yield similar results. We note that LXC has a slight lead over KVM.

Apache Static Web Page Serving

This test represents a typical server use that tests the CPU, discs and memory. The physical host obviously provides better performance, followed by LXC and KVM.

The results of this test confirm our initial hypothesis: LXC performs better than KVM.

Aio Stress Random Write

This test can be akin to using a database that does a lot of writing to disk. Surprisingly, KVM has a slight lead over LXC.

iozone: Size: 4GB — Disk Test: Read Performance

This test verifies random disk playback. The results provided by this test are not representative. The discs in the server are not able to provide 1300MB/s. It must be inferred that the system cache greatly increases the results.

We must conclude the following: LXC can get the most performance from the system cache, while KVM cannot take advantage of it probably because it doesn’t have as much memory as the host.

iozone: 4GB — Disk Test: Write Performance

This test verifies random writing to disk. Here, too, we must understand that we measure the cache of data. The results provided by this test are not representative.

Pfam Database Search

This test simulates a query in a database. Unsurprisingly, KVM is still the last in line, but offers reasonable performance.

LZMA 256MB File Compression

This test essentially verifies the performance of a single CPU by compressing data with the LZMA algorithm. I can’t explain KVM’s lead in this test.

PHP Benchmark Suite

This test essentially verifies the performance of a single CPU by running PHP scripts. All three tests yield very similar results. LXC still has a small lead over KVM.

Illumination Renderer 100 Samples

This test verifies the performance of the CPU by calculating light trajectories to generate an image. The physical host has a large lead due to the number of CPUs allocated: 16 CPU for the host vs. 2 CPU for KVM. We note that LXC has a slight lead over KVM.

Tableaux des Résultats

Analysis of results

With these results, it is observed that CPU-related tests provide comparable results in LXC and KVM if the number of CPUs allocated to Virtual Machines is the same. It is also observed that the performance of the physical host, LXC and KVM are all very similar when the test verifies the performance of a single CPU. It should be noted, however, that LXC wins with a small lead in the majority of tests.

In terms of disk-related tests, there is a significant difference between LXC and KVM. KVM being slower than LXC in all writing or disc playback tests.

This suggests that KVM and LXC provide similar performance if your application is strictly CPU-related. LXC and KVM make the most of the CPUs allocated to them. There is almost no loss of performance compared to the physical host.

On the other hand, when writing to disk or disk playback is involved, KVM and LXC don’t perform as well as the physical host. Reading and writing to the disc is, therefore, the Achilles heel of virtualization. We need to move in this direction if we want to improve the performance of our Virtual Machines.

Overall, LXC clearly performs better than KVM. That said, KVM is not far behind.

Based on these results, should you convert your entire environment to LXC? Perhaps not. The effort required to convert multiple Virtual Machines compared to the small performance gain probably doesn’t warrant it. Besides, performance is just one of several factors in your decision-making between KVM and LXC. In addition, in future articles, we will determine the best configuration parameters to improve KVM and LXC disk writing and playback performance.

Originally published at https://www.ikus-soft.com.

Involved in the open source community for more than 10 years. He is the founding president of Ikus Soft inc.,