Laravel 在 kubernetes 上 - 缓慢的作曲家供应商自动加载(生产)

Laravel on kubernetes - slow composer vendor autoload (production)

我们已经在 google 云平台上为我们的 laravel 应用程序设置了一个 kubernetes 集群。 容器:

(我们 运行 在 nginx-ingress-controller 下,但这似乎与问题无关)

我们 运行 在一个简单的 laravel 路由 returns "ok" 上进行了 jmeter 压力测试,我们注意到响应时间很糟糕。

之后我们 运行 在 index2.php(在 public dir το 滑过框架内)上进行相同的测试,只是 returns 'ok'。

我们得到了这个结果(!):

经过深入研究,我们发现作曲家的自动加载导致了这种缓慢。

任何有关如何解决此问题的建议将不胜感激。

谢谢

好的。我们发现我们没有启用 opcache。 正如关于 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.