Editing Performance tuning

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
 
<translate>
 
<translate>
<!--T:1-->
 
 
This page describes how to improve the performance of an OpenVZ system.
 
This page describes how to improve the performance of an OpenVZ system.
  
== HW node environment tuning == <!--T:2-->
+
== HW node environment tuning ==
  
=== Disable unnecessary services === <!--T:3-->
+
=== Disable unnecessary services ===
  
<!--T:4-->
 
 
Disable all default services that you do not need to use and then reboot your host.  
 
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!
 
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.d</code> on Debian
  
=== Shell scripts performance improvement === <!--T:7-->
+
=== Shell scripts performance improvement ===
  
<!--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>.
 
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  
 
To see current settings, type  
  
   <!--T:10-->
+
   # locale
# locale
 
  
<!--T:11-->
 
 
If you want to change it only for the current shell session, do:
 
If you want to change it only for the current shell session, do:
  
  <!--T:12-->
+
  # export LANG=C
# export LANG=C
 
  
<!--T:13-->
 
 
If you want to change the default value, modify the <code>/etc/sysconfig/i18n</code> file.
 
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>.   
 
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 == <!--T:15-->
+
== Container tuning ==
  
=== CPU distribution inside container on SMP hosts === <!--T:16-->
+
=== CPU distribution inside container on SMP hosts ===
  
<!--T:17-->
 
 
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.
 
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>!
 
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 a container, use:
 
To set the number of CPUs available inside a container, use:
  
  <!--T:19-->
+
  # vzctl set $CTID --cpus N
# vzctl set $CTID --cpus N
 
  
=== Network checksumming === <!--T:20-->
+
=== Network checksumming ===
  
<!--T:21-->
 
 
RHEL 5 based kernel supports IP checksum offload.
 
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).
 
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
 
To check current offload setting for the hardware ethernet card (eth0, for instance) type
  
   <!--T:23-->
+
   # ethtool -k eth0
# ethtool -k eth0
 
 
   
 
   
 
Make sure that tx/rx features are switched on.
 
Make sure that tx/rx features are switched on.
  
<!--T:24-->
 
 
To see current offload settings for the venet0 device, type
 
To see current offload settings for the venet0 device, type
  
   <!--T:25-->
+
   # ethtool -k venet0
# ethtool -k venet0
 
  
<!--T:26-->
 
 
To set offload settings on for the venet0 device, type
 
To set offload settings on for the venet0 device, type
  
   <!--T:27-->
+
   # ethtool -K venet0 tx on sg on
# ethtool -K venet0 tx on sg on
 
  
<!--T:28-->
 
 
Note, that 'tx on/off' enables/disables both tx and rx checksumming features for the all venet devices for all containers and HN.
 
Note, that 'tx on/off' enables/disables both tx and rx checksumming features for the all venet devices for all 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 container.
 
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 === <!--T:30-->
+
=== Shell scripts performance improvement ===
  
<!--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, 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.
  
<!--T:32-->
 
 
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):   
 
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):   
  
  <!--T:33-->
+
  # build-locale-archive
# build-locale-archive
 
  
<!--T:34-->
 
 
And again, in some cases shell (bash) startup time can be reduced up to ~<font color=red>15%</font>.
 
And again, in some cases shell (bash) startup time can be reduced up to ~<font color=red>15%</font>.
 
</translate>
 
</translate>

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)