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.
These configurations were tested on the following platforms:
- Magento Community Edition (CE) v 188.8.131.52
- 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:
- Disable all unnecessary system services which may consume resources. Using cups as an example:
service cups stop ; chkconfig cups off
- Remount file system partitions with “noatime,nodiratime” options. Using the / partition as an example:
mount -o remount,noatime,nodiratime /
- 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
- 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:
- Enable KeepAlive in the Apache configuration file httpd.conf and restart Apache
- Disable all Apache modules which are not needed in httpd.conf and restart Apache
- Move Magento’s .htaccess file into a VirtualHost container configuration
- Ensure PHP version 5.5 or above is installed and configured
- Consider installing and configuring PHP-FPM for enhanced performance
- Install and enable PHP Opcache. For example using PHP 5.5:
yum install php55w-opcache Change two settings in /etc/php.d/opcache.ini: opcache.enable=1 opcache.enable_cli=1
- 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:
opcache.memory_consumption=512 opcache.interned_strings_buffer=12 opcache.max_accelerated_files=90000
- 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 realpath_cache_size=5M realpath_cache_ttl=12000
Basic Magento Optimization
- Disable all Magento modules that are not actively being used
- When possible, use the Magento Compiler module
- 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.
- Optimize the Magento .htaccess file. For example, enable these settings:
php_flag php_value memory_limit 1024M php_flag zlib.output_compression on realpath_cache_size=5M realpath_cache_ttl=12000
- 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 <cache> <backend> memcached</backend> <!-- apc / memcached / empty=file --> <memcached> <!-- memcached cache backend related config --> <servers> <!-- any number of server nodes can be included --> <server> <host> <![CDATA[127.0.0.1]]> </host> <port> <![CDATA]> </port> <persistent> <![CDATA]> </persistent> </server> </servers> <compression> <![CDATA]> </compression> <cache_dir> <![CDATA]> </cache_dir> <hashed_directory_level> <![CDATA]> </hashed_directory_level> <hashed_directory_umask> <![CDATA]> </hashed_directory_umask> <file_name_prefix> <![CDATA]> </file_name_prefix> </memcached> </cache>
- Consider Redis as an alternative to Memcached.
VMware ESXi Optimization
- Ensure Vmware Tools is installed and running on the Linux guest
- 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.
Pantek offers professional support, development, and hosting for Magento.
This information was sourced from several articles including: