Drupal 8 performance: the Supercache module
Drupal 8 performance: the Supercache module
The Supercache module is the result of an attempt to improve Drupal 8 efficiency when dealing with cache tag management and other design issues with several caching components that make it a pain to deal with Drupal 8 based applications that change a lot.
An out of the box Drupal 8 install will issue about 2,100 database statements for a simple task such as performing a log in and creating two articles.
With a little setup and the Supercache module I was able to bring that down to 240 statements.
Here is a video proof that these numbers are real. The statement count is being measured real time thanks to the awesome SQL Server Profiler tool.
The impact of the Supercache module - that was for a while a core patch - was benchmarked and proved to reduce wall times by about 25% and database queries by as much as 50% after things change (doing a cache write).
How does the Supercache module do this?
- Drupal's cache system got heavier in Drupal 8 at the expense of making it more precise thanks to cache tags. But there are situations where you simply do not need all that bloatage. The Supercache module introduces a new and sleeker cache layer (of course without cache tags). A simple cache tag stored in Drupal's cache system takes up 196 bytes. The new caching system only uses 12 bytes. This does not seam like a big deal after all, it's just a few bytes difference. But it translates to being able to store 65,000 cache tags in 1MB of APCu/Wincache instead of just 5,000, But that is not the only advantage of this cache layer:
- Reduced storage size, up to x12 less for small cache items.
- Levarage native functionalities provided by most storage backends such as touch, counter, increment, etc.
- Faster processing due to lack of cache tags and other extras.
- Scalar types are stored natively so you can batch operate on the cache items themselves if the storage backend allows you to do so (database, couchbase or mongo)
- Drupal 8 introduced the very useful ChainedFastBackend (that you can easily use in Drupal 7). But the current implementation of that backend has some design flaws - such as invalidating the whole fast backend when doing a cache write or not using cache tags in the fast backend. Supercache replaces the ChainedFastBackend implementation with one that solves those two issues improving hit rates in the fast backend on systems with lots of writes.
- Replaces the default cache tag invalidator services (that works directly on the database) for one that leverages a similar concept to the ChainedFastBackend.
- Introduces the ability for the key value storage to work similarly to the ChainedFastBackend.
To properly leverage what the Supercache module has to offer you should setup support for a centralized caching backend such as Couchbase
Comments
Wim Leers replied on Permalink
Core issue: https://www.drupal.org/node/2611400.
AwildaHarrison replied on Permalink
This an awesome site. Well, I was searching for some related topics and i found you site. When read, i found this to be far much interesting and i shared all this post to my friends to get in it. I would like to get much more informative posts there by. Hope to get much info's, thanks much for sharing such an informative stuffs.
Add new comment