⬆️ ⬇️

Basic performance. Make Drupal fly. Part I

Basic performance.  Drupal .  I



Hello! Let's talk about the performance of the popular CMS / CMF Drupal, namely about the 7th version.



Many not-so-experienced users scold Drupal for being slow. Like, for each request Drupal is always loaded entirely, loading all-all-all its modules. In general, they may be right; Drupal has such a problem, but it is solvable.



In Drupal, almost all the content that is intended for visitors is an entity, whether nodes, users, or taxonomy terms. Let's start with them.

')

We generate 1000 users with the help of the devel_generate module, which is included in devel and we measure the time of their loading from the database.



image



From the example it can be seen that this operation takes 30 seconds, which is actually not very good. Well, just for this case, Drupal has its own system for caching entities. Let's look at it in work.



image



When you restart these users are loaded in 2 seconds, well, well done Drupal, but you can and better.



Download and enable a couple of modules ( Entity cache and Memcache ).



The Entity cache module allows you to cache standard Drupal entities using the Cache API.

Memcache provides the ability to transfer the care of the cache from MySQL to the Memcached server, which stores data in RAM and therefore works faster with them.



image



And - right away success, the first run is performed in just 2.8 seconds instead of 30. Go ahead.



image



A restart in which the data is retrieved from the Memcached server's cache is performed in 0.4 seconds. Not bad compared to default caching in Drupal.



However, Memcached is not the only one Redis can do such things.

Disable the Memcache module and install the Redis module.



image



The first launch is again long, because the cache is first formed. The result - 2.2 seconds, while this is the best result.



image



0.35!



Thus, we achieved an increase in performance of 13 times in the case of the first run and 5 times in the case when the data is taken from the cache.



Unfortunately, it is not always possible on the hosting to install an additional Memcached or Redis server. In this case, you can do only the module Entity cache.



image



The first request is executed for quite a long time. This is again related to cache generation.



image



But all subsequent runs in less than a second.



From this we can conclude that the Entity cache module is a must have module on any Drupal site. Based on its capabilities, it can be supplemented with Redis.

Source: https://habr.com/ru/post/243615/



All Articles