Skip to content

Magento 2 – Empty API call performance

I would like to know how you are doing either locally or ideally in production on an empty (rest or graph I guess) API call.

Basically, how much time does Magento take to just load without even doing any real logic.

For example if I take the endpoint /V1/cmsPage/:pageId.
I modify vendor/magento/module-cms/Model/PageRepository.php:getById($pageId) and I just die in it without doing anything.
It can work with any endpoint.

In production it will take about 280-320ms on a Magento 2.4.6. (PHP 8.1)
Another test I did, if to just call time php pub/index.php, I have better results (240-255ms) due to the fact less things are loaded I guess.

I know I can cache some endpoint results into a Magento cache or fastly or whatever, it does not change the fact that at a moment, this call will take at least 300ms.

I would like to know how you perform and if you have ever tried to lower this Magento initialization (did you try to modify directly the framework, use JIT for PHP etc…)

Thank you in advance 😉