Performance tuning

From OpenVZ Virtuozzo Containers Wiki
Revision as of 09:42, 11 March 2008 by Botinki Kira (talk | contribs) (Robot: Automated text replacement (-VEID +CTID))
Jump to: navigation, search

This page describes how to improve performance of OpenVZ system.

HW node environment tuning

Disable unnecessary services

Disable all default services that you do not need to use and then reboot your host.


For example, the audit daemon can significantly decrease performance of linux kernel system calls (up to ~20%) even if you do not use any audit rules, or even if you just stopped this service without host reboot!


To setup default services, use chkconfig or ntsysv in RedHat, or rc-update in Gentoo, update-rc.dv on Debian

Shell scripts performance improvement

To improve performance of small shell scripts, which spends a lot of time starting the shell binary itself (like the shell scripts test from the unixbench package), you can set your LANG environment variable to "C".


To see current settings, type

 # locale

If you want to change it only for the current shell session, do:

# export LANG=C

If you want to change the default value, modify the /etc/sysconfig/i18n file.


If your default LANG environment variable was set to something like en_US.UTF-8, you can reduce shell (bash) startup time up to ~15% with LANG=C.

Virtual Environment tuning

CPU distribution inside VE on SMP hosts

  • If the total number of VE's in your host is more than CPUs number, and there are many threads running inside each VE it is better to give just a single VCPU to each VE.

In this case thread memory locality will significantly reduce overhead on SMP memory coherence and overall performance can be increased up to ~50-100%!

To set the number of CPUs available inside VE use:

# vzctl set $CTID --cpus N

Network checksumming

RHEL 5 based kernel supports IP checksum offload. If network ethernet cards in your host support IP checksum offload then you can switch this feature on also for the virtual network devices (venet, veth).

To check current offload setting for the hardware ethernet card (eth0, for instance) type

 # ethtool -k eth0

Make sure that tx/rx features are switched on.

To see current offload settings for the venet0 device, type

 # ethtool -k venet0

To set offload settings on for the venet0 device, type

 # ethtool -K venet0 tx on sg on

Note, that 'tx on/off' enables/disables both tx and rx checksumming features for the all venet devices for all VEs and HN.

The same applies to the veth device except that 'tx on/off' enables/disables tx and rx checksumming features for only given virtual ethernet device in HN and corresponding VE.

Shell scripts performance improvement

Please note, that on VE creation the default LANG value will be the same as in the HW node. So you can tune it in node (see #Shell scripts performance improvement above), or set it in VE the same way.


The second important thing is the locale cache. On rpm based distributions, usually it is created by the glibc-common-XXX.rpm post install script and it can be up to 50 MBytes on some distributions. So on some VE templates it can be missed to save disk space. But you can always create it inside VE later by the following command (you must be the root user):

# build-locale-archive

And again, in some cases shell (bash) startup time can be reduced up to ~15%.