The WordPress/bbPress Performance Limit
I’ve learned a lot about WordPress code over the past few years but even more so after working with it’s forum spinoff bbPress. A few things about WordPress/bbPress performance became obvious when I starting noticing that another plugin developer’s forum running SMF was running considerably faster than bbPress and WordPress on the same poorly performing host. I took SMF apart to understand why and here’s what I found:
WordPress cannot (in theory) be made much faster, unless entire pages are made static with a caching system and it’s core is not even loaded for the visitor. It’s simply a limit of WordPress’s architecture and would require an entire rewrite to change. If you have mysql caching turned on and an opcode cache (apc, eaccelerator, xcache, etc) that’s the most you can (easily) do before solutions like wp-cache.
The reasons why include:
1. dozens upon dozens of files that have to be included before any page rendering can begin. Other blog/cms software tries to keep this number down but in WordPress it’s almost runaway. Even an opcode cache must check the timestamp on the source files so the filesystem is kept constantly busy – if it’s not in the filecache, there is a performance hit. If it’s being rendered on a different server from where the files are stored (like on Dreamhost and others) there is even more of a performance hit.
2. Each plugin is a separate file that is not a direct mod on the source but an additional include that is required to load and more code to execute. All plugins are loaded regardless of what kind of page is being rendered. See above why this is a problem. Your WordPress setup can easily be requiring near 100 files to load and 500k of code to execute before a single character is output.
3. All output goes through a language translation hook. Even if you are using the default language this will always be slower than direct output.
4. Output is done in bits and pieces with typically no buffering done (ala ob_start) to accelerate and smooth this process. Any programmer should know from experience that outputting a few characters at a time, 1000 times is far slower than storing them all up in a string and dumping the few thousand all together at once at the end.
All these weaknesses can also be found in bbPress (the forum software that is based on WordPress architecture). Maybe oneday a great mind will come up with a magic, backwards compatible speedup solution without rewriting the core but I doubt it will be any time soon.
Despite these weaknesses, on a single dedicated or VPS server with proper resources, proper opcode, mysql and file caching, WordPress (and bbPress) can give just about any other blog/cms software a run for it’s money. The problems begin when these performance solutions are simply not available on a shared hosting server.
ps. I’ll also note that I am not abandoning WordPress or bbPress anytime soon. The benefits of their plugin architecture far outweigh the server performance requirements. Another method for speedup that I did not mention is that replacing apache with lighttpd or litespeed which can also be a big benefit but of course that is much more work than simply turning on the mysql cache and installing an opcode cache.