WordPress is a monster of a PHP application and many people running the CMS know that it’s not only your server that suffers but the end user as well. Someone once told me that all sites need to load in under 4 seconds which seems nigh impossible for a site that has 30 plugins and huge images that have to load on a single long scroll, but it can be done! Today I’ll go over what I have to do to tame the monster that is WordPress into a kitten!

sonic

1. First run a speed test on Pingdom and ask yourself the following questions

What is taking the longest to load on the site?

screen-shot-2015-01-13-at-9-33-38-am

This is the easiest step, by arranging your waterfall you can see that images are a big issue by the length of the green bars (receive time) and my script order is a little bad for that PHP script by the length of the yellow bar (wait time).

The quick fixes for all of the major issues are:

    • If scripts are taking the longest to load, move them to the footer (not always possible with wordpress but please for the love of god try)
    • If css is taking the longest to load move it all into one file (this is almost never a problem)
    • If images are taking the longest to load and it STILL is taking the longest to load after you do the image optimizations below you need to scatter the images across some subdomains and load them synchronously (or implement a lazy load feature) putting images across several subdomains or on a CDN allows the user to call them all at once instead of one at a time.

What is holding up the rest of the scripts on the site?

Arranging the waterfall by load order (it’s the default in pingdom) will give you a better idea of what is the problem child on your site. When sites are downloaded, one resource is downloaded at a time, and it has to be fully downloaded before you can move onto the next. Large scripts and 404s definitely slow down the process so it’s important that you move these to the footer or remove them.

What percentage of the site load is images? scripts? etc

screen-shot-2015-01-13-at-9-41-26-am-1024x727

Clicking over to the page analysis gives you a better idea of what you need to attack. Is the large percentage of the site images? Focus on image optimization, is javascript wrecking your load time? Remember that you must know thy enemy to conquer them.

sonic-the-hedghog

2. Install and run this plugin and do more research

The Plugin Profiler is probably the only thing useful Godaddy has ever built for WordPress (although they are trying with managed wordpress hosting) and it can be a bit buggy. The biggest problem is that the scan doesn’t start or takes a day and forever to do anything. Make sure you have no caching plugins installed on wordpress when you’re running the scan and fiddle around with the settings to get it to do it’s thing.

What is the plugin taking up the most of the site speed?

Once the scan completes, which sometimes can be a pain, you’ll be given a report that looks like this:

screen-shot-2015-01-13-at-9-59-31-am

The large chunk of the pie is Nextgen Gallery, can I get rid of this (probably)?

What is the overall plugin load in megabytes? (this is important later)

Clicking over to the advanced metrics you’ll get the plugin load, this is how much wordpress is basically taxing your server, when we run apachebuddy (my best friend in perl script form) you’ll see this number come up later.

screen-shot-2015-01-13-at-10-02-57-am-1024x379

Can any of these plugins be deactivated and replaced with hard code?

I want to say like 80% of the plugins I see on a wordpress install are completely and utterly useless when you could code something to do the exact same functionality instead within ten minutes. If you have a plugin to make accordion menus, please for the love of sonic just use bootstrap and make one.

How many MySQL queries are made on the homepage?

This comes from a site that I was helping optimize some time ago. It was an auction site on wordpress (the horror) and it was making thousands of queries on the home page alone. Can you combine some of these queries? Calling on the database so often is definitely going to slow the site down.

Plugin load in the top destroyer of wordpress sites, plugins are loaded on every page no matter what happens, so it’s important to minimize them as much as possible. This plugin load creates huge apache processes and can take down some of my biggest servers.

3. Install the following plugins (yes I know I just complained about them)

sonic-the-hedgehog-movie

These are basically my go to set of plugins for any wordpress site regardless of whatever else is going on in the site. They cover the major wordpress problem children: Plugins, Images, and MySQL.

Quick Cache: caching plugin that doesn’t screw everything up!

screen-shot-2015-01-13-at-10-43-36-am

A lot of people use the W3 Total Cache but this plugin causes problems more often than not, and if it does conflict, it takes more than just a Mr. Clean Magic Eraser to get it off your server! I absolutely hate plugins that stick around longer than necessary. Quick Cache is light, and almost never messes with any other plugins that I have installed.

Plugin Organizer: the easiest solution for lots of plugins!

screen-shot-2015-01-13-at-10-44-09-am

Plugin Organizer has saved me on numerous occasions where clients want to install 5000 plugins that do absolutely nothing except load a facebook like box on one page, or a form on another. These are “mandatory” plugins that eat up memory faster than pacman and slow the site to a crawl. With the plugin organizer you can selectively load the plugins on only the pages that need them, and turn them off on pages that are not using them. I love it!

WP Smushit: good for compressing images!

screen-shot-2015-01-13-at-10-44-44-am

Yahoo actually does some decent things when no one is looking at the Smushit algorithm for compressing images is one of them. This plugin automatically goes through your media library and compresses old images, and when you upload new images, it compresses them too! It’s nice for an easy way out but the drawback is that it only works on images less than 1MB in size (which seems like a lot but I always find it isn’t enough sometimes

WP Optimize: only if there are a high number of MySQL queries being run on page load!

 

Remember when you did the P3 Profiler and you could see how many SQL queries were being called? If that number is in the hundreds, this is the plugin for you, also if you’re running a large amount of users or content this helps clean everything up so queries execute faster. It’s a good plugin if your install is database heavy, I would install this plugin.

4. Add this to your .htaccess file

This set of rules is a good way to get on Google’s good side as it passes their page compliance, and also helps with browser caching which generally speeds up the user experience.

5. Run images larger than 1MB through Compressor.io

screen-shot-2014-12-31-at-12-28-02-pm-1024x576

I talked about this service in my last blog post but it’s really a necessity if you have a large image install. Go into your uploads folder via FTP, organize by size, and fix everything over 1MB, you shouldn’t be uploading huge images like that anyways unless you’re NASA. Shame on you. I know you didn’t save for web from photoshop.

6. Devops Fun Time: On your Server run the following commands and follow the suggestions

tumblr_n94tlozltc1tumiaoo1_500

No post would be complete without devops, would it? Fire up the terminal and SSH into your web server (these only work on dedicated hosting, if you’re not on dedicated hosting and you’re running into memory issues, maybe you should look into dedicated hosting?)

curl http://cloudfiles.fanatassist.com/apachebuddy.pl | perl

That will optimize apache using the memory load of each www-data instance, this instance is your wordpress install + your plugin load. This will see how many people can access your server at once without the server crashing. See why plugins are terrible? They’re mean to your poor server’s memory. Save your server the trouble and get rid of useless plugins.

wget https://raw.github.com/major/MySQLTuner-perl/master/mysqltuner.pl
./mysqltuner.pl --user root --pass YOURPASSWORD --forcemem 1024

will optimize mysql

and if thats not enough lazyscripts helps me quite a bit for server optimization and management. Why be an overachiever, when you can be an underachiever with lazyscripts?

After all THAT is done set up an account at New Relic to monitor the site and see for points for tweaking it helps to see what scripts are taking the longest processing time, or what processes are constantly killing your server. These bottlenecks are a lot easier to see after a few days of monitoring your server traffic. I would only study this after you’ve fully optimized wordpress to see what else is wrong with your install that I haven’t covered.

Finally, if you’re not using it, you should be: Cloudflare if it can keep 4chan alive during a DDoS it can keep your site running smoothly during peak hours.

tumblr_mh3phhsqdy1rvyhnio1_500

Your wordpress site should be already running a lot faster now! Do you use anything else for plugins that you can’t live without? Do you have some secret trick I didn’t mention? Leave a comment!

As a sidenote to this post: I actually wrote this as an email to a person trying to hire me, they were a friend of a friend and they asked “what I would run” which I thought meant “what I would do if I were them” instead of “how much money should I give you” and gave them all this information for free. Which I suppose was beneficial for you and for them!