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:
- Web Server e.g. Nginx, Apache, IIS
- PHP interpreter e.g. CGI, FastCGI, PHP-FPM, HHVM
- 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:
- Non-logged in users
- Logged in users (including admin users)
Non-logged in users can benefit a lot from web-server tweaking alone.
For logged in users, you need to focus on PHP and MySQL.
- Use Nginx as your web-server. If you are new to Nginx, try EasyEngine. EasyEngine makes managing WordPress sites easy with Nginx web-server.
- Use CDN for static assets e.g. images, css and JS files
- 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.
- Optimize image sizes with lossless image compression. You can do this either using pagespeed or a WordPress plugin like smush.it.
- 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.
- If you are using SSL, use it for complete site. Avoid using SSL for parts of your site. SSL can be tweaked as well.
Try to score as many “A” as possible.
- We recommend using nginx with HHVM with PHP-FPM fallback.
- If HHVM doesn’t work with your plugins and themes, then Nginx with PHP-FPM is best.
- When it comes to PHP, always use latest PHP version, even though WordPress supports outdated PHP versions (which exposes WordPress sites to security risks)
- Always use Zend Opcache for opcode caching.
- Move session storage to tmpfs or memcache
- Use memcache for object-cache. You can do it using W3 Total Cache plugin.
- 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.
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
- Use latest MySQL version. Though WordPress will work with older version, new mysql versions has better performance.
- Periodically tweak mysql configuration, using scripts like tuning-primer and mysqltuner
- 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.
- Profile mysql query to check internal execution.
- Convert MyISAM tables to InnoDB tables. If you have plugins which relies on custom post type, this is must.
- Use tmpfs for mysql temporary tables.
- 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.
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.
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.