Support » Fixing WordPress » Performance Help

  • colinwiseman



    I help run a rather large blog. we have 250K visitors with almost 450K page views a month on the blog. in the last month we have increased by almost 70K and it’s hitting us hard!

    I have moved most of the static files on to a seperate server and that helped massively, but now we are starting to slow down again.

    We run WP Super Cache and jQuery lazy load to make sure that visitors are only loading things that they need to load and not everything on the page. But still things are slowing down.

    Does anyone know of an easyway to change WordPress so that I can start to move the massive amount of images to another server – i.e. all current images stay where they are, any new ones get uploaded to a new server automagically via WordPress.

    Can anyone help point me in the right directions for the next steps of running a large site such as this. Or in your opinion is this the stage that we need to think of a more bespoke system?

    Big ask, but we need a big help.


Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Mark Ratledge


    Forum Moderator

    Searching the forums makes me believe there’s no easy way to upload images to a different server.

    But you can use to speed things up, and also be sure you have cleaned out old post/page revisions, as they can greatly increase the size of a database and result in a big slowdown. Run as SQL query in phpmyadmin to delete revisions:

    DELETE a,b,c
    FROM wp_posts a
    LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
    LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
    WHERE a.post_type = 'revision'

    You can add this line to wp-config.php to stop future revisions:

    define ('WP_POST_REVISIONS', FALSE);




    Thanks for your reply, so are you saying all the revisions from all the posts that are still in the database, could be slowing the site down? And running that nice looking script above it should give a small DB performance increase?

    For the images I have created a work around which might help. I have created a subdomain website, and any images that get requested from this subdomain, that don’t exist, get downloaded off the live site.

    The script then redirects back to the new image location properly, and hey presto, you have uploaded your image to WordPress normally, but it appears on my second server. Makes it simple.

    You can see the code on my personal blog – – but the code is C# on a Windows server…sorry php folks.

    Moderator Mark Ratledge


    Forum Moderator

    In several cases, I dropped database sizes by 80% by deleting post/page revisions and got a huge increase in speed. Backup database beforehand.

    Also, are you running any wordpress plugins that log stats, searches, etc.? They may have huge database tables.

    That scriot looks interesting. I’m sure people would be interested in it if there was a php version.




    Things look to be going quite nicely now. Quite a speed boost I have got with things. But 1 things I noticed. I installed W3 Total Cache, and the site is flying now most of the time – when a spike in traffic hits we still slow down. The W3 Total Cache showed that the home page had 331 database queries to load it…that’s a massive amount! I noticed that our post page had 90+! Madness!! But then I realised I had built a slideshow at the top of the page – takes a random 20 items from any post marked as “Featured”. And iterates round them. This added somthing like 40 queries of the database onto the page – 2 per page taken from the database…here’s my code:

    <?php $temp_query = clone $wp_query; ?>
        <?php query_posts('category_name=Featured&orderby=rand'); ?>
        <?php $count = $wp_query->post_count; ?>
        <div id="slideshow-body" style="width: <?php echo $count * 214 ?>px;float:left;height: 60px; position:absolute;">
        <?php while (have_posts()) : the_post(); ?> 
        <div class="item" style="width: 214px;float:left;height: 60px;">
            <div class="image" style="width:56px;float:left;">
                <?php if ( has_post_thumbnail() ) { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark" onclick="_gaq.push(['_trackEvent', 'slideshow', 'viewed', '<?php the_title(); ?>']);">
                        <?php the_post_thumbnail( array(50,50), array('style' => 'padding:2px; border: solid 1px #ddd;') ) ?>
                <?php } else {
                } ?>
            </div><!-- END IMAGE -->
            <div class="link" style="width:150px;padding: 0 0 0 4px; float:left;">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" onclick="_gaq.push(['_trackEvent', 'slideshow', 'viewed', '<?php the_title(); ?>']);"><?php
                    $title = the_title('','',FALSE);
                    $len = strlen($title);
                    if($len > 65)
                        echo substr($title, 0, 65).'...';
                        echo $title;
        </div><!-- END ITEM -->
        <?php endwhile; ?>

    Why is it the database get’s hit so often when I set up my query in query_posts. Should it not get what I ask from the database in 1 call and store it in 1 object that get’s itterated around? It seems to go back to the database for each loop!!

    And am sure this is correct as I have read about WordPress’s “loop” so could it just be the way WordPress is built that it will do this for each query and loop?



    Right bit more testing and I found out it is the call to ‘the_post_thumbnail’ that is pushing up the database queries! Should the post thumbnail not be stored with the post and not in another table?



    i suggest you to go with hyper cache and db cache reloaded

    Install both the plugins..i am seeing a good result on my blog which has approx same hits as you have

    Hope that Helps



    The problem am having with database caching via plugins is that either they use memcached – which won’t install for some reason – or disk to store the objects. With the number of files that get thrown around on the site, database disk caching kills the site 🙁

    I read a post earlier today that gave recommended settings for MySQL. Should try them, but I don’t want to crash the site…again!!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Performance Help’ is closed to new replies.