Is Drupal 8 really faster than its predecessor?

I have been told recently that the times when Drupal 8 was slow passed long ago, that increased number of abstractions in Drupal 8 doesn’t affect its performance, and that Drupal 7 hook system worse than Drupal 8 events in terms of speed. When I don’t believe, I measure and encourage others to do so.

Alright, let’s benchmark Drupal 8 and Drupal 7 one more time.

The environment

- Bare metal, Ubuntu, Nginx 1.10, PHP 7.1, MariaDB 10.1.

The methodology

- ApacheBench (ab) tool (what could be simpler)
- ab -n 1000 -c 100 for all experiments
- Each experiment should be taken five times (the average value goes into reports)

Examples of ab commands:

# Anonymous:
ab -n 1000 -c 100 http://drupal7/user
#Authenticated:
ab -n 1000 -c 100 -C auth_cookie_key=auth_cookie_value http://drupal7/user/1

I use Chrome Dev Tools -> Application -> Cookies to get the auth_cookie_key=auth_cookie_value pair.

The subjects

Configuration 1: Pure code performance

  • Minimal profiles
  • Disabled cache and asset aggregation
  • Enabled Bartik theme for Drupal 8 (to match Drupal 7 default theme)

And here are the results...

rps - number of requests per second (the more, the better)

Anonymous requests to the login page
Drupal 7 Drupal 8
/user /user/login
809 rps 1260 rps
  1,56 times faster
Anonymous requests to a node page
Drupal 7 Drupal 8
/node/1 /node/1
665 rps 1358 rps
  2 times faster
Authenticated requests to a user page
Drupal 7 Drupal 8
/user/1 /user/1
658 rps 259 rps
  2,54 times slower
Authenticated requests to a node page
Drupal 7 Drupal 8
/node/1 /node/1
537 rps 251 rps
  2,14 times slower

Configuration 2: “Real-life” conditions

  • Standard profiles
  • Enabled all built-in caches (expiration: 1 day)
  • Enabled CSS/JS aggregation
  • Generated 1000 Article nodes with tags and up to 10 comments per node (Devel Generate)

Thanks to @marcvangend for encouraging me to test this configuration.

Marc van Gend's tweet about performance tests

Now let's look at the results...

Anonymous requests to the login page
Drupal 7 Drupal 8
/user /user/login
3525 rps 1115 rps
  3,16 times slower
Anonymous requests to the view page of a random node with tags and comments
Drupal 7 Drupal 8
/node/2000 /node/2303
3030 rps 1110 rps
  2,73 times slower
Anonymous requests to the frontpage (node list)
Drupal 7 Drupal 8
/ /
3098 rps 1073 rps
  2,89 times slower
Authenticated requests to a user view page
Drupal 7 Drupal 8
/user/1 /user/1
468 rps 123 rps
  3,80 times slower
Authenticated requests to the view page of a random node with tags and comments
Drupal 7 Drupal 8
/node/2000 /node/2303
279 rps 78 rps
  3,58 times slower
Authenticated requests to the frontpage (node list)
Drupal 7 Drupal 8
/ /
222 rps 121 rps
  1,83 times slower

Conclusion

Although Drupal 8 has demonstrated a performance boost for anonymous requests on Minimal profile without cache, all other experiments have shown that Drupal 8 is still significantly slower than Drupal 7, unfortunately.

A couple of ideas on why you may not feel this difference:

  • PHP 7 is much better in terms of performance. Many people started using it from Drupal 8 because at first Drupal 7 had some compatibility issues with PHP 7. Some Drupal 7 sites are still on PHP 5.
  • Drupal 8’s frontend is better optimized, for example some render-blocking scripts moved to the bottom of the page, so it may feel like the page loads faster.

I understand that the results of my tests may not align with marketing strategies of Drupal service providers and other affiliated people, so I don’t expect you to share this post or thank me. But despite this, I know deep down you appreciate my efforts )