Blog

Real world Wordpress performance testing

The background

A few weeks ago, one of the companies I'm partly involved in purchased a very popular website in the Swedish real estate field. The website we bought was essentially a Wordpress site with some interesting customizations. The new website ranks very good in Google and the other major search engines and the amount of organic traffic that flows in to that site is simply fantastic.

As soon as the deal was done, the team copied the website to a new production environment and started working with the graphic appearance so that the new site would resemble the existing old site. Half way through the work, the CEO of started asking questions about the performance. In short, it was terrible. A page would take anything from 4 to 10 seconds to load and sometimes it would even time out entirely. A few different efforts was made to explain and remedy the problem, but it turned out that there was a lot of guessing involved and none of the guesses made was the right one. Yesterday, I did the right thing and took it to the test bench.


Take it to the lab

They say that once you know how to use a hammer really well, all problems starts to look like a nail. I guess that's starting to become true for me, only in my case the hammer is loadimpact.com. My idea was to copy the Wordpress blog in question to an environment where I could examine it under load, so I did just that. I looked in the back of my closet and found this old 2.1 GHz Quad code with 8Gb RAM machine that was just collecting dust (kidding, I use it all the time). The server has a complete LAMP stack so both the web server and the mysql server resides on the same hardware. 

 

A few short words about how to move a Wordpress installation. It's not complicated, but you can end up with a few really non intuitive problems if you don't get it right. However, if you do it right, it's a 5 minute task (plus the actual time to move large files across the Internet). Here's how I got it right the second time:

Move all Wordpress files to the test environment. There isn't really that many ways to fail but you need to make sure that the web server(I'm assuming everyone uses Apache2 here) on the new host has read access to the destination folder. 

Get a DNS entry for the new destination. In my case, all the customizations made to the blog was assuming that the installation resided in the root folder of the webserver, all images was referred to with src="/images/foo.jpg" etc. So I setup a subdomain that pointed to the web server and set up a new virtual host that pointed directly to the Wordpress installation on the new web server

Copy the database. There's some room for error here. I used phpmyadmin to create a database dump from the production environment with the intention to restore it on a database accessible from the test environment. When restoring it in the test database, I used the command line:

mysql dbname -u username -p  < dumpfile.sql

That went really well, the database was recreated in no time and everything looked really good. But. That doesn't work. Wordpress uses uft-8 as default character set and in the above line the mysql command line tool will assume that the file is ISO-Latin-1. Chances are that it won't really hurt you at all but if it does, the errors will be far from intuitive. I ended up with error messages like:

Warning: array_keys() [function.array-keys]:
The first argument should be an array in wp-includes/widgets.php on line 657

The fact that you're looking at a character encoding problem here isn't really obvious right? But the explanation is farily simple. Worpress uses the PHP internal functions serialize and unserialize to transform complex structures like arrays and objects into strings that are suitable for storing in a database. The format used will for instance describe a string like this: s:10:"räksmörgås". The number 10 tells PHP how many characters to expect in the following string. When exporting the above example into a text file, the file on disk will look something like this: s:10:räksmörgÃ¥s. Now, if mysql thinks that the file you are importing is encoded in ISO-Latin-1, the content of the database will look exactly as it did on disk. Later when Wordpress is asking PHP to unserialize the expression s:10:räksmörgÃ¥s PHP will kindly reply that it can't be done and Wordpress will end up feeding funny looking strings into functions that would expect for instance and array as input parameter. The above error message I got was one of those examples. But the remedy is really simple, import the dumped file with this command instead:

 

mysql dbname -u username -p --default-character-set utf8 < dumpfile.sql

 

Adjust to the new environment. The last thing that  needs to be done when moving a Wordpress installation is to make sure Wordpress knows that it have moved now. There are two important places to change. First, the file wp-config.php needs to be updated with the new database credentials. Second, the table wp_options (could use a different prefix than "wp_" in your installation) stores the URL of the blog in two places, you will find them both using the following query:

SELECT * FROM wp_options WHERE option_name in('siteurl','home');

So, with the above steps taken care of, the Wordpress installation now works as expected in my test envornment. It could have been done in 5 minutes, but I ended up spending a little more due to the database character encoding experiment, but at least I learned something from it and hopefully so did you by reading about it.

 

Take it to the lab

Time to bring out the tool box. In my case, it's loadimpact.com account and a ssh account on the target machine. What I like to do is to put load on the application  and wait for white smoke to appear somewhere. Typically, I'm looking for signs showing that the application is too hard on the database, is using too much CPU or is memory hungry.  Of we go:

 

Yep, there's a problem with this blog alright. Even at 10 concurrent users, we have response times around 7 seconds. Interestingly though, the load times seem farily constant as we put additional load. At 50 concurrent users, we see about the same average response time as with 30 or 40 users. As this test was running, I was watching the server to see where the white smoke would appear. I didn't really have a favorite suspect so I began with using top:

The screenshot shows what top looked like with 50 concurrent users (remember that the response times here was in the range of 10 seconds). There's a couple of apache2 processes that's actually not that hard on resources. 4% CPU each and 0.3% memory (on a fairly powerful machine though). The mysqld process seem calm, it shows up in the list but uses very little CPU and memory resources. This actually looks fairly good. But let's go over the ususal suspects:

RAM memory actually looks really full, only 200 Mb  free, but that's actually just how Linux works with memory (the same numbers on a Windows machine would be awful). Before I see the kswapd process showing up in top, I won't really consider available RAM to be a problem. So conclusion #1 is that we don't have a problem with RAM memory.

CPU also looks good. None of the visible processes in top uses that much CPU. Also, take a look at the header. 95.1%id actually means that the server CPU is idling 95.1% of the time. Conclusion #1 is also easy, we don't have a problem with CPU usage.

Database usage looks good as well. Most of the work is carried out by the mysqld process that we already saw was very quiet. Since we actually have the web server and the database server on the same hardware, excess database usage would also show up as higher total CPU usage. But to be sure, I'll have a look using the tool mytop:

 

 mytop shows the currently running queries that mysql is handling at the moment. If we had any queries that took a really long time without consuming a lot of CPU, we'd catch them here. The screenshot above is takes while there was 50 concurrent users hitting the blog and the response times was in the 10 second range. It's clear that the delay in response times has nothing to do with poor database performance.

So, none of my three usuals suspects seem to be guilty this time. What else could there be?

 

The fourth suspect

The fourth suspect that I came to think about was network performance. Long response times paired with little activity on the server could indicate that there is some other resource on the network that is taking the load. My test server isn't showing any signs of activity, but what about other servers or the network itself? The next handy tool would be to bring out iftop. Here's what the screenshot looks like:

iftop will tell you what other hosts your server is connected to at the moment and how much bandwidth each of those connections are using at the moment. Looking at the list I could explain the reason behind each and everyone of the foreign hosts except for two of them. The last one on the list is an internal host on the same network and that's simply a file server that shouldn't come in to play at all. snik1.gatorhole.com is the server that's putting the load on my machine, so it's only natural that it shows up here. One of the other hosts is the one I'm using ssh from, so that one was also expected. The two I'm curious about was lillamy.ballou.se and s114.loopia.se.

Ballou.se is the domain name of our hosting provider for the new site, I find it interesting that we'd be hitting it with traffic. Loopia.se is the domain name of the OLD hosting provider for the site we're trying to test. That's even more interesting! Perhaps the application have some hard coded configuration that makes it look up things in the old environment!

Any such configuration would either be stored in the database or in the file system so I went there to look. First, I was using grep to search the file system for any references to the old domain name or hosting provider but it turned up blank. Next I was a bit lucky. Knowing that Wordpress stores a lot of information in the wp_options table I did a search for it in phpmyadmin:

SELECT * FROM `wp_lo_options` WHERE option_value like '%lokaler.nu%'

"lokaler.nu" is part of the domain name of this application and the DNS records are actually still pointing to the old server. I got roughly 10 rows back and after looking at them a bit the one that caught my attention was a the configuration for a RSS Widget. This widget would get the latest 6 news items from the blog itself. Instead of using a Widget such as "Recent Posts" or similar, the administrator setting this up had opted to get the news via RSS. Just replacing that Widget for the more natural "Recent posts" was exactly what I was looking for. The next test was much better:

 By removing the RSS Widget and getting the results directly from the internal database was the key. The graph is now much more normal and for a normal 10-20 concurrent users we're in the comfortable 1-2 second range. We still have issues to look at and the next step is to install one of the better Wordpress cache solutions, but the most critical performance issue is resolved. Done.

 

 Conclusions

So, did we learn anything new today? Well, yes I'd like to think so. First and foremost, using a load testing tool to find out what's wrong with an application is actually a very good idea. Putting load on a web application is a good way to make the performance problems stand out a lot more. In this case, the tools used to examine what's going on on the server all takes a little time to produce interesting numbers. A single snapshot of top is useful, but looking at it for 60 seconds is an order of magnitude better. The same goes for all the other tools involved. Even getting to see the s114.loopia.se name show up in iftop would have been impossible or at least required a lot of luck if we had to generate the traffic using manual refresh in Firefox/Firebug.

Second, if you're using an RSS Widget in your Wordpress blog, please be careful. If you're using it to draw news from your own blog, consider using a Widget that can get data directly from the database instead. If you are pulling news from an external source, make sure you use a working cache module.

 

 

 

 

 

 

Wordpress load testing part 3 - Multi language woes

Understanding the effects of memory starvation.

This is the third part in a series of posts about Wordpress and performance. In part 1,
we took a look at Wordpress in general. In part 2 and part 2.5 we reviewed a couple of popular caching plugins that can boost performance. In this part, we'll start looking at how various plugins can have a negative effect on performance and if anything can be done about it.

In the comments for one of the previous posts in this series, Yaakov Albietz asked us if we used our own service www.loadimpact.com for the tests. I realize that I haven't been that obvious about that, but yes, absolutely, we're exlusively using our own service. The cool thing is that so can you! If you're curious about how your own web site handles load, take it for a spin using our service. It's free.

We started out by looking for plugins that could have a negative effect on Wordpress performance, thinking, what are the typical properties of a bad performer plugin? Not so obvious as one could think. We installed, tested and tinkered with plenty of suspects without finding anything really interesting to report on. But as it happens, a friend of a friend had just installed the Wordpress Multi Language plugin and noted some performance issues. Worth taking a look at.

The plugin in question is Wordpress Multi Language (WPML). It's got a high rating among the Wordpress community wich makes it even more interesting to have look at. Said and done, we installed WPML and had it for a spin.

The installation is really straight forward. As long as your file permissions are set up correctly and the Wordpress database user have permissions to create tables, it's a 5-6 click process. Install, activate, select default language and at least one additional language and your done. We're eager to test, so as soon as we had the software in place, we did our first test run on our 10 post Wordpress test blog. Here's the graph:

Average load times 10 to 50 users

Ops! The baseline tests we did for this Wordpress installation gave a 1220 ms response time when using 50 concurrent users. We're looking at something completely different here. At 40 concurrent users we're getting 2120 ms and at 50 users we're all the way up to 5.6 seconds or 5600 ms. That needs to be examined a bit more.

Our first suspicion was that WPML would put additional load on the MySQL server. Our analysis was actually quite simple. For each page that needs to be rendered, Wordpress now have to check if any of the posts or pages that appears on that page have a translated version for the selected language. WPML handles that magic by hooking into the main Wordpress loop. The hook rewrites the MySQL query about to be sent to the database so that instead of a simple "select foo from bar" statement (over simplified), it's a more complex JOIN that would typically require more work from the database engine. A prime performance degradation suspect unless it's carefully written and matched with sensible indexes.

So we reran the test. While that test was running we sat down and had a look at the server to see if we could easily spot the problem. In this case, looking at the server means log in via ssh and run the top command (if it had been a Microsoft Windows box, we'd probably have used the Sysinternals Process Exporer utility) to see what's there. Typically, we'd want to know if the server is out of CPU power, RAM memory or some combination. We were expecting to see the mysqld process consume lots of CPU and verify our thesis above. By just keeping an unscientific eye on top and writing down the rough numbers while the test was running, we saw a very clear trend but it was not related to heavy mysqld CPU usage:

20 users: 65-75% idle CPU 640 MB free RAM
30 users: 50-55% idle CPU 430 MB free RAM
40 users: 45-50% idle CPU 210 MB free RAM
50 users: 0%   idle CPU  32 MB free RAM

As more and more users was added we saw CPU resource usage go up and free memory availability go down, as one would expect. The interesting things is that at 50 users we noted that memory was extremely scarce and that the CPU had no idle time at all. Memory consumption increases in a linear fashion, but CPU usage suddenly peaks. That sudden peak in CPU usage was due to swapping. When the server comes to the point where RAM is running low, it's going to do a lot more swapping to disk and that takes time and eats CPU. With this background information in place, we just had to see what happended when going beyond 50 users:

That's very consistent with what we could have expected. Around 50 concurrent users, the server is out of memory and there's a lot of swapping going on. Increasing the load above 50 users will make the situation even worse. Looking at top during the later stages of this test confirms the picture. The kswapd process is using 66% percent of the server CPU resources and there's a steady queue of apache2 processes waiting to get their share. And let's also notice that mysqld is nowhere to be seen (yes, this image is only showing the first 8 processes, you just have to take my word for it).

 

 

The results from this series of tests are not WPML specific but universal. As we put more and more stress on the web server, both memory and CPU consumption will rise. At some point we will reach the limit of what the server can handle and something got to give. When it does, any linear behavior we may have observed will most likely change into something completely different.

There isn't anything wrong with WPML, quite the opposite. It's a great tool for anyone that want a multi language website managed by one of the easiest content management systems out there. But it adds functionality to Wordpress and in order to do so, it uses more server resources. It seems WPML is heavier on memory than on CPU, so we ran out of memory first. It's also interesting to see that WPML is actually quite friendly to the database, at no point during our tests did we see MySQL consume noticeable amounts of CPU.

 

Conclusion 1: If you're interested in using WPML on your site. Make sure you have enough server RAM. Experience of memory requirements from "plain" Wordpress will not apply. From the top screen shot above, we conclude that one apache2 instance running Wordpress + WPML will consume roughly 17 Mb RAM, we havent examined how that differs with number of posts, number of comments etc, so lets use 20Mb as an estimate. If your server is set up to handle 50 such processes at the same time, you're looking at 1000 Mb just for Apache. So bring out your calculators and calculate how much memory your will need for your server by multiplying the peak number of users you expect with 20.

Conclusion 2: This blog post turned out a little different that we first expected and instead of blaming on poor database design we ended up realizing that we were watching a classic case of memory starvation. As it turned out, we also showed how we could use our load testing service to provide a reliable source of traffic volume to create an environment where we could watch the problem as it happens. Good stuff, something that we will appear as a separate blog post shortly.

 

Feedback

We want to know what you think. Are there any other specific plugins that you want to see tested? Should we focus on tests with more users, more posts in the blog, more comments? Please comment on this post and tell us what you think.

 

Wordpress load test part 2 - amendment

This is the second and a half part in a series of posts about Wordpress and performance. In part 1,
we took a look at Wordpress in general. In part 2 we reviewed a couple of popular caching plugins that can boost performance. In this follow up post, we'll tell you a bit about what we learned after part 2 was published.

 

Revisiting W3 Total Cache

After publishing our results in part 2, we received a concerned Twitter message from Frederick Townes, the W3 Total Cache (W3TC) author. He thought we had done something wrong since the Disk enhanced cache mechanism used in W3TC should be at least as effective as the Wordpress Super Cache plugin (WPSC). After a brief Twitter discussion, we understood that he was absolutely right. The mod_rewrite magic that WPSC uses to achieve the amazing results was indeed present in W3TC as well (and I might as well add that the mod_rewrite rules added by Freredick's plugin is neater than the ones added by the test winner).

The mistake we made in our first test is that we didn't realize the significant difference between the two different disk based page caching methods available. There's "Basic" caching which is the one we tested, and there's "Enhanced mode". In Basic mode, W3TC will work pretty much the same way as the standard wp-cache plugin which involves invoking a PHP script. In our server benchmark, we've already seen that our server will consume in the region of 80ms for doing that so we're glad if we could avoid it in the elegant manner that Wordpress Super Cache does.

In Enhanced mode, surprise surprise, avoiding invoking PHP is exactly what W3 Total Cache will do. The basic concept is the same in W3TC and WPSC, both plugins will add a bunch of lines to the .htaccess file that tells Apache2 to go look for a static copy of (a.k.a cached) version of the requested file/resource. And as noted above, W3TC does this with a slightly more elegant addition to .htaccess. In our defense, even though the documentation provided with W3TC is good, we didn't find anything in particular that explained this significant difference between Basic and Enhanced.

How Load Impact can affect the results

Naturally, we took W3TC back to the lab to see how fast it is in enhanced mode. But before telling you about the results, we want to explain a few details about how Load Impact works. When we ask Load Impact to simulate the load of 50 concurrent web users, that is exactly what Load Impact will do. The second the test starts, exactly 50 virtual users will load the page at the same time and Load Impact will note how long time it takes before the web server responds and the content is completely transferred. Then, each virtual user will make a random pause and try again. Depending on the accuracy settings for the test, this will be repeated over and over again. In a "Fast" test, there will be very few repetitions and in a "Accurate" test, there will be lots and lots of repetitions. The more repetitions, the more data points to use when calculating the average load time. This configuration setting allows users to prioritize test completion time over accuracy if they want to. This behavior actually have some impact when testing cache plugins. When we test, the first time when 50 virtual users comes storming to the test web server at once Apache will fire up as many child processes as it's configured for, 30 in our case. All of these processes will go look in the cache and quite likely discover that there is no cached version of the requested file. So PHP is invoked, Wordpress will generate the page and the cache plugin kicks in and stores the rendered version of the page in the cache. Not only does creating the cached version take more time than a normal page request does, in our scenario, there's a risk that this is done up to 30 times. And to make things even worse, 30 child processes writing to a file based cache exactly the same time will cause a lot of file locking problems that will end up taking even more time.

The conclusion is that depending on the state of the cache when the test begins, the response time of the first 30 data points may vary. And this is exactly what we saw when we took W3 Total Cache back to the lab.

Testing W3 Total Cache again

We retested W3TC again and arrived at these numbers:

Wordpress baseline: 1220 ms

W3 Total Cache (basic disk): 256 ms (-79.0%)

W3 Total Cache (enhanced disk): 188 ms (-84.6%)

That's a solid improvement so we contacted Frederick again with the good news only to be turned down again, "something is still wrong" he told us. Then we redid the test for Enhanced mode  and over again with minor tweaks to the W3TC settings. After every tweak, we cleared the cache so that any cached pages specifics wouldn't interfere with the current settings. We saw slightly higher average load times as well as slightly lower, but we were never close to the 112 ms record set when using the Wordpress Super Cahce plugin. Until the "warm vs cold" cache issue hit us and we did a test with a warm cache. And boom! The average load time decreased all the way down to 109 ms, better than what WPSC would acheive. So let's add how W3TC performs using enhanced disk caching:

Using Enhanced disk cache:

Average load time 50 users: 109 ms

Baseline difference: -1111 ms

Baseline difference %: -91.1%

 

 

Summary

Results

Before updating the results table,  we retested the other results as well, but the number we ended up with in the retests was all within a 5ms difference from the original test result, so we're sticking with the results from our first round of tests. But we're reducing to using just 2 significant figures: 

PluginAvg. load timeDifference

Difference %

Standard Wordpress12200

0 %

wp-cache210-1010

-83 %

batcache537-683

-56 %

WP Super Cache112-1108

-91 %

W3 Total Cache (disk basic)256-964

-79 %

W3 Total Cache (disk enhanced)109-1111

-91 %

W3 Total Cache (memcache)367-853

-70 %

 


That's it.

Wordpress load test part 2

NOTE: This post was updated after it was first published. Please click here for explanation.

This is the second part in a series of posts about
Wordpress and performance. In part 1, we took a look at Wordpress in general. In this part, we'll continue the investigation and look at a few specific plugins that can help improve performance.

First things first, in part 1, we used a 8Gb Quad core server for the tests. From now on, we've moved to a KVM virtual server. The main purpose of that is that we change the machine configuration when something interesting is discovered. For instance, if we discover a performance problem and suspect RAM memory to be the bottleneck, we can add memory to the machine and rerun the test. The obvious downside is that the baseline established in part 1 isn't valid anymore. So the first task is to examine how this virtual machine handles load as described in part 1.

The base configuration for the virtual server is 2 CPU cores running at 2.1 GHz with 1024 MB RAM memory. The OS Ubuntu JEOS upgraded to 9.04. Apache2 is at version ___, PHP5 is up to version  . The MySQL server is located on the same machine and is running 5.xxx. Wordpress is upgraded to version 2.9.1.

The baselines. A simple PHP script that sends 10 bytes of data back to the user has an average load time of 85 ms when running 80 concurrent users. That's actually pretty much the same number as we saw on the 8Gb Quad core machine, we had 80.9 ms on that machine.

Next thing we looked at in the first part was the average load time for a basic empty Wordpress install. On the Quad core box, we saw an average load time of 357 ms for 80 users. On the virtual machine, not so good. A ramp up test going from 50 to 80 concurrent users shows load times at 691 ms for 50 users and more or less infinite at 60 users. At that load level, the kswapd process was eating away a good 66% of all available CPU, meaning that the server spent most of it's time swapping pages back and forth between RAM and disk. Even if nothing actually crashed, we aborted the test and concluded that the current config can't handle more than 50 concurrent users.

For the final baseline test we added 10 posts into the Wordpress install and made a new measurement. On our virtual machine, 50 users gave us a load time of 1220 ms, the same load on the Quad core machine gave us 470 ms response times. Clearly, taking away 2 processor cores and slashing the RAM memory to 1/8th affects average load times badly which is not surprising at all. Anyway, we now know that our current test environment is unlikely to handle more than 50 concurrent users and we also know what happens if we add RAM and/or CPU cores.

 

Tweaking Wordpress performance

There are numerous of ways to increase wordpress performance and we'll have a look at how the numbers gets affected in this particular installation. Now, Wordpress wouldn't be Wordpress if the most interesting performance tweaks was already packaged as easy to use plugins, so instead of digging deep into the Wordpress core, we ended up evaulating a set of interesting plugins, here they are:

wp-cache plugin

The wp-cache plugin have become very popular way to add a chache to Wordpress. Wordpress used to have a built in object cache, but that got cancelled in Wordpress 2.5. So today, the wp-cache plugin is one of the most obvious plugins that come to mind when wanting to tweak Wordpress performance (and yes, we'll look at wp-super-cache as well). The test result with wp-cache is very good. As we've seen above, this server will need 85 ms to server the simplest possible PHP script and the wp-cache plugin gets us fairly close to that ideal number.

Average load time 50 users: 210 ms

Baseline difference: -1010 ms

Baseline difference %: -82.9%

 

batcache plugin

Batcache was written to help WordPress.com cope with the massive and
prolonged traffic spike on Gizmodo's live blog during Apple events.
Live blogs were famous for failing under the load of traffic. Gizmodo's
live blog stays up because of Batcache. The developers of Batcache actually refer to WP Super Cache themselves as a better alternative, but in some cases with multiple servers and where memcached is available, Batcache may be a better solution. The performance gains with Batcache is actually not up to par with what wp-cache or WP Super Cache delivers, but it's still a lot better than a standard Wordpress install.

Average load time 50 users: 537 ms

Baseline difference: -683 ms

Baseline difference %: -56.0%

 

WP Super Cache plugin

The WP Super cache plugin takes things a few step further compared to the standard wp-cache. Most notably, by using a set of Apache2 mod_rewrite rules, WP Super cache is able to serve most of your Wordpress content without ever invoking the PHP engine, instead the content is served at the same speed as it would serve static content such as graphics or javacsript files. Installing this plugin is a little bit more complicated and it requires both mod_headers and mod_expires Apache2 modules to be enabled. But once installed, it really works, just look at the numbers! If using the WP Super Cache plugin works on your server, it's probably the easiest and most powerful way to boost your Wordpress performance numbers. And if it doesn't work as intended on your server, the good thing is that it reverts back to the functionality provided by the standard wp-cache plugin.

Average load time 50 users: 112 ms

Baseline difference: -1108 ms

Baseline difference %: -90.8%

 

 

W3 Total Cache plugin

The W3 Total Cache plugin is a powerful plugin that takes the best from wp-cache and batcache and adds a few additional features to improve performance. W3 Total cache allows the user to choose between disk and memory based caching (using memcached). It also supports minifying HTML, JS and CSS files as well as the various types of http compression (deflate, gzip etc.). Finally, W3 Total cache supports placing content on a content delivery network (CDN) that can speed up loading of static content even further. W3 Total Cache have a lot of configuration options and we did not take the time to fully investigate them all. We did test the performance difference when using disk based caching and memory based caching and the difference is actually notable. We enabled minifying and compression but we've pretty much used everything else 'out of the box'.

Using disk cache:

Average load time 50 users: 256 ms

Baseline difference: -964 ms

Baseline difference %: -79.0%

 

Using memory cache:

Average load time 50 users: 367 ms

Baseline difference: -853 ms

Baseline difference %: -70.0%


Summary

Results

NOTE: This table was updated after it was first published. Please click here for explanation.

PluginAvg. load timeDifference

Difference %

Standard Wordpress12200

0 %

wp-cache210-1010

-83 %

batcache537-683

-56 %

WP Super Cache112-1108

-91 %

W3 Total Cache (disk basic)256-964

-79 %

W3 Total Cache (disk enhanced)109-1111

-91 %

W3 Total Cache (memcache)367-853

-70 %

 

Conclusions

The various performance related plugins for Wordpress all revolves around caching. The most impressive results was acheived using WP Super Cache and W3 Total Cache. Among the other plugins, the choice is between disk based caching and memcached based caching. Our tests actually show that disk is faster, but that's something that needs to be explored further. The tests have been done on a blog with very little data in it and Linux uses a fair amount of disk caching that is probably more effective with these particular amounts of data. Whenever WP Super Cache is not possible to use (or simply feels too exotic for you), we suspect that a perfectly tuned W3 Total Cache is the best choice. W3 Total Cache shows the most potential for tuning and we like the overall 'look-and-feel' of it. UPDATE: Actually, after retesting W3 Total Cache, we think it may an even better alternative than WP Super cache. The one negative thing we've picked up so far is a potential compatibility issue with Wordpress Multi User (WPMU), but we have not been able to confirm that.

 

Feedback

We want to know what you think. Are
there any other specific plugins that you want to see tested? Should we
focus on tests with more users, more posts in the blog, more comments?
Please comment on this post and tell us what you think.

 

 

 

Load testing Wordpress

This is the first part in a series of posts about Wordpress and performance. In part 1, we'll look at Wordpress in general, in later instalments, we'll look at how performance is affected by popular plugins and tweaks. (click here for part 2)

Wordpress is probably the most popular blogging platform out there today powering a countless number of blogs and other web sites. Wordpress was first released back in 200x and quickly became a popular tool for bloggers. Part of it's success is due to the fact that it's remarkably easy to install and configure. Another big hit with Wordpress is the community of users that contribute to the development by creating plugins. There are plugins for just about anything, display Google ads, search engine optimization, statistics, integration with social media just to name a few.

There are also downsides to Wordpress but the one that interests us the most is performance. Wordpress was once known to have lacklustre performance properties. It especially had big problems handling a lot of concurrent users. Imagine the disapointment from a young and aspiring blogger that writes endless amounts of excellent blogposts without being able to reach out to a bigger crowd. When he finally catches a break and gets that link from news.com, the Wordpress powered blog dies under the pressure and before the blog is back up again, that link from news.com is yesterdays news.

But Wordpress have gotten better. The default installation is faster out of the box and there are numerous of tips, tricks and guides on how to optimize Wordpress performance beyond what should be possible. And of course, there are also plugins that helps Wordpress to perform better. Our mission is to find out what the state of Wordpress performance is today. Let's start.

The tools

The tools we brought to the lab to do this series of tests are fairly simple. We have an out of the box Wordpress 2.8.6 blog installed on a single server. The server run Ubuntu Linux 9.04 on a Intel Quad Core 2.1 GHz machine with 8Gb RAM memory. The web server is the standard Apache2 that comes with Ubuntu and the database server is MySQL 5.1 located on the same machine. PHP is up to version 5.2.10. And the most important piece we brought was naturally a LoadImpact.com account to run the tests.

 

Establish a base line for the server

There are lot of moving parts in a setup like this. We first want to establish a baseline that tells us the maximum possible throughput on a PHP page in this specific setup. To do that, we created an simple php script that echoes exactly 10 bytes of data back to the browser. By load testing this simple script we get an understanding of how much of the page load time that is spent just on sending requests back and forth over the Internet, how well Apache2 can fire up the PHP processes and how much time PHP needs to initialize itself.

The baseline test and all the other tests we will be running is a ramp up from 50 up to 80 concurrent users. This is what the graph from the test look like:

Base line test. The performance of the server itself

As you can see. The response times actually gets better with more concurrent users (that's caching), overall it stays at or under 100 ms. So before putting Wordpress into the picture, we see response times at just under 100 ms. That's the best possible response time we could ever achieve with PHP at this load level on this particular server located at this particular IP.

 

Establish a baseline for Wordpress

Ok, next step is to see what we get when we install Wordpress. A standard Wordpress install will first and foremost run a whole lot more code than the previous script. It also connects to the database and looks for blog posts, comments and a lot of meta data such as what categories that are in use etc. So naturally we expect to see longer response times. We placed the same amount of load on the front page of the Wordpress installation as we did on empty.php, here's what an empty Wordpress blog looks like:

Performance when Wordpress is installed

 

The response times now begins at just over 300 ms at 50 concurrent users and at 80 the response times are just over 350 ms. But that's not very interesting, we need to add a few posts so that the scripts and database gets some actual work done. Here's what the graph looks like when 10 posts are added to the blog:

Wordpress performance with 10 posts added

That's a bit more interesting. We response times now starts at 425 ms, dips down to 364 ms at 60 concurrent users (mysql caching is our best guess here). At 70 and 80 concurrent users, the response times start rising quite sharply to 439 ms and 601 ms respectively. That actually starts looking like it's a "knee", the point where performance starts to really degrade and the server risks grinding to a halt.  Let's see what happens if we add even more load:

Wordpress load test with more clients

Yes indeed. With more clients, the response times increases even more, as expected.

In absolute numbers, we're still talking about very good response times
here even if this test is using a server with more CPU and RAM memory than the typical Wordpress installation have exclusive access to. And we are also looking at fairly high load levels. Getting 150 concurrent users on your blog is not going to happen to a lot of people and maintaining a reponse time of well under 2s is not bad at all.

The second thing to notice is that what we first suspected was a "knee" in the response time chart between 60 and 70 users does not look like a knee at all any more. The response times increases more or less proportionally to the load which is quite good. A really really high performing web site out there would display a more or less flat line for this load levels, but our setup is no where near that k

 

Conclusion

We've established a base line for Wordpress performance. We're going to keep testing this setup with various types of tweaks and write about it. The next part of this series will look at different plugins and how they affect performance, we've already tested a few of the most popular ones and some of them do affect performance quite a bit.

Feedback

We want to know what you think. Are there any other specific plugins that you want to see tested? Should we focus on tests with more users, more posts in the blog, more comments? Please comment on this post and tell us.

 

(click here for part 2)

 

 1 2 Next →