Our last blog tips was all about increasing readership, this time we will look at performance enhancement. Few days ago one of our readers expressed that he experienced sluggishness on the back end while using WordPress as a CMS with high number of pages. He (Tom) isn’t the only one who came across this problem, a lot of WP users experience similiar problems. The question is: Do these problems resides in the core of WP or occasionally forced by some other issues?
There is no simple answer. Any CMS, whether Drupal or WordPress can experience the same issues caused by numerous reasons without anything to do with the core itself. I will keep the focus of this discussion on the WordPress (self hosted) related issues to narrow it down. Why dont we turn the spotlight onto the fundamental reasons first, so that it would be easier to eliminate them? Your WP (WordPress) powered site may experience sluggishness because:
- MySQL server or connection issues.
- PHP Memory Limit.
- Apache log rotator problem (for Apache server).
- Broken/Degraded PHP code in template/theme files.
- Excessive plugin uses/ use of plugin(s) with broken codes.
- WordPress Dashboard’s display of RSS feeds.
- Pingback attempts when posting.
There are many other reasons which might trigger sluggishness, but they would be one way or another related to above mentioned causes. Now that we know what makes our WP site’s slow down (Back end or front end), let’s turn our focus on how to avoid these.
MySQL server or connection issues
Actually very little you can do about this, since your host can only resolve this. Most of the case this is a temporary issue, when your host is having an upgrade or downtime. Too many connections to your DBhost can also trigger sluggishness. Your WP back end can also slow down when MySQL Database is unable to keep up with the query demands.
Solution: Contact your server host if they are having an upgrade or downtime. Make sure your WP database isn’t shared with your other sites. Check with your hosting company regarding your DB statistics, if needed do an upgrade or change host. No use sticking to a host just because they are nice but can’t meet your technical demand.
PHP Memory Limit
The heartbeat of WP is PHP, so obviously when something goes wrong with that you will have issues. By default PHP is a beast with all kinds of nasty modules it thinks it needs to load. So the more it’s loading, the more memory you need. Why not control what to load? Disable as many extensions you are not using to save memory. There is a very useful guide on PHP configuration optimization.
Solution: Optimize your PHP configuration, avoid loading unused modules.
Apache log rotator problem (for Apache server)
This happens when your site is hosted on Apache server. When a log rotator script breaks, your server log files start growing huge in size. Meaning your server has to deal with hundreds of Megabytes excess log files that will slow it down to the point of instability.
Solution: Contact your server’s technical support. You may also check and make sure the files/directory of log files should be only server writable.
Broken/Degraded PHP code in template/theme files
Many WP users experience sluggishness for this reason as their site gets bigger. You will come across hundreds of beautiful, stunning looking WordPress themes on the web, but how will you know the PHP codes are optimized on the back end? WordPress has some basic guidelines/ requirements for theme submission, but a PHP code check isn’t one of them (Checking each themes code isn’t practical either). But, from the user’s perspective you need to make sure your themes code is optimized, as that code is the framework of the whole site.
Solution: First use wp-cache plugin (included with latest WP version installation pack). It’s the classic caching solution. It also knows how to update itself when comments are received, etc, so your site is always the most up to date and requires less load time. Second (optional) why recompile scripts every time, when you can save the bytecode? There is an extension called eAccelerator, its uses a bit of disk space but also optimizes the opcodes and saves you from having to recompile a script every time. It can shave up to 5000ms off your loading time, depending on the php code. Third switch your themes to some standard theme (for example-WordPress default theme) with all the plugins active and test the performances. If the performance remains sluggish, your problem isn’t in theme/template codes.
Excessive plugin uses/ use of plugin(s) with broken codes
This is the second most probable cause for WP to slow down. Just like above problem, this is also caused by broken PHP code or degraded MySQL queries, but in this case within the plugin files.
Solution: Don’t use a plugin when you can do it easily without the use of plugin. Activate only the plugins you want to really use, or best still, remove the non active plugins. Now deactivate all plugins and clear your browser cache. Activate one plugin and clear the cache again and check the performance, lastly clear cache again. Repeat the process until you experience slowness or finish activating all required plugins. There are ways to identify slow/degraded MySQL querries, which I will discuss in next blog tip.
Oddly enough this is a random problem, meaning different people experience sluggishness with different types of third party scripts or widgets. So, why am I saying the reasons are problematic codes, where it’s random? For most cases the problem is resolved when those scripts or widgets are removed, they must have been the cause .
WordPress Dashboard’s display of RSS feeds
If you find that editing posts/templates or logging into WordPress takes a long time, the culprit is probably the WP dashboard. This is the “home” of the administration section, displays links to your latest posts, upcoming posts, comments, and incoming links. Unfortunately, it also displays a number of RSS feeds related to WordPress. While this sounds like a good idea, it often takes 30 seconds or longer to load the page because of delays fetching the RSS files, and they rarely have anything new and relevant. Two ways you can avoid that-
- Avoid loading the Dashboard page (index.php) at all. Instead of using the “Login” link in the sidebar, you may use link that goes straight to /wp-admin/post.php. This brings you straight to the posting interface, which loads instantly, and you can use the links to reach other parts of the console, including the Dashboard if you need it.
- If you still want to use the standard login feature, install Angsuman’s Dashboard hack, which replaces the RSS section of the dashboard with more useful links within your site.
Pingback attempts when posting
This is a random cause of your slow WP posting interface, especially the editing part. While the actual posting process is instantaneous, the delay is caused by two parts of network activity-
- WordPress attempts to use Pingback to notify every URL you’ve linked to. If you find yourself linking to WordPress blogs often, this is actually a useful feature-otherwise, it’s a waste of time. In my experience, attempts to Pingback non-blog sites are the cause of most of this delay. Lastly please for heavens sake do not use any plugin such as default trackback, because you don’t want your server to spend 40-45 seconds to trackback something that isn’t relavent to your posts.
- WordPress uses Ping-o-matic to notify search engines of your post. This is a very good thing, but occasionally causes delays. Rarely, Ping-o-matic causes a delay when posting. To eliminate this, you can remove rpc.pingomatic.com from the list of Update Services in Options -> Writing. You can even use other ping server instead of pingomatic. Here is the list of some useful ping servers which can be used instead of pingomatic.
As you can see most of the cases for slowing down a WP site isn’t WP related at all. A little bit of workaround and tricks can be just enough to avoid these.