Fine Tuning Your WordPress Install
- 1 Overview
- 2 Using automatic upgrades
- 3 Spam
- 4 Caching
- 5 FastCGI
- 6 Checking your Plugins
- 7 Image Size
- 8 Widgets
- 9 Database
- 10 Revisions
- 11 Stats Plugins
- 12 XML-RPC
- 13 Missing Files
- 15 Upgrading to DreamPress or a Private Server
- 16 Tools
- 17 See Also
Over time, you may notice that your WordPress site runs slower or doesn't run as well as it should. There are several reasons this could occur, and this wiki walks you through some of the most common issues and provides solutions to help you resolve them.
Using automatic upgrades
Staying on top of both plugins and core WordPress upgrades is the single best thing you can do. Not only will it keep your site less prone to hack attempts, but almost every new version of the software has tweaks that offer speed increases.
You can use either the One-Click Installs page in the panel or log into your WordPress panel to set up automatic upgrades.
To use our One-Click Installs feature in the panel to request upgrade notifications:
- Open your panel at (Panel > ‘Goodies’ > ‘One-Click Installs’)
- Choose your domain.
- Click the edit link under the ‘Upgrade Action’ column.
- Select the Upgrade automatically option.
Note: Please note that all One-Click Installs require that the domain they are being installed onto is set to Fully Hosted.
- When you request automatic upgrades, DreamHost updates the packages in the installer whenever they become available and notify you via email.
- You can also update your site by logging into your WordPress dashboard. From there, you can update your core WordPress install, plugins, and themes.
- As of WordPress 3.7, minor revision updates are done automatically by the WordPress application. DreamHost highly recommends that you allow these minor updates to automatically occur since they are typically bug fixes and/or security updates.
The first thing to do while checking out an overloaded blog is to see if it's being spammed. It is one of the top reason why blogs go crazy on CPU usage. Check the "Comments" link on your WordPress install. If you're seeing the same sort of comments as the mail you see in your mail account's Inbox from spammers, you'll need to install a plugin to help deal with the incoming flow of spam.
There are a lot of anti-spam plugins that are available for WordPress, but we're only going to list a few that work the best on our servers:
- Pros: Spam checking happens off server, low impact on server overhead, works with most feedback forms.
- Cons: Needs an API Key in order to run.
- Pros: Easy to install via WordPress, blocks users who don't have 'cookies' (which should only be bots), works with Akismet
- Cons: Requires editing your .htaccess
- Pros: CAPTCHAs keep bots from submitting comments.
- Cons: Spam isn't always done by bots, meaning manual spam will still get through. Not always readable/accessible.
Using a combination of these plugins is recommended, but keep in mind that the CAPTCHAs plugin is not always user friendly.
If spam isn't your problem, then the server is probably hitting your MySQL database more than it should. Since WordPress depends a lot on the database, it can make quite a few requests while trying to get the information needed to render your pages. This can be really inefficient and cause astronomical loads when sites like Reddit, Digg, Slashdot, and BoingBoing link to you.
Web Caching Plugins
There are several caching plugins available which promise to improve your loading times and decrease server load, allowing your site to handle large spikes in traffic like the Slashdot effect. Please note however that since your site is being cached the user may not see any immediate updates.
There are plenty of plugins that cache MySQL requests by building static content to load instead of hitting the database for every request. Below are some that work the best on our servers:
- Picking up where WP-Cache left off, this plugin has included advanced features as well as a plugin and hooks system. It should be included with all new deluxe one-click installs of WordPress done by DreamHost. An installation guide can be found here: Installing WP Super Cache
- This is probably one of the most user-friendly caching plugins out there. If you take one look at WP Super Cache and can't make heads or tails of it, HyperCache is an outstanding alternative for most end users.
- This plugin is also excellent, and gaining a lot of traction in the community, in part due to its inclusion of CDN features.
- Works together with Web Caching plugins above to further speed up your site – in particular if you're using many widgets.
You can activate Dreamhost's PHP FastCGI options which should improve your php code execution. If you are on a private server, you also have the option to activate XCache support which will further improve your PHP execution.
|Warning:||Some sites that have a lot of spam/bot/spider traffic could see a large increase in memory saturation when switching to FastCGI. If memory spikes are a problem, try switching to CGI and use a good caching plugin (see above).|
Checking your Plugins
Firstly, it's extremely important to make sure your plugins are compatible with the version of WordPress you're using.
This is something you can verify at WordPress' Plugin Directory.
If you are experiencing site slowness, and you want to see if it's resource-usage related (and not something on DreamHost`s end), simply disable all your plugins, and switch to the default theme.
If your WordPress installation is suddenly running faster, then it’s recommended to go through your plugins and enable them one-by-one, to see if any of them is using more resources than the others.
For a more scientific approach, you can see how many queries and how much CPU time a page took to load.
To determine the number the queries and how much CPU is being used:
- Log into the server via FTP. You can find more info about how to use FTP here:
- Find your "footer.php" file which is found on the webserver.
- Navigate to your /wp-content/themes directory.
- In this directory, open the folder for the theme you’re using. For example, if you’re using ‘twentyfourteen’ you’d find the footer.php file at /wp-content/themes/twentyfourteen/footer.php.
- In the file, add the following content at the very bottom:
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds
By reloading this page each time you activate a plugin, you can check which one increases your queries and CPU time considerably.
On the bottom of your Wordpress site you’ll see:
# queries in # seconds
You will need to have any caching plugins disabled for this to work.
The Jetpack plugin is a bit special. You might try disabling individual modules in the plugin to improve performance. For each module, click "Learn More" and then "Deactivate".
The size of your images can also contribute to a slow loading site. The larger your images, the longer it will take for it to download on the user's end. So you will want to make sure that your images are as small as possible. Please read over these instructions on how to optimize your images
Be suspicious of all widgets (or sidebar content) that will force the user to poll other DNS servers. This may delay the loading of the site.
Also, check if your theme is using custom widgets to draw recent comments of posts. If this is not handled correctly, it will poll the database every time which increases your site's load considerably.
If you're using a lot of widgets, a good option is to use the WP Widget Cache plugin (in addition to standard caching) to reduce the processing time for their output.
You should routinely optimize your MySQL database to avoid a "fragmentation" effect. The easiest way to do this is to use the WP-DBManager plugin which includes a function to optimize your database as well as the capability to schedule this optimization to run at an appropriate timeframe (recommended once per month at least).
Post Revisions is a WordPress feature that has proven to be helpful. While these are very nice to have, some databases can balloon if you're prone to making a lot of changes or spending a lot of time creating a post. To help keep your database size down — which keeps your install speedy — you might want to fine tune the amount of revisions your site saves.
Running a MySQL Query
If you don't want to add another plugin into your WordPress installation, then you can run a simple SQL query to remove revisions.
To set up a SQL query:
- Open your panel and navigate to the (Panel > ‘Goodies‘ > ‘MySQL Databases’) page.
- Log into phpMyAdmin.
- You will see your tables listed on the left.
- Click your database name.
- Make a note of the table prefix.
Note: The table prefix may appear as "wp_" but it’s very possible to have a random string of letters such as "wp_qch9en_".
- In the upper left of the phpMyAdmin page are a series of icons:
- Click the SQL button to open the SQL command window.
- The SQL command page opens:
- Paste the following SQL command in the SQL window:
DELETE FROM wp_posts WHERE post_type = "revision";
This will remove all revisions currently stored in the database. Just make sure to enter the correct table prefix into the query. In the example above, the prefix is just wp_.
To prevent revisions from being created and stored in the first place, add this line to your wp-config.php file after the database info:
You can find the wp-config.php file in your FTP account. It will be in the primary folder for your domain.
If you still want to save some revisions, you can use the following code in place of the one above:
define('AUTOSAVE_INTERVAL', 120 ); // Default value is 60 seconds. define('WP_POST_REVISIONS', 3); // Number of revisions to save.
That limits the number of revisions to 3 and changes the auto-save value to every 2 minutes. You can change those values to something higher (or lower).
You can read more about revisions via the WordPress codex here:
While having a plugin that handles your stats (and displays them in your admin interface) is nice, they can actually inflate the database almost as quickly as unchecked spam. This means you should be cautious of using them, and pay special attention to your database if you do so.
Optimally, you'd use something that doesn't depend on your server environment like Google Analytics — but if you prefer a server side solution, Piwik is available in our one-click installer and works rather nicely.
WordPress uses the xmlrpc.php file for remote administration purposes such as posting via third party applications. However, this file can be a target for attackers.
To protect your site, DreamHost has implemented rate-limiting on this file. You can disable xmlrpc.php although some plugins which depend on it (like Jetpack) may no longer work if you do.
Sometimes, due to upgrades or some poorly coded pre-packaged themes, your WordPress install might have some missing files. Missing files make the server expend a little extra effort and can drive up load considerably on a popular site. One of the most common missing files is the favicon (favicon.ico). If you've recently used the one-click installer, a favicon should be generated for you — but it never hurts to make sure one exists in the main directory for your site.
Adding a favicon if one doesn't already exist is easy. It does require SSH access however. In the root directory of your site (i.e. /home/username/example.com/), type:
This command creates a blank favicon.ico file. But a blank icon is far better than one that is missing.
To check for any other missing files, you can run your site through Pingdom Tools. A single pass through their site will point out any missing files that could be causing your site to load slowly. Just look for filenames in red and then either replace them or remove references to them in your themes or posts.
Upgrading to DreamPress or a Private Server
If you've tried the plugins and suggestions but are still seeing a high load on the server, then it could be that the traffic to your site has outgrown shared hosting. At this point you may wish to consider adding a Private Server or DreamPress to your hosting package.
If you have any questions about adding DreamPress or a Private Server to your account, please contact DreamHost support for more info.
Here are a few tools to help you troubleshoot performance issues with your Wordpress site:
- Firebug: A very handy tool that displays what is loading and how long it takes.
- YSlow: A companion to Firebug that might give you some pointers on what to fix and how.
- Web Inspector: Built into Chrome and Safari, it gives you much of the same information as Firebug.
Only use the following if you are using a VPS or Dedicated server:
- Load Impact: A load testing service that hits your server with many simultaneous users. A free version does a 50 user test. Be sure that you have caching enabled before running. During this process, you can watch the CPU load with 'top', and RAM levels with 'free -m' - or both with 'vmstat 1' (Ctrl-c to stop).