Magento Performance Optimized Server

Published on Author gryzli

I’ve read some articles on magento performance tuning and server optimization for best result. Here I will try to summarize most of the important stuff I’ve read.


Server Software

Magento best practices advice on using the following configuration:

Nginx + MySQL + php-fpm (FastCGI) + APC / OpCache + (Varnish)

It’s better to use as recent as possible versions of MySQL and PHP.


MySQL configuration tunning

The following my.cnf content is suggested here:



# This option is good to be minimum "8", no matter how many
# cpus you have
innodb_thread_concurrency = 2 * [numberofCPUs] + 2
# ______________

innodb_flush_log_at_trx_commit = 2
thread_concurrency = [number of CPUs] * 3
thread_cache_size = 32

# If you are using DB dedicated server ,this could be set to 80% of your available memory
# Keep in mind, that Magento is using InnoDB as a default storage engine, so increasing innodb_buffer_pool_size must bring to big performance gains
innodb_buffer_pool_size = 4G
# ________________

table_cache = 1024

# If you have some more memory available, query_cache_size could be increased more
# I suggest you to not go over 512MB for query_cache_size, or there's a chance to get some performance degradation
query_cache_size = 64M
query_cache_limit = 2M
join_buffer_size = 8M
tmp_table_size = 256M
key_buffer = 32M
max_allowed_packet = 16M
max_heap_table_size = 256M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1


NGINX Server optimization

Below are some configuration snippets, which must bring to performance gains when using Nginx.



events {
        worker_connections  1024;
        use epoll;
        multi_accept on;


   sendfile on;
   tcp_nopush on;
   tcp_nodelay on;
   send_timeout 180s;

   gzip on;
   gzip_comp_level 2;
   gzip_proxied any;
   gzip_types      text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;




location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
    expires max;
    access_log off;


Magento CMS Configuration

There are some steps we can take inside the Magento itself in order to bring better performance to our magento optimized store.

Full Page Cache

Full page cache gives Magento the ability to cache the whole page and store it in form of (X)HTML. Only CMS, Category and Product View support Full Page cache.

Enabling Full Page cache inside Magento (or through plugin) could lead to very high performance gains:

– up to 10x performance gain on CMS Page

– up to 100% performance gain on Shopping Scenario

– up to 10x performance gain on Browsing Scenario


System Caching

The default system caching method is by using files on disk. Changing this method to APC or Memcache could result in some performance gains also.

This setting can be modified in: app/etc/local.xml config file


Session Handling

The default session storage for storing client sessions is disk storage.  If you want to achieve better performance, you can configure Magento to store it’s sessions in Memcached . 

Keep in mind, that when using just a single server, the performance benefits of using Memcached as a session storage are almost none.


Rebuilding Indexes

The time for index rebuilding must be chosen carefully and configured to happen during least loaded times.


Using Solr as a Search Engine

Since v1.8, Magento Enterprise Edition supports Apache Solr search engine and provides a module called: “Enterprise Search“, which could be configured to use Solr instead of MySQL Full text search.