Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Performance tuning

60 bytes added, 19:29, 9 September 2008
double empty lines slashed; no level1 headings; categorized
This page describes how to improve the performance of an 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 <code>audit</code> daemon can significantly decrease performance of linux kernel system calls (up to ~<font color=red>20%</font>) 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 <code>chkconfig</code> or <code>ntsysv</code> in RedHat, or <code>rc-update</code> in Gentoo, <code>update-rc.dv</code> 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 [http://www.tux.org/pub/tux/niemi/unixbench/ unixbench] package), you can set your <code>LANG</code> environment variable to <code>"C"</code>.
 
To see current settings, type
If you want to change the default value, modify the <code>/etc/sysconfig/i18n</code> file.
 
If your default <code>LANG</code> environment variable was set to something like <code>en_US.UTF-8</code>, you can reduce shell (bash) startup time up to ~<font color=red>15%</font> with <code>LANG=C</code>.
== Container tuning ==
=== CPU distribution inside container on SMP hosts ===
* If the total number of containers in your host is more than CPUs number, and there are many '''threads''' running inside each container it is better to give just a single VCPU to each container.
In this case thread memory locality will significantly reduce overhead on SMP memory coherence and overall performance can be increased up to ~<font color=red>50-100%</font>!
To set the number of CPUs available inside a container , use:
# vzctl set $CTID --cpus N
=== Network checksumming ===
RHEL 5 based kernel supports IP checksum offload.
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 container.
=== Shell scripts performance improvement ===
Please note, that on container creation the default <code>LANG</code> 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 container the same way.
 
The second important thing is the locale cache. On <code>rpm</code> based distributions, usually it is created by the <code>glibc-common-XXX.rpm</code> post install script and it can be up to 50 MBytes on some distributions. So on some container templates it can be missed to save disk space. But you can always create it inside container later by the following command (you must be the root user):
And again, in some cases shell (bash) startup time can be reduced up to ~<font color=red>15%</font>.
 
[[Category: HOWTO]]
[[Category: Troubleshooting]]