Drupal 6 vs. Drupal 7 Performance (and Comments vs. Nodes)

I’ve been doing quite a bit of work recently trying to improve performance in Drupal 7. This has included both reducing the raw number of queries run per page, particularly those generated by node_load() and drupal_lookup_path(), and also trying to track down some PHP bottlenecks.

In January, I compared nodes vs. comments in HEAD. However there haven’t been any comparisons between Drupal 6 and 7 recently.

To maintain the comments vs. nodes comparison I benchmarked the default front page with 50 and 300 nodes listed, and node/n with 0, 50 and 300 comments listed (and one node of course). This isn’t a very realistic scenario, but it’s useful for seeing the impact of certain changes. There’s been discussion of trying to run continuous automated benchmarks of both HEAD and Drupal 6 – so we can catch performance regressions in a similar way the automated testing suite does now. Hopefully as part of that we’ll see more realistic tests being developed. In the meantime, here’s what I found:

The good news is that we’re spending a lot less time in the database for both nodes and comments in Drupal 7. The bad news is a lot of this is being canceled out by more time spent in PHP.

This is particularly obvious when viewing a single node, where HEAD is a fair bit slower than Drupal 6, but it carries over to long listings too. Viewing 300 nodes takes just over 1 second in both releases on my laptop. In Drupal 6, over half the time is spent executing database queries (700ms), in Drupal 7, we cut that by 500ms, but benchmarks come out about the same.

Times are in requests per second via ab (more requests is better), I’ve also included devel query log results. Note I cheated a bit and applied this patch to HEAD before doing the comparisons – without that there’s an extra query per node.

The extra PHP time is in large part due to much more flexibility in certain parts of Drupal 7 – like passing node contents through drupal_render(). This is good in that we’ve traded performance for flexibility rather than just introduced bottlenecks without a trade-off, but still, work to be done.

Drupal 6 Drupal 7
1 node, 0 comments 15.84
[#/sec] 42 queries in 26.76 milliseconds.
9.29 [#/sec] 39 queries in 25.2 milliseconds.
1 node, 50 comments 4.17 [#/sec] 243 queries in 131.15 milliseconds. 2.60 [#/sec] 91 queries in 50.76 milliseconds.
50 nodes 1.87 [#/sec] 400 queries in 248.76 milliseconds. 2.46 [#/sec] 87 queries in 47.55 milliseconds.
1 node, 300 comments 0.97 [#/sec] 1244 queries in 808.31 milliseconds. 0.87 [#/sec] 341 queries in 152.71 milliseconds.
300 nodes 0.46 [#/sec] 2134 queries in 788.24 milliseconds. 0.50 [#/sec] 337 queries in 271.23 milliseconds.

If you’re interested in improving this situation further, take a look at http://drupal.org/project/issues/search/drupal?issue_tags=Performance for things currently being worked on.

2017-03-31T06:20:24+00:00 Categories: Drupal|

Share this

About the Author: