When I started this blog, I was faced with a broad selection of choices for a blogging engine. There's two in my language of choice, ColdFusion. There's countless options in countless other languages. And there's no end to the number of blogging services like blogger and blogsome. But instead I chose to write my own.
You may be thinking I did so for the challenge, or because I had some unique requirements. Not even close. I did it because it's just about the easiest damn web app you can build, and most packages out there are overkill. Even the ones that sell their simplicity. I spent more time building the templates than I did writing the code.
One of my regular reads chose Movable Type for himself, a PHP-based engine which renders static HTML pages — arguably the most effective caching mechanism possible, obviously resulting in zero SQL queries per page, on average.
The same guy set up his next blog using WordPress and got a completely different experience. Out of the box, it's devoid of any caching mechanisms whatsoever — bad at the best of times, but outrageous when it requires twenty SQL queries per page. For a blog.
What is it doing with twenty queries? Sure, you need two to get out the article and replies. And perhaps one to grab related or recent articles. That's three.
Yet this appears to be something of a constant with off-the-shelf web software. Even a simple feature like leaving a behind deletion marker on forum posts is shunned for inviting “too many new queries.” Really? Is it so difficult to modify the core page query to support this?
So this begs the question: what is the typical number of SQL queries per page, for the most popular blogging and forum software?
For the Whirlpool forums, it's two. Actually, it's less than two since most thread listings only require a single query to build the page. This bears out in measurement — when the application is running at its peak time load of 30 pages per second, MySQL is handling 50 queries per second. How can it run with so few queries? I'm tempted to call it good caching, but really it's just good coding practice. The user's permissions are stored in the session scope. The core forum structure is stored in the application scope. Since this information is used on nearly every page, this move isn't just prudent, it's whack-over-the-head obvious.
If you run a forum or blog, I'd love to hear what your queries per page ratio is.
I think it depends a lot on the way your blogging engine is constructed. Mine (http://blog.daemon.com.au/) is built using FarCry Core (a ColdFusion framework: http://www.farcrycore.org/). To initially build a page there are a lot of queries -- its the underlying ORM in action. But once the site is cached it only ever hits the database every now and then to refresh content that has changed and popped the cache.
I've been thinking about redoing my blog (it's currently running BlogCFC), and I think you've practically convinced me to roll my own this time around. Simple and efficient is good.
P.S. There is another 5 or 6 CF-based blogs (http://carehart.org/blog/client/index.cfm/2008/4/30/tools_resource_list_part3), most notably is probably MangoBlog which just went 1.0 recently.
you guys surely need to try 1ssBlog especially with the coming Updater 2 :)
I can say that BlogCFC does itself do quite a large number of queries per page, but Ray has of course used query caching quite a bit so they don't result in real I/O too often.
He gets around the limit (pre-CF8) on using CFQUERYPARAM in cached queries by using his own caching solution. One can find it (ScopeCache), and others, in a category on my tools/resources list (thanks for the shout out, Carter), at http://carehart.org/resourcelists/tools_to_consider/#cache. I should add I'm still running a pretty old version of BlogCFC (5.005), so things may well have changed about the above.
Hey Simon, since this entry is also about how you created the blog yourself, while it does look clean and simple, I'd like to mention a couple things you may want to consider:
- I don't see any link for one to get a feed or subscribe to the blog. I tried and found that it seems no special feed URL is necessary. That's cool, but it's not common. People may not think to just use the blog's URL to add to feed readers or feed-to-email tools like rssfwd.com
- Do you offer a means in your blog for someone to subscribe to comments for an entry, without having to comment?
- Oh, I just noticed: you don't ask us for our email addresses, so we won't get any emails when new comments are written. That's a shame. I realize your going for simplicity, but this seems an unfortunate loss of functionality.
- And since some don't know about feed readers, have you considered an option for people to subscribe where you'll send them emails as new entries are written?
- Do you offer a link anywhere with more info on yourself? People reading your blog may want to know more about you. :-)
- Once you have more than the current number of entries (several), it will help to be able to search among the entries, as well as to scroll back through months. Are you considering such things?
Again, not knocking the blog. And maybe you've given all these things thought and decided to jettison them in the name of simplicity. Just thought it might be helpful to share my observation as a user. :-) Keep up the good work.
Quick note: Movable Type's core is in Perl, but uses PHP for it's dynamic archives feature (if enabled)
My blog software uses 7 queries out of the box:
1) SHOW TABLES LIKE 'bt2_site' (used to check if it is installed)
2) SELECT config_name, config_value from bt2_site (loads site configuration)
3) SELECT session_data FROM bt2_sessions WHERE session_id = ? LIMIT 1 (loads session information)
4) SQL for getting posts
5) SQL for getting user permissions
6) SQL for getting categories
7) SQL for updating session information
The software can be found here:
http://www.bluetrait.org/ (Bluetrait 2 Alpha 3)