making bbPress (and WordPress) work better!

bbPress Benchmark, performance diagnostics

I’ve made another bbPress plugin, this time to benchmark and diagnose performance problems in page load times – bbPress Benchmark.

It is based on Jerome Lavigne’s Query Diagnostics for WordPress but I have taken it much further in what it measures (plugin & template load times, etc.) Here’s the story of why I created it:

Recently I set up yet another bbPress forum to for public testing and to showcase my plugins. I went with a very low cost host on purpose as I don’t expect much traffic. So it costs for a year what most people pay for a month to host their WordPress blog or bbPress forum.

What was not unexpected is the host uses heavily loaded servers so responsiveness is much lower than the high speed VPS I am used to. It also was missing some features (caused by safe mode). They also use squid caching which works against dynamic pages, so no http 1.1 chunked output which means no visual queues that a page is loading. But what a perfect opportunity to discover the weaknesses in how WP & bbPress work since things were in “slo-mo”!

Pages that took less than 100ms to create on my high end VPS take over 500ms on this host, sometimes even 900ms if there is high load (not transfer time, page generation time, transfer time gets added to that as 1-2 seconds).

I thought for certain the culprit was going to be slow mysql performance. Guess what? Based on BB-Benchmark I can now say the slow time is because of plugins loading, not mysql! Mysql was always under 100ms. But two dozen plugins take 200-400ms to load EACH TIME a page is displayed.

Now I am left wondering if that is PHP execution time or simply because the shared host’s disk is so busy that the two dozen files take that much time to be found and read. Probably so, because if I do a hard refresh right after the first load, it’s much faster. So it’s in the disk cache. But wait 10-15 minutes and the cache has moved on to the other thousand clients they must have on there, so it has to seek and load again.

More detective work is needed so I can figure out how to prove this. I wonder if it makes sense to somehow store activated & working plugins into mysql and then pull them all out of there instead of the raw disk. They are obviously using a seperate mysql server that is much faster than the local drive. I don’t even know if PHP can be loaded from mysql or if that is even safe – I will have to investigate!

Update: Yup, I think I am onto something:
=== benchmark & query results ===

total page time: 2.142 seconds.

time to reach each section:
bb_underscore_plugins_loaded = 0.496
bb_plugins_loaded = 1.708 <<<<------------------ see ???
bb_init = 1.744
bb_index.php_pre_db = 1.780
bb_index.php = 1.802
front-page.php = 2.037
header.php = 2.056
logged-in.php = 2.085
footer.php = 2.121

time to render page: 2.1116 seconds (query time subtracted)

total query count: 11

total query time: 0.0304 seconds

slowest call was # 1 : 0.0137 seconds
SELECT meta_key, meta_value FROM bb_topicmeta WHERE topic_id = '0' server:dbh_local connect: 5.58ms

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s