Use Watir for automated web application testing and load testing

Posted by . is an open-source Ruby library for automating web browsers. You can use it to run automated tests on your web application or even to load test your application.

I haven’t used it yet but I can see how it could be useful, running a number of concurrent browser threads on a VPS, performing a set of actions on your website/app, putting it through it’s paces, even triggering Ajax requests. You could have Watir running on a cluster of machines and really challenge your website.

If I ever put it to good use I’ll be sure to write about it further.

A couple useful links: someone talking about using Watir for load testing examples of Watir usage

XHProf call graph for a WordPress homepage request

Posted by .


I’m currently looking at using XHProf to profile WordPress performance on our hosting. It’s the first time I’ve really looked at the call graph generated by XHProf. It’s a crazy data visualisation that lists all function calls, it’s probably only of any use if it’s projected on a large wall in high definition.

Click on the graphic to take a look at a larger version. It’s not full size as that was going to be something crazy like 10,000 pixels wide.


Hide admin menu items on a WordPress site

Posted by .

This code hides the admin menu items for all users that don’t have the ‘manage_sites’ capability.

On multisite that would mean only Super Admins can look at those menu items.

This script only removes the menu items (so users can still look at the page if they know the path) but it de-clutters the admin somewhat, making it a little easier on beginners.

WP-cron debug test – Add a WordPress cron event to email server variables every 2 minutes

Posted by .

I had to debug some issues today with a couple of scheduled posts not being published on time and showing “Missed schedule” on  a multi-server setup.

I thought it may be something to do with WP-cron so put together the below code to add a new cron event to email me PHP server variables every 2 minutes. It can easily be edited to email other information to help you debug cron issues.

A cheaper alternative to for load testing

Posted by . is a great alternative to using for load testing.

With they take care of the software and servers distributed globally for generating the load. You just pay for the pleasure! Realistically if you are load testing you want to generate substantial load. There lowest package for load testing a site that may get 10,000 visitors a month you can do for free. But to generate load to test your server you’ll really want their next package with is equivalent to getting 100,000 visitors a month and costs $225! Now if you’re planning a highly popular website you’ll probably be pushing 1,000,000 visitors a month, well that’s going to cost you $2,100!! It’s a great service but I can’t justify spending that every month on load testing (and you’ll probably have to pay for bandwidth charges through your web host so that’s even more cost). have a paid (pro) service that also costs quite a bit but they also have a lite option where all you do is register and then download the software. With these guys you install the software on one of your own servers (or a PC somewhere) and then run and configure the load test your self. The advantage here is you can run the load tests from a server within your network which means in most cases there is no bandwidth charge. If you want to test some serious numbers or just want to distribute your load test over a number of servers you can either distribute this over the cloud using Amazon EC2 (for a nominal charge) or you can install the load engine component on you’re own servers in any data center.

Even the lite option is good for 1,000,000 concurrent users! You would need a mortgage to achieve that with LoadImpact.

To configure the load test you basically browse your site and the software keeps track of everything you download and access. Then all of those actions are replayed during the load test.

There are some limits to the lite option but it’s a pretty good alternative (I’m not sure if you can use SSL and I definitely know you can’t use ajax).

Here is an example report I exported the other day and saved as a PDF - some items are reserved for the pro version but there is plenty of information there for my needs.

You’ve heard of a brain dump, well this is a Chrome dump.

Posted by .


Looking up at the top of my browser I seem to have quite a few tabs open. About a third of theme have been open for a few weeks, another third have only been open since yesterday and the other third only open since this morning.

I’ve got some interesting content open (well I think it’s interesting) so I thought I’d get it down in a blog post. Sort of like a brain dump but instead of dumping the stuff out of my brain I’m dumping the stuff that’s currently open in my Chrome web browser.

Sharing a Memcached server between multiple WordPress sites (key problems)

Posted by .

If you use Memcached as an object cache for your WordPress site and you have many sites sharing a Memcached instance you may encounter problems. All down to WordPress and the Memcached object cache plugin you use creating duplicate keys. The W3 Total Cache plugin has a problem with this and so does this Memcached plugin.

The dedicated Memcached plugin has some fixes for this but they aren’t yet pushed to the repo version of the plugin. So download the object-cache.php file directly from trunk/Trac.

This is another one of those blog posts that’s a reminder for my self as much as info for anyone else…

A support forum entry for that plugin problem and fix.

Data visualisation with D3

Posted by .

I use graphite to keep an eye on various web server stats such as processor usage, failed web server requests etc. Although the dashboard you get with Graphite works pretty well I’ve been looking for an alternative dashboard for some time. A while back I found Graphene which looks like an improvement on the Graphite dashboard but I’ve never used Backbone.js which it’s built on, and all you have is time series and gauges, and it’s just too dark for my liking so I never used it.

I was going to knock up my own dashboard system and use the Google chart tools API but thought I’d quickly just check for some alternatives.

D3 looks awesome. Not only can you create some really cool graphs but you can also do all sorts of data visualisations. Problem with D3 is it’s a little too low level (for my lazy ass) so each graph I want to make wouldn’t exactly be a 5 minute job.

Then I found NVD3, which gives you a pretty decent range of chart components for D3.

There is also Cubism which also uses D3 but it only gives you time series. The other thing Cubism does is integrate with Graphite. So there may be some useful code that I can merge with NVD3 to easily create a new dashboard for my Graphite data and ease me into using D3 and SVG in general.

Rackspace server bandwidth cap data and extreme costs

Posted by .

Over the past few days I’ve been doing some capacity planning for the WP Sites hosting setup and as part of this I had to revisit the Rackspace cloud throughput limits. When you try to squeeze out every ounce of performance from say a 1024MB cloud server it’s quite easy to forget (Rackspace don’t actually shout about it) that each server instance has what looks like a pretty stingy bandwidth pipe.

A 1024MB cloud server is limited to 30 Mbps on it’s public interface which doesn’t sound like a lot and each time I look at those numbers I panic thinking I’m going to have to find a new provider without those limits, if you think about it a little further 30 Mbps is quite a bit.

30 Mbps is equivalent to 225,00 MB of data every minute. If we go by the average webpage size being 1.5 MB that’s 150 pages per minute, or 2.5 pages per second (this is obviously simplified, no browser cache or anything like that taken into account). Even an un-optimised server should easily serve up 2.5 WordPress pages per second and in you kept that up constantly it could set you back £1,195.56 in bandwidth charges per month! So based on 2.5 pages a second that’s 216,000 visitors a day costing you a total of £1,195.56 in bandwidth charges at the end of the month. (more…)