Magento 2.4.1 Performance Test
Let's profile the new pride of Magento Inc. — The “best of the class: nevest Adobe eCommerce version 2.4.1
Let's profile a production website.
Magento 2.4.1 simple page generation time.
Result: 136 ms.
Magento 2.4 has some core issue there
PHP 7.4 function mdecrypt_generic is slow
Even if lib sodium is installed :
Description of the single stupid Magento config cache takes 45 ms!
You can’t achieve good Magento 2.4+ performance because its core is too broken!
Since PHP 7.1, the mcrypt library was deprecated and removed from PHP 7.2 and it is producing new issues for Magento 2 store owners
The “phpseclib”, used by Magento,
Due to the absence of mcrypt library in PHP 7.2, phpseclib used pure-PHP cryptography implementation which is 45x times slower — that explains why we observe performance degradation.
A logical question here would be, why phpseclib is not using OpenSSL, which is 6.5x times faster than mcrypt and 300x times faster than pure-PHP implementation.
The logic of how phpseclib selects the cryptography backend is very complicated and depends on many variables. Quoting the same phpseclib contributor from GitHub:
If phpseclib is using mcrypt it’s doing so for speed purposes. Either (1) OpenSSL (which is faster than mcrypt) is unavailable or (2) it’s unsuitable for the given algorithm in question (eg. arcfour128 is being used or something; OpenSSL doesn’t support “incremental encryption” as mcrypt did; it can be emulated for block ciphers but not for stream ciphers).
Production 2.3.5 Website profile
simple PHP page generation time: 35ms when M2.4.1 needs 45ms just for stupid encryption.
Magento 2.4+ is 3–4 times slower than 2.3+
Happy Magento journey!