Behold WordPress, Destroyer of CPUs

With respect to your comments about why caching is not part of the WordPress base install, one wonders (well, I do anyway) how wordpress.com is configured. They must have at least a few sites there that get hammered pretty viciously. I vaguely remember the team saying they had learned a lot from building out the site and that those insights would be folded back into the redistributable software. Did that ever happen?

I’ve set up tons of WordPress installs and this hasn’t been my experience so I have to assume it has something to do with your system.

“Our Drupal site has a minimum of 200 database requests on each page and some have more than 500.”

@AndyT: Why!?

Bad Behavior is an anti-spam, not a caching, plugin and is notorious for eating up CPU itself.

Your biggest problem is you OS. There is an OS called ubuntu, and I hear its much better.

@Linus: Mmmm, no thanks. Windows OS works fine for me.

[sentax]
As some people have mentioned that it may be the database back end that is causing the CPU spikes, I was researching web hosts a month ago and I wanted Windows server with Wordpress, all of the hosting companies I found didn’t offer it. I couldn’t make Wordpress work on a Windows setup because they offered only MS SQL Express instead of MySQL which if you know Wordpress only works on MySQL. So in order to get Wordpress I would of had to use a Linux account with Wordpress, then MySQL would be included in that account and then I’m good to go with Wordpress.

I’m thinking maybe this is how hosting companies are getting around the Windows+Wordpress performance problems, or maybe it’s just the WP-Cache they don’t know about? They are avoiding the CPU problem by only offering a certain setup to run on their servers.

Makes me wonder.
[/sentax]

Jeff, you didn’t mention whether you were using MySQL or MSSQL, but assuming the former you should definitely enable query caching there for some potentially huge gains. We have a jsp app doing 20-30 queries per page load on ~300,000 row tables, and enabling the query cache improved performance by an order of magnitude (once the initial queries were cached, that is). The relevant variable to google is “query_cache_size”.

There are a lot of other tuneables for MySQL too, but nothing else made nearly the difference that the query cache did.

Have you looked at DasBlog? It is a .NET solution…

My blog is not exactly a world-beater but it gets descent traffic and WP2.5 barely registers on my CPU load. I’m running it on FreeBSD on an ancient Celeron box with 256MB of RAM! I really think the problem here is that Windows is not a great platform for running PHP on.

I’d suggest going LAMP and then re-running your tests. I think you’ll be surprised by the difference.

Bart.

The advantages of serving dynamic content are really only useful with dynamic content. A lot of what WP does could and should be done statically.

But that’s considered evil and wrong and would be too much like MT. Matt’s hinted as much previously.

Which is made all the more amusing that folks will go to great lengths to make as much content as static as possible (which is what caching tries to do) in order to gain some control over CPU usage.

And the built in caching that was trialled a few versions back now just didn’t work right with dynamic db calls, causing borkage and pain to anyone crazy enough to try using it.

WP has some very inefficient db calls - that’s really where a lot of the CPU load is. They’ve tried to improve it too, but the moment a handful of plugins or widgets are enabled the db calls become crippling.

It’s still a big problem. Add load to that and WP won’t cope. Not without some serious iron. db caching and PHP accelerators can help mitigate a lot of that.

Interesting stuff. I have a little WordPress blog; in fact, it is my website. With photo galleries and the works. Love it. But yes, the code is a nightmare: I thought it was just me, because I hate hate hate PHP. But you have to dig into some pretty hairy code just to do simple modifications to the templates.

As for CPU issues… I’ll let my provider deal with that. I never heard of any issues before. But I was also kind of under the impression that WordPress didn’t scale well, because I’ve never seen any major sites using it.

You should try linux eco system.

“And really, all of the Apache/Linux vs Windows comments completely miss the point – the difference between the two OS’ is almost invisibly small relative to the gross inefficiency of Wordpress in a default install.”

While in all cases a poorly-written program will have a more significant impact on its performance than which operating system it’s running on, there are two important differences between Linux and Windows that I can see will make a difference here.

  1. Windows memory management is broken. It puts all sorts of data into its page file even when there is lots of free RAM remaining. This can be an especially bad choice if you are caching content to RAM or are using a database with a large memory footprint. The Linux kernel comes configured out of the box pretty well, but you can also manually adjust the kernel’s swappiness to determine when it swaps RAM data to disk.

  2. Windows virtualization is immature and has very poor I/O performance. On Linux you can use Xen to achieve virtualization with very little overhead. A poorly performing VM will kill performance for most programs. It’s even worse with Windows running on top of Windows when you factor in the poor memory management from my previous point. Virtual Server and VMWare Server are almost unusable for anything more than a development setup.

I run 30 wordpress blogs… Everything was fine when they all did less than a 100 hits a day. When they hit 1000 hits a day my host informed me that my CPU was at a constant state of 100%.

Using Caching my CPU is now at an average of 18%… And my blogs doubled in traffic since people don’t have to wait 30 seconds for a page to load.

I use Drupal extensively at our company and I love it - clean, well documented code, great features, great community, and fantastic flexibility.

That said, a standard Drupal 6 installation with no custom modules runs about 60 queries per page view. My local PC that I use to develop:

Executed 59 queries in 114.35 milliseconds

Just to view the front page. An actual site that we run runs 100s of queries per page view, in less than 500ms.

Now, my attitude is that while it would be better to run very few queries per page, it is entirely immaterial if pages render quickly and reliably. My biggest site gets 500 uniques a day, so I am yet to experience any major growing pains. Drupal seems to scale brilliantly, with some VERY big sites running on the system without any high-profile performance issues.

The point I am trying to make is that I think developers can get very narrowly focussed on the ‘proper’ way to do something, when all that really matters is the result. I am as guilty as anyone. Your users don’t care that you managed to serve them a static cached version of the page, they just want the site to load quickly and work reliably.

WordPress is ugly as sin under the hood, but I think it has proven itself as a very, very capable blog platform. Similarly, a purist would say Drupal is a terrible platform because it runs 100s of queries where perhaps a few would do. But, it is easy to maintain, easy(ish) to use, and creates great sites.

Saying that a platform that runs 10s or 100s of queries is straight ‘bad design’ when the evidence suggest otherwise is simply elitist.

OK, so it’s just my home computer, but I installed Appache, MySQL and PHP on Windows XP … then I switched over to Ubuntu.

Apt-get and the synaptic package manager made installation much easier than I was expecting.

I found that the Linux versions of applications seemed to have fewer bugs (stored procedures didn’t work in the Windows Version of MySQLAdmin).

The HowTos had command lines that I could copy and run under Linux.

L-A-M-P, they were designed to work together, so I asked myself, why only go three quarters of the way into open source?

I can’t believe you called the developers of word press sloppy. Just because YOU have a requirement that they didn’t meet. (Out of the box, super fast, ready for digg running on windows)

Wordpress is one of the best blog engines out there because it is configurable and has an awesome ecosystem.

I would say that sloppy is just setting something up quickly and assume it can handle high load without tunning. (And running PHP on windows? come on!)

I too wish wp-cache were built into Wordpress and more easily configured. Wordpress has so much going for it but issues like this make me want to run Serendipity - http://www.s9y.org - and other blogging platforms.

Why don’t you vote with your choice of blogging engines and pick a “better” one?