(gs):Optimize WordPress caching
- This page was last modified on February 7, 2011, at 15:20.
From (mt) Community Wiki
Contents |
This article is part of a series which provides general information on optimizing your WordPress blog for the (gs) Grid-Service.
(mt) Media Temple does not support third-party software. For more information on WordPress, please visit http://wordpress.org.
Bird's eye view of WordPress
WordPress is a popular blogging application. The main components are a MySQL database and a series of PHP files. Each time a page is displayed, a query to the database is made. This is sent to your browser which parses the data and renders that page.
This works well when your traffic is moderate or when your blog does not need to query the database frequently. What can you do when your traffic spikes? We recommend using a cache plugin.
Caching
Cache, pronounced cash, is the transparent storage of data for future use. This improves your WordPress blog performance so that when a visitor views your blog much of the information is now easily retrievable. There are a few plugins that we recommend and some that we don't.
Plugins
Plugins are used to extend the functions of WordPress. Many are written efficiently and use server resources sparingly; while others are written by someone that is learning or not as proficient in PHP.
Plugins can be downloaded from the programmer's site, the WordPress plugin directory or within your WordPress Dashboard.
Due to the way some plugins operate, they do not work well with caching plugins and will in fact cancel out their benefits. Be wary of plugins that dynamically change the appearance of WordPress on every page view.
Tested caching plugins
- W3 Total Cache, http://wordpress.org/extend/plugins/w3-total-cache/
- Quick Cache, http://wordpress.org/extend/plugins/quick-cache/
- Hyper Cache, http://wordpress.org/extend/plugins/hyper-cache/
- cos-html-cache, http://wordpress.org/extend/plugins/cos-html-cache/
- Really Static, http://wordpress.org/extend/plugins/really-static/
- WP Super Cache, http://wordpress.org/extend/plugins/wp-super-cache/
Our process
Metrics used
- Hits
- Posts
- Home page/Post page
- File lock
- GPU usage
Here's what we did:
- Reviewed each plugin and identify best settings.
- Tested each plugin individually.
- Reviewed GPU usage 24-hours later.
We ran an Apache benchmark test. Here's a sample of the code:
ab -n [number of requests] -c [number of concurrent requests to make] http://example.com/
Our results & recommendations
We found that each of the plugins worked well with the exception of cos-html-cache. This plugin caused an increase in the GPU usage and had some file locking. While it may be possible to edit the code of this plugin to work on the Grid, we did not edit any code for the purpose of this test. For more information about GPUs, please see these articles:
File locking is essentially a mechanism to prevent data from being mis-communicated to different 'processes' on a machine. This is bad because the number of locks can accumulate over time. This will cause problems for future processes if the process doesn't clean up after itself.
All plugins were used with the default settings; no code was edited.
For WP Super Cache, we recommend not checking the option for "Coarse file locking."
This type of caching is not compatible with the Network File System (NFS) that is used for data storage on the (gs) Grid-Service and may cause serious complications for the shared storage segment on which your data resides. In extreme cases, the cache could contribute to a serious interruption of system services for both you and other customers on the same shared disk.