PHP 7.4 introduces the opcache preloading function. Its meaning is to load all the necessary scripts into memory at the stage of starting the PHP daemon. Let’s see if this feature is worth using in Magento?
The guys from the community created an issue in the Github for this feature to be supported.
But for some reason Magento did not support it, I wonder why? Let’s go and see what the enthusiasts did on this topic, how it should look like
https://www.cloudpanel.io/docs/cloudpanel-ce/guides/php/opcache-preload
Here the guys at the very top write that it is “a feature that improves the application start performance up to 60%“. This means that the indicated performance gain will be only at the start. Next, we see an example for the Magento and the code that needs to be written and parameters in the php.ini:
opcache.preload_user=magento
opcache.preload=/var/www/html/preload.php
The code for Magento itself can be found there.
So what do we see? It is necessary to put and write additional code for the sake of increasing performance at startup. But after launch, the very first request will load the necessary scripts into the opcache memory anyway! And on the second request, they will already be loaded not from disk, but from memory.
Thus, this feature does not make any sense at all, and most likely that is why the guys from Magento refused to support it. Moreover, additional bugs may surface there that you will have to fix, but you definitely do not need this.
I tested the performance of Magento 2.4.2 with preload enabled and disabled, the result is the same. To check, I used the wrk utility.
One reply on “PHP 7.4 preloading feature for Magento”
https://github.com/MonogoPolska/monogo-m2-preload
I think this will helpful for magento2