gpt4 book ai didi

php - Docker 容器中响应时间缓慢 : Laravel 5. 2

转载 作者:可可西里 更新时间:2023-10-31 22:52:31 28 4
gpt4 key购买 nike

在 PHP-7 docker 容器中运行 Laravel 5.2 时,我得到的响应时间为 300ms - 400ms

这非常慢,但如果我只是在同一个容器上回显 phpinfo(),响应时间是 15ms - 50ms 有没有人经历过这些缓慢的响应时间在 Docker 容器中使用 Laravel?

最佳答案

为了其他任何通过谷歌偶然发现这个问题的人的利益,Docker for Mac 现在支持 user guided caching对于卷。

Different applications require different levels of consistency. Full consistency is sometimes essential, and remains the default. However, to support cases where temporary inconsistency is an acceptable price to pay for improved performance, Docker 17.04 CE Edge includes new flags for the -v option:

  • consistent: Full consistency. The container runtime and the host maintain an identical view of the mount at all times. This is the default, as described above.
  • cached: The host’s view of the mount is authoritative. There may be delays before updates made on the host are visible within a container.

为我的 Laravel 应用程序启用缓存模式就像更新 docker-compose.yml 中的卷引用一样简单。

之前:

    volumes:
- ./:/var/www

之后:

    volumes:
- ./:/var/www:cached

进行更改并重新创建我的容器后,我发现性能更符合我对非虚拟化本地服务器的预期。以前一个简单的请求需要 1.3 秒才能完成,现在已降至 0.35 秒。尽管警告说主机更改可能不会立即在容器中可见,但我还没有注意到任何传播问题。

还有一个关于 Docker Mac FS performance 的持续 GH 问题附上一些有用的注释。

关于php - Docker 容器中响应时间缓慢 : Laravel 5. 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35305230/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com