Optimizing Magento on VMware vSphere

| Linux, Pantek, Vmware

Magento is a high performance, scalable eCommerce solution used by more than 240,000 merchants worldwide.

Website speed and performance is critical with all eCommerce websites, however Magento’s flexibility can sometimes yield slow page speeds when not optimized. This technical blog contains several suggestions for optimizing Magento’s performance when running on Linux with VMware vSphere ESXi hosts. The intended audience for this blog is for advanced Linux and VMware administrators.

This is not intended to be comprehensive, and assumes an existing implementation of Magento, Apache, Linux, MySQL, and VMware ESXi.

Tested Environment

These configurations were tested on the following platforms:

  • Magento Community Edition (CE) v
  • Apache HTTP Server 2.2
  • MySQL Server 5.5
  • CentOS Linux 6.7
  • VMware vSphere: ESXi 5.5, 5.1 and 5.0

Basic Linux OS Optimization

First, ensure your Linux install has been optimized. Here are several suggestions:

  1. Disable all unnecessary system services which may consume resources. Using cups as an example:
    service cups stop ; chkconfig cups off
  2. Remount file system partitions with “noatime,nodiratime” options. Using the / partition as an example:
    mount -o remount,noatime,nodiratime /
  3. Ensure file system partitions boot with these options on future boots:
    Modify /etc/fstab and add "noatime,nodiratime" to the options on the partition Magento uses
  4. Tweak sysctl settings:
    sysctl net.ipv4.tcp_tw_reuse=1
    sysctl vm.swappiness=10
    echo 10 > /proc/sys/vm/swappiness
    echo "net.ipv4.tcp_tw_reuse=1" >> /etc/sysctl.conf
    echo "vm.swappiness=10" >> /etc/sysctl.conf

Apache and PHP Optimization

Next, focus on your Apache and PHP optimizations. Here are several suggestions:

  1. Enable KeepAlive in the Apache configuration file httpd.conf and restart Apache
  2. Disable all Apache modules which are not needed in httpd.conf and restart Apache
  3. Move Magento’s .htaccess file into a VirtualHost container configuration
  4. Ensure PHP version 5.5 or above is installed and configured
  5. Consider installing and configuring PHP-FPM for enhanced performance
  6. Install and enable PHP Opcache. For example using PHP 5.5:
    yum install php55w-opcache
    Change two settings in /etc/php.d/opcache.ini: 
  7. Adjust PHP Opcache settings as necessary in opcache.ini. Opcache.memory_consumption should be lower than the php memory_limit set in /etc/php.ini and/or the Magento .htaccess file. For example:
  8. Adjust additional PHP settings in php.ini as necessary. Set memory_limit to at least 1024M but lower than the servers total memory capacity. For example:
    memory_limit 1024M
    zlib.output_compression on

Basic Magento Optimization

  1. Disable all Magento modules that are not actively being used
  2. When possible, use the Magento Compiler module
  3. Enable Flat Catalogue to merge product data into one table:
    From the Magento administrator interface, go to System > Configuration > Catalogue.
    Under Frontend, change Use Flat Catalogue Category to YES.
    Clear the cache.
  4. Optimize the Magento .htaccess file. For example, enable these settings:
    php_flag php_value memory_limit 1024M
    php_flag zlib.output_compression on
  5. Install and enable Memcached:
    yum install memcached libmemcached10 libmemcached10-devel php-pecl-memcached cyrus-sasl-devel
    service memcached start
    chkconfig --levels 2345 memcached on
    Add the below to app/etc/local.xml right before closing
     <!-- apc / memcached / empty=file -->
     <!-- memcached cache backend related config -->
     <!-- any number of server nodes can be included -->
  6. Consider Redis as an alternative to Memcached.

VMware ESXi Optimization

  1. Ensure Vmware Tools is installed and running on the Linux guest
  2. Increase CPU and Memory Reservations to maximum possible
    Open Virtual Machine Properties for VM
    Click Resources, then CPU 
    Increase Reservation to at least 1000MHz
    Increase Limit to maximum possible in your environment
    Change Shares from Normal to High
    Click Memory 
    Increase Reservation to at least 2048MB 
    Increase Limit to Unlimited 
    Change Shares from Normal to High
  • Use Paravirtual SCSI Controller Driver
    If running, shutdown VM
    Open Virtual Machine Properties for VM
    Click SCSI Controller 0
    Click Change Type
    Select VMware Paravirtual
    Click OK
    Power on VM

The above suggestions represent the most common changes necessary to optimize Magento on VMware ESXi. However, there are many other considerations and variations possible as well. The above settings must be adjusted and tuned for your specific environment to ensure maximum performance.

This information was sourced from several articles including:



Comments are closed.