Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Performance tuning

1,407 bytes added, 08:42, 26 December 2015
Marked this version for translation
<translate><!--T:1-->This page describes how to do correct improve the performance measurements on of an OpenVZ system.
= Test conditions =HW node environment tuning == <!--T:2-->
== kernels with different versions =Disable unnecessary services =* If you want to compare performance of the kernel on different hosts, or measure OpenVZ performance overhead, it's strongly recommended to compare the same kernel version with similar .config file and on the same linux distribution.== <!--T:3-->
* If you compare kernels with different versions, please check <!--T:4-->Disable all .config options default services that are differ, especially _DEBUG_ optionsyou do not need to use and then reboot your host. For example, on unixbench pipe throughput test on 2.6.18 kernel, disabled CONFIG_DEBUG_HIGHMEM option will increase performance up to <font color=red>20%</font>
<!--T:5-->For example, the <code>audit</code> daemon can significantly decrease performance of linux kernel system calls (up to ~<font color== running services ==* Before performing test measurementred>20%</font>) even if you do not use any audit rules, or even if you should disable '''all''' default services in your runlevel and then '''just stopped this service without host reboot''' your host. !
It is not enough to just stop <!--T:6-->To setup default services, because some services, like use <code>chkconfig</code> or <code>auditntsysv</code> will affect performance even if the daemon is already stopped. For some unixbench tests it can be in RedHat, or <font color=redcode>~20%rc-update</fontcode> overhead if in Gentoo, <code>auditdupdate-rc.d</code> was started once on a host before reboot.Debian
On RedHat distributions use === Shell scripts performance improvement === <code>chkconfig</code> or <code>ntsysv</code> utility to disable default services. (<code>rc!--T:7-update</code> in Gentoo, <code>update-rc.dv</code> for Debian)
== filesystem tests ==<!--T:8-->* If you perform filesystem testsTo improve performance of small shell scripts, please keep in mind filesystem typewhich 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), block size, mount options and so onyou can set your <code>LANG</code> environment variable to <code>"C"</code>.
For example<!--T:9-->To see current settings, ext3 filesystem performance highly depends on journal type and mount options.
* Also please always note/report IO <!--T:10-scheduler type. Different IO-schedulers can highly affect your tests results (up to <font color=red>30%</font>). # locale
<!--T:11-->If your kernel support different IO-schedulers, you can get/set want to change it only for the type herecurrent shell session, do:
# cat /sys/block/hda/queue/scheduler noop anticipatory deadline [cfq]<!--T:12--> # echo noop > /sys/block/hda/queue/schedulerexport LANG=C
== network isolation ==<!--T:13-->* You should disable local networkIf you want to change the default value, modify the <code>/internet connection if your tests doesn't require itetc/sysconfig/i18n</code> file.
== CPU distribution inside VE on SMP hosts ==<!--T:14-->* If the number of VE's in your host is more than CPUs number, and there are many tasksdefault <code>LANG</tests running inside each VE, and that tasks are scheduled quite often, it's better code> environment variable was set to give just one CPU for each VEsomething like <code>en_US. In this case the VirtualCPUUTF-scheduler performance overhead can be significantly decreased8</code>, and performance you can increase reduce shell (bash) startup time up to ~<font color=red>10015%</font>!with <code>LANG=C</code>.
To set the number of CPUs available inside VE use== Container tuning == <!--T:15-->
# vzctl set $VEID === CPU distribution inside container on SMP hosts === <!--cpus NT:16-->
== network performance ==<!--T:17-->* please do not use file transferring utilities to test If the network performancetotal number of containers in your host is more than CPUs number, because the bottleneck of these tests and there are many '''threads''' running inside each container it is usually file system 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- not TCP100%</IP stackfont>!
<!--T:18-->To set the number of CPUs available inside a container, use:  <!--T:19--># vzctl set $CTID --cpus N === network 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  <!--T:25--># ethtool -k venet0 <!--T:26-->To set offload settings on for the venet0 device, type  <!--T:27--># 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. <!--T:29-->The same applies to the veth device except that 'TODO''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--> <!--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. <!--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):   <!--T:33--># build-locale-archive <!--T:34-->And again, in some cases shell (bash) startup time can be reduced up to ~<font color=red>15%</font>.</translate> [[Category: HOWTO]][[Category: Troubleshooting]]