This section discusses the various ways of optimizing your server configuration for Magento to deal with large product sets and regular updates from our plug-in. It also includes general best practice.
======== Database configuration ========
The following settings for the ”’my.cnf”’ MySQL configuration file are suitable for a server with 2GB RAM and have been tested with 150,000 products. If you have more RAM, you should look to increase the size of the ”’innodb_buffer_pool_size”’ to increase performance.
key_buffer = 384M
max_allowed_packet = 16M
table_cache = 1024
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 16
query_cache_type = 1
query_cache_size = 64M
tmp_table_size = 64M
max_heap_table_size = 64M
innodb_buffer_pool_size = 1408M
innodb_additional_mem_pool_size = 20M
Ensure you have the following settings in ”’php.ini”’. You may wish to try increasing memory_limit if you get errors regarding PHP running out of memory
Memory_limit = 512M
======== Magento Configuration ========
System > Cache Management > Select All > Enable
This one is an absolute no-brainer and provides one of the best performance enhancements you will get in Magento. This caches the XML layer in Magento, along with some other information, to speed up PHP processing time.
System > Tools > Compilation > Run Compilation Process
This option compiles all Magento installation files and creates a single include path. ”’Remember to disable this module before upgrades”’. The compilation process may need to be run again when new files are released.
System > Configuration > Advanced > Developer > Log Settings > Enabled: No
This is disabled by default, but be sure to double-check it is disabled on production environments, as this setting can drastically slow down your website if enabled.
Enable Flat Catalog/Index
System > Index Management > Enable All
System > Configuration > Catalog > Frontend, set Use Flat Catalog Category/Product to Yes
If you have a large amount of products on your site (>10,000), this update decreases load times on searches, product listings, etc.
Install the Fooman Speedster module – http://www.magentocommerce.com/magento-connect/fooman-speedster.html
After installing this extension via Magento Connect make sure that /lib/minify/m.php is executable (permissions like 755 on the file itself and the containing folder should work) and /var/minifycache is writeable.
Magento creates a lot of logs which can slow performance. You should set up a scheduled task to regularly clean the logs. There are two types which must be culled: files and database entries.
The following commands will delete the files that need to be deleted
php -f downloader/mage.php clear-cache
rm -rf downloader/pearlib/cache/*
rm -rf downloader/pearlib/download/*
rm -rf var/cache/*
rm -rf var/session/*
rm -rf var/report/*
rm -rf var/tmp/*
To clean the database, the shell utility log.php can be configured as a cron job or run manually to clean on-the-fly.
From the Magento root directory, type:
php -f shell/log.php clean
the –days switch can be used to specify how many days back to save.
== Server Configuration ==
Nginx is significantly faster than Apache. We have tested our plug-in with it and it works fine
This is a must-have tweak. It decreases page size by over 30%. Make sure to enable the deflate module in your Apache configuration, then comment out the appropriate lines in the mod_deflate.c directive of your ~/.htaccess file.
Many instances of Linux will have this enabled by default
# Insert filter on all content
# Insert filter on selected content types only
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0 no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
Install APC with the command line pecl install apc
Also add the following cache handle to your app/etc/local.xml configuration
This should result in an increase of around 30% in page load speed
Add the following lines to your Apache configuration file
Apache KeepAlive keeps the TCP connection open between the client and the server, allowing multiple requests to be served over the same connection. This removes some overhead with sites serving up a lot of concurrent HTTP requests. Make sure you have plenty of memory if you do this as each connection consumes resources.
Add the following line to your Apache configuration file
The open_basedir parameter is a security feature that restricts filesystem lookups, but can hurt performance on applications with a large filesystem footprint like Magento.