Console Login

Stop Using OpenVZ for Production: Why KVM is the Only Serious Choice for High-Performance Hosting in 2012

Stop Using OpenVZ for Production: Why KVM is the Only Serious Choice for High-Performance Hosting

It is 2012, yet I still see seasoned systems administrators deploying high-load MySQL clusters on OpenVZ containers. It’s a ticking time bomb. If you have ever been woken up at 3:00 AM because your database locked up due to a "noisy neighbor" on the same physical node, you know exactly what I am talking about.

The hosting market is currently flooded with cheap VPS providers promising "Burst RAM" and unlimited resources. But in the world of production environments—whether you are running a Magento store or a custom Python/Django backend—virtualization architecture matters more than the sticker price. At CoolVDS, we made the architectural decision to build our infrastructure exclusively on KVM (Kernel-based Virtual Machine). Today, I am going to explain why container-based virtualization is failing your application and how to tune a KVM instance for raw performance.

The "Burst RAM" Lie and the Shared Kernel Trap

To understand why your server feels sluggish despite low load averages, you have to look at the kernel. With OpenVZ (which many budget hosts use), you aren't getting a dedicated OS. You are getting a glorified chroot environment. All containers on the host share the same kernel.

This leads to two critical problems:

  1. Resource Overselling: Providers can sell 64GB of RAM on a node that only has 32GB physically, relying on the fact that not everyone uses it at once. This is "Burst RAM." When everyone does use it, your processes get killed by the OOM (Out of Memory) killer.
  2. Kernel Bottlenecks: If one user tweaks their iptables incorrectly or triggers a kernel panic, the entire physical node—and your server—goes down.

KVM is different. It utilizes hardware virtualization extensions (Intel VT-x or AMD-V). Your CoolVDS instance has its own kernel, its own memory space, and acts like a dedicated server. If a neighbor crashes, you don't even notice.

Detecting "Steal Time": Is Your Host Oversold?

If you suspect your current provider is squeezing too many users onto one physical server, check the CPU Steal Time. This metric tells you how long your virtual CPU waits for the physical hypervisor to give it attention.

Run top in your terminal and look for the %st value:

top - 14:23:45 up 15 days,  2:30,  1 user,  load average: 0.85, 0.90, 0.88
Tasks: 110 total,   1 running, 109 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.5%us,  3.2%sy,  0.0%ni, 80.0%id,  0.2%wa,  0.0%hi,  0.1%si,  4.0%st
Mem:   2055480k total,  1890200k used,   165280k free,   120400k buffers
Swap:  1048572k total,      140k used,  1048432k free,   980500k cached

See that 4.0%st? That means 4% of your CPU cycles are being stolen by the host. On a quality KVM node, this should be near 0.0%.

Tuning KVM for SSD Performance

Spinning hard drives (HDDs) are the bottleneck of the modern web. This year, we have seen a massive shift towards Solid State Drives (SSDs) in the enterprise. However, simply paying for SSD hosting isn't enough; you need to tell your Linux kernel how to treat this storage.

By default, CentOS 6 often defaults to the cfq (Completely Fair Queuing) scheduler, which is optimized for spinning platters and seek times. On an SSD, this actually slows you down. You want to switch to the deadline or noop scheduler to reduce latency.

Step 1: Check your current scheduler:

cat /sys/block/sda/queue/scheduler
# Output might be: [cfq] deadline noop

Step 2: Change it to deadline (immediate) and make it persistent:

# Immediate change
echo deadline > /sys/block/sda/queue/scheduler

# Permanent change: Edit /boot/grub/grub.conf
# Add 'elevator=deadline' to your kernel line:
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=no rd_NO_LVM rd_NO_DM elevator=deadline
Pro Tip: Also add the noatime flag to your /etc/fstab file. By default, Linux writes a timestamp every time a file is read. On a high-traffic web server, this generates thousands of unnecessary write operations per second. Changing this to noatime can improve I/O throughput by 10-15%.

Optimizing MySQL 5.5 on KVM

With the dedicated RAM allocation you get on CoolVDS KVM instances, you can safely tune InnoDB without fear of the OOM killer striking randomly (a common nightmare on OpenVZ). The most critical setting in 2012 for MySQL performance is the innodb_buffer_pool_size.

If you have a 4GB VPS dedicated to the database, do not leave this at the default 8MB. Set it to utilize 70-80% of your RAM.

[mysqld]
# /etc/my.cnf optimization for a 4GB KVM instance
innodb_buffer_pool_size = 2G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
query_cache_type = 1
query_cache_limit = 2M
query_cache_size = 64M

Note: Setting innodb_flush_log_at_trx_commit = 2 provides a massive speed boost by flushing logs to the OS cache rather than the disk on every commit. You risk losing 1 second of transactions in a power failure, but on our stable infrastructure, the performance gain is worth it.

The Norwegian Advantage: Latency and Datatilsynet

For developers targeting the Nordic market, physics is the ultimate constraint. Hosting your application in Germany or the US when your users are in Oslo adds unavoidable latency. A packet round-trip from Oslo to Frankfurt is ~25-30ms. From Oslo to a local datacenter? <3ms.

Furthermore, we must navigate the legal landscape. The Norwegian Personal Data Act (Personopplysningsloven) and the EU Data Protection Directive (95/46/EC) place strict requirements on how personal data is handled. While the "Safe Harbor" framework exists for US transfers, many Norwegian businesses prefer the legal certainty of keeping data on Norwegian soil, under the oversight of Datatilsynet.

At CoolVDS, our servers are physically located in Oslo. This ensures two things:

  • Blazing fast connectivity via NIX (Norwegian Internet Exchange).
  • Full compliance with local data retention laws, ensuring your client data never leaves the legal jurisdiction inappropriately.

Conclusion: Demand Dedicated Resources

In 2012, "Cloud" is the buzzword, but "Isolation" is the reality you need. Don't let your application suffer because your hosting provider is overselling resources on a shared kernel. KVM provides the stability of a dedicated server with the flexibility of virtualization.

If you are ready to stop fighting with "steal time" and start deploying on true hardware virtualization with enterprise-grade SSDs, it is time to switch.

Deploy a high-performance CentOS 6 KVM instance on CoolVDS today and experience the difference of true isolation.