Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Performance tuning

462 bytes added, 08:42, 26 December 2015
Marked this version for translation
<translate><!--T:1-->This page describes how to improve the performance of an OpenVZ system.
== HW node environment tuning == <!--T:2-->
=== Disable unnecessary services === <!--T:3-->
<!--T:4-->
Disable all default services that you do not need to use and then reboot your host.
<!--T:5-->
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!
<!--T:6-->
To setup default services, use <code>chkconfig</code> or <code>ntsysv</code> in RedHat, or <code>rc-update</code> in Gentoo, <code>update-rc.d</code> on Debian
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 === <!--T:7-->
<!--T:8-->
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>.
<!--T:9-->
To see current settings, type
<!--T:10--># locale
<!--T:11-->
If you want to change it only for the current shell session, do:
<!--T:12--># export LANG=C
<!--T:13-->
If you want to change the default value, modify the <code>/etc/sysconfig/i18n</code> file.
<!--T:14-->
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>.
= Virtual Environment = Container tuning == <!--T:15-->
=== CPU distribution inside VE container on SMP hosts === <!--T:16-->
* <!--T:17-->If the total number of VE's containers in your host is more than CPUs number, and there are many '''threads''' running inside each VE container it is better to give just a single VCPU to each VEcontainer.
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>!
<!--T:18-->To set the number of CPUs available inside VE a container, use:
<!--T:19--># vzctl set $VEID CTID --cpus N
=== Network checksumming === <!--T:20-->
<!--T:21-->
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).
<!--T:22-->
To check current offload setting for the hardware ethernet card (eth0, for instance) type
<!--T:23--># ethtool -k eth0
Make sure that tx/rx features are switched on.
<!--T:24-->
To see current offload settings for the venet0 device, type
# ethtool <!--T:25--k venet0 To set offload settings off for the venet0 device, type>  # ethtool -K k venet0 tx on sg on
<!--T:26-->
To set offload settings on for the venet0 device, type
<!--T:27--># ethtool -K venet0 tx off on sg offon
<!--T:28-->Note, that 'tx on/off' enables/disables both tx and rx checksumming features for the all venet devices for all VEs containers and HN.
<!--T:29-->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 VEcontainer.
=== Shell scripts performance improvement === <!--T:30-->
<!--T:31-->
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.
Please note<!--T:32-->The second important thing is the locale cache. On <code>rpm</code> based distributions, that on VE creation usually it is created by the default <code>LANGglibc-common-XXX.rpm</code> value will post install script and it can be the same as in the HW nodeup to 50 MBytes on some distributions. So on some container templates it can be missed to save disk space. But you can tune always create it in node inside container later by the following command (see [[#Shell scripts performance improvement]] aboveyou must be the root user), or set it in VE the same way.:
<!--T:33-->
# build-locale-archive
The second important thing is the locale cache. On <code!--T:34-->rpmAnd again, in some cases shell (bash) startup time can be reduced up to ~</codefont color=red> based distributions, usually it is created by the 15%<code/font>glibc-common-XXX.rpm</codetranslate> 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 ~<font color=red>15%</font>.[[Category: HOWTO]][[Category: Troubleshooting]]