By now you must have gone through tons of optimization tips related to Magento but here I am going to share my personal experience of fighting with Magento and these tweaks really helped me to improve overall Magento performance and good thing is most are also applicable to most of other PHP+Mysql based applications.
I was stuck with performance issues and I tried almost all the common suggestions spread over different sites and forums but I was still not able to achieve and fix some of issues. So what I did?
- Get a faster clock speed per core and latest generation CPU. Believe me no of cores and amount of Memory sound good on paper but they will only help you when you have to handle more no of visitors at given time but if you want to decrease PHP page generation time then only faster clock speed core will help you as normal visitor’s request is handled by only a single core so a faster core can only finish the job in lesser time.
- No one can beat the power of a Physical server so always go for a Dedicated server instead of Cloud or VPS or any type of virtualized server if you can design a reliable Disaster Recovery plan.
- If you have enough computing power on your web server then always go for local Mysql instance as it will provide you better performance compare to remote Mysql server.
- Move Magento ‘cache’, ‘full_page_cache’ and ‘session’ folder on a ‘tmpfs’ based RamDisk. I was having random high IOPS issues and moving them to RAMDisk sorted it.
- If you seeing high percentage of Mysql temporarily tables created on disk despite keep increasing ‘tmp_table_size’ and ‘max_heap_table_size’ values then most probably your application is using much TEXT and BLOB columns so allocating more memory won’t help you and in that case you can try moving Mysql ‘tmpdir’ to a RAMDisk (with caution).
- Play with XFS or EXT4 filesystems and see which work best with your environment.
- Upgrade PHP to 5.5 and use OPcache instead of APC or APCu.
- Upgrade Mysql to 5.6
- In case of Apache move all .htaccess rules to virtual host, you can try with ‘AllowOverride None’ altogether.
- Disable Mysql slow query log and binlog.
- Disable PHP slow_log.
- Disable Magento System and Exception logs as well as Profiler.
- You can also try mounting Mysql ‘data’ directory and ‘/var/www/’ with ‘noatime’ option.
- Prefer using “Unix Socket” for PHP-FPM and Mysql over TCP/IP. Same applies to ‘Redis’ and “Memcached”.
- Create all unix sockets in RAMDisk (tmpfs) instead of disk.
- If you are seeing random 502, 499 errors in nginx (while CPU, Memory, I/O, database etc looks stable) with PHP-FPM “Unix Socket” then switch to TCP/IP or increase listen.backlog, net.core.somaxconn and ulimit values.
- Try newer PHP Mysql driver ‘mysqlnd’ over ‘libmysql’.
- Try PHP memcached driver over memcache
- Setup “Parallel Downloads” for different type of content.
- Setup HTTP/2 or SPDY to improve HTTPS performance.
- Use external Analytics like GA.
- Properly setup robots.txt and block bad bots and private areas of site and define a crawl delay.
- Replace regular Search and Layered Navigation from Solr or Sphinx, I personally using Algolia.
- Setup scheduled “Magento Log Cleaning”.
Obviously along with above suggestion you still need to apply all those tweaks and tips which you already know most.