Performance Optimization

TL;DR; Use EasyEngine. It handles most of this out of the box and provide easy commands for remaining stuff.

For a WordPress site, there are many areas where performance can be improved.

A typical WordPress site setup consists of:

  1. Web Server e.g. Nginx, Apache, IIS
  2. PHP interpreter e.g. CGI, FastCGI, PHP-FPM, HHVM
  3. MySQL e.g. oracle-mysql, percona-mysql, mariadb

Some sites uses an accelerator like Varnish in front of web-server. Varnish could be fine for Apache, but don’t recommend using Varnish with Nginx.

In terms of audience, we need to optimize site for 2 types of users:

  1. Non-logged in users
  2. Logged in users (including admin users)

Non-logged in users can benefit a lot from web-server tweaking alone.

ADVERTISEMENT

For logged in users, you need to focus on PHP and MySQL.

Web Server

Checklist

  1. Use Nginx as your web-server. If you are new to Nginx, try EasyEngine. EasyEngine makes managing WordPress sites easy with Nginx web-server.
  2. Use CDN for static assets e.g. images, css and JS files
  3. Combine CSS and JS files and if possible minify them. Try doing this via pagespeed. If that is not possible, use W3 Total Cache for this. Be very careful with this step as it can break your themes and plugins.
  4. Optimize image sizes with lossless image compression. You can do this either using pagespeed or a WordPress plugin like smush.it.
  5. Protect wp-login.php from bruteforce attack at nginx (web-server) level. A strong password can save you from getting hacked, but bruteforce login attacks create unnecessary PHP-MySQL load.
  6. If you are using SSL, use it for complete site. Avoid using SSL for parts of your site. SSL can be tweaked as well.

Tools

You can use gtmetrix.com and/or webpagetest.org.

Try to score as many “A” as possible.

More: Check Nginx tutorials section

PHP

Checklist

  1. We recommend using nginx with HHVM with PHP-FPM fallback.
  2. If HHVM doesn’t work with your plugins and themes, then Nginx with PHP-FPM is best.
  3. When it comes to PHP, always use latest PHP version, even though WordPress supports outdated PHP versions (which exposes WordPress sites to security risks)
  4. Always use Zend Opcache for opcode caching.
  5. Move session storage to tmpfs or memcache
  6. Use memcache for object-cache. You can do it using W3 Total Cache plugin.
  7. Analyze PHP code performance using xdebug and webgrind.

If you find checklist long, try last one only.

Many WordPress plugins are coded by amateurs and if you are unlucky, you will be using a poor coded plugin. Xdebug profiling can help you find it.

ADVERTISEMENT

If you are using EasyEngine, you will get most of above out of the box.

For xdebug profiling, you can run command:

ee debug example.com --php

More: Check PHP tutorials section

MySQL

Checklist

  1. Use latest MySQL version. Though WordPress will work with older version, new mysql versions has better performance.
  2. Periodically tweak mysql configuration, using scripts like tuning-primer and mysqltuner
  3. Enable slow query log and analyze it with anemometer. This is highly recommended if you are seeing site slowed down for non-logged in users.
  4. Profile mysql query to check internal execution.
  5. Convert MyISAM tables to InnoDB tables. If you have plugins which relies on custom post type, this is must.
  6. Use tmpfs for mysql temporary tables.
  7. Add mysql indexes if possible to speed up queries. Many plugin developers don’t take efforts to add proper mysql indexes for MySQL tables there plugin creates.

More: Check MySQL tutorials section

Web Hosting

Never use shared hosting. If your site is small, you won’t be reading this article. As you are reading this, it means your site is big and need to tweaked. Most of stuff here won’t work on shared hosting.

WordPress specific hostings e.g. WP-Engine makes few things easier but they won’t give you full control.

We recommend VPS with SSD hosting. DigitalOcean and Linode are our favorites!

Notes

Of course, after all of above, your site may still be slow. Chances are high that you missed something from above list.

Unfortunately it’s not possible to solve performance problem for any site over our community support forum or skype/email exchanges. rtCamp can only help if it gets first-hand access to the server! You may contact us if for professional support in that case.

Links: EasyEngine