Tania Petsouka
Tania Petsouka

Reputation: 1424

Laravel on kubernetes - slow composer vendor autoload (production)

We have set up a kubernetes cluster for our laravel application on google cloud platform. Containers:

(We run under nginx-ingress-controller but this seems unrelated to the issue)

We run a jmeter stress tests on a simple laravel route that returns "ok" and we noticed terrible response times.

enter image description here

Afterwards we run the same test on an index2.php (inside public dir το slide over the framework) which just returns 'ok'.

And we got this result(!): enter image description here

After digging we found out that the composer's autoloading stuff cause this slowness.

Any advice on how this could be resolved will be highly appreciated.

Thanks

Upvotes: 1

Views: 993

Answers (1)

Tania Petsouka
Tania Petsouka

Reputation: 1424

Ok. We found out that we had no opcache enabled. As documented about composer optimize-autoloader:

On PHP 5.6+, the class map is also cached in opcache which improves the initialization time greatly. If you make sure opcache is enabled, then the class map should load almost instantly and then class loading is fast.

Upvotes: 4

Related Questions