04 September, 2007

Blog Tips#3 Increase performance of your WP site

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.
  • Some particular third party widgets/ JavaScript 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.

Some particular third party widgets/ JavaScript codes
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 :P .

Solution: Most commonly these third party scripts/widgets have issues with new version of WordPress (reason unknown)-Snap preview anywhere, MyBloglog widget (javascript version of mybloglog) (surprisingly the slowness disappear when you manually coded the non javascript into your template), Advertising networks JavaScript codes (I experienced some of the ad networks ad script brings down your site to its knees), few dozens others. The smartest move will be keeping only the necessary ones (if possible non JavaScript version).

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-

  1. 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.
  2. 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.

 

10 Responses to “Blog Tips#3 Increase performance of your WP site”

  1. [...] While looking through this WordPress performance post I realised that eAccelerator might not be running properly on this blog. For some time I’ve noticed this site hasn’t been as quick off the mark as it used to be. Dare I say it, but it was even a little sluggish! [...]

  2. [...] Increasing WordPress Performance: Segala has some tips for increasing the speed and performance of your WordPress blog. [...]

  3. Congratulations to Bernie who finally tied the knot! I re-read his post from yesterday and the penny dropped !Segala’s WP optimisation article is……

  4. Cormac 6 September 2007 at 7:42 pm #

    Good post Kunal, I never heard of eAccelerator before.

    I would recommend removing any non-dynamic content from the sidebar/header/footer too. No point in using PHP/MYSQL to bring up your blog’s pages/categories/footer when you can do it in HTML.

    You should probably test your blog’s load time on various DSL connections too.

    Total Validatorcan do this but there are more in-depth tools for testing other variables other than load time.

  5. Low Impact Development 10 September 2007 at 7:30 pm #

    That dashboard hack is awesome. Thanks for the tip!

  6. [...] While looking through this WordPress performance post I realised that eAccelerator might not be running properly on this blog. For some time I’ve noticed this site hasn’t been as quick off the mark as it used to be. Dare I say it, but it was even a little sluggish! [...]

  7. Geoff Dodd tips 20 February 2008 at 3:48 am #

    Thanks for ‘proof’ that it’s not WP that is slowing things down. Pingomatic is a great service running a massive load so I can excuse and applaud that component of successful blogging. You covered a lot of technical reasons for slowness. Thanks. GD.

  8. Performance guy 1 March 2008 at 2:08 pm #

    Caching is the key. If you can cache more the less queries will be sent to your mysql server, thus, lower load.

  9. Justin 5 February 2009 at 4:13 am #

    You mentioned about pings. I am wondering how to shut down comment pings in 2.7. I have been searching and looking and I cannot find where there is toggle switch/check box for disableing this feature. Can you point it out for me?

    Thanks

  10. Mohammad Allah- Er- Khan 6 October 2009 at 7:11 pm #

    Hello,

    Thank you for your excellent tips to increase the performance of a blog site. But I am having a problem with large wordpress static pages i.e. as the time goes the static pages increasing with much more contents and that’s why the page loading is slower day by day. Please help me in this regards. It will be highly appreciated if you can suggest that how to minimize or what techniques should be used to manage this huge contents in a static wordpress page.

    Look forward to your suggestions.

    Thanks,
    Mohammad Allah- Er- Khan

Leave a Reply

About

Founded in 2003 and privately owned, Segala is a specialist in testing and certification.

Segala‚Äôs mission it to help make the Web more reliable, safe and trustworthy. Our method of certification helps us to realize this mission by exposing more information about the suitability of each website in search results – enabling users to make informed decisions about which sites to visit. Read More…

Contact

Contact us by emailing daphne@segala.com or call +353 (0)1 2931966. Our address is 19 The Mall, Beacon Court, Sandyford, D18. Ireland.

PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIGFib3V0PC9sa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