Article ID: 112441, created on Oct 4, 2011, last review on May 10, 2014

  • Applies to:
  • Virtuozzo containers for Linux 4.7
  • Virtuozzo containers for Linux 4.6
  • Virtuozzo containers for Linux 4.0
  • Virtuozzo for Linux 3.x

Information

This article describes how to optimize default Apache settings on Debian-based containers to have better performance and higher density using a 256MB container memory limit.

NOTE: This article is an example of Apache tuning. You may need to use your own Apache settings according to your own needs.

The easiest way to create containers with pre-defined Apache limits is to modify the template post-install script:
  1. Edit /vz/template/debian/${VER}/${ARCH}/config/os/default/post-install to contain this section:
    #--------------
    # apache tuning
    CFG_FILE=etc/apache2/apache2.conf
    if [ -f $CFG_FILE ]; then
        sed -e "s/^[[:blank:]]*StartServers[[:blank:]]*.*/StartServers       1/" \
            -e "s/^[[:blank:]]*MinSpareServers[[:blank:]]*.*/MinSpareServers    1/" \
            -e "s/^[[:blank:]]*MaxSpareServers[[:blank:]]*.*/MaxSpareServers    5/" \
            -e "s/^[[:blank:]]*ServerLimit[[:blank:]]*.*/ServerLimit       10/" \
            -e "s/^[[:blank:]]*MaxClients[[:blank:]]*.*/MaxClients        10/" \
            -e "s/^[[:blank:]]*MinSpareThreads[[:blank:]]*.*/MinSpareThreads    1/" \
            -e "s/^[[:blank:]]*MaxSpareThreads[[:blank:]]*.*/MaxSpareThreads    4/" \
            $CFG_FILE > ${CFG_FILE}.$$ && \
                    move_file ${CFG_FILE}.$$ $CFG_FILE > /dev/null 2>&1
    fi
    #--------------
  2. Re-create the OS template cache:
    vzpkg create cache debian-${VER}-${ARCH} -f

All newly created containers based on the Debian ${VER} ${ARCH} template will have these Apache limits.

Another way to fine-tune the container is to create a custom EZ template which would consist only of a post-install script, which adjusts Apache limits according to your needs.

Also, it is possible to create several application templates representing various load scales for flexible containers provisioning, e.g. apache-tuning-basic, apache-tuning-moderate, apache-tuning-high, and apache-tuning-extreme.

IMPORTANT: It is also necessary to adjust the memory, number of files, and network socket limits according to the server load.

An approximate resource allocation schema is presented in this table:
  Container limits Apache limits
Name Memory, MB # Files # Sockets StartServers MinSpareServers MaxSpareServers ServerLimit MaxClients MinSpareThreads MaxSpareThreads Timeout
Basic 256 2048 1024 1 1 3 10 10 1 4 20
Moderate 512 4096 2048 2 2 5 50 50 1 4 20
High 1024 8192 4096 2 2 5 100 100 1 4 20
Extreme 2048 16384 8192 2 2 5 150 150 1 4 20

0c05f0c76fec3dd785e9feafce1099a9 d02f9caf3e11b191a38179103495106f e8e50b42231236b82df27684e7ec0beb 9b9439294978ca011521bd467a069524 36627b12981f68a16405a79233409a5e 35c16f1fded8e42577cb3df16429c57a 2897d76d56d2010f4e3a28f864d69223

Email subscription for changes to this article
Save as PDF