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

标签 php macos laravel docker boot2docker

在 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/

相关文章:

php - 'safe' json_decode( ,,, ) 以防止耗尽内存

git - 名为 'Icon' 的神秘 git 分支

laravel - Laravel 5.3+ 中的 Route::controller() 替代方案

java - -bash : syntax error near unexpected token `('

macos - 如何在更改边界的动画期间强制重绘 CALayer

laravel - 通过 artisan 和composer 安装之间的区别

php - 如何从 View 中使用模型函数? - 拉维尔 5.4

php - 如何防止玩弄人们每天可以投票一次的投票系统?

php - 防止 Laravel 5.5 中 3 列出现多个值

php - 从 WooCommerce 可下载产品访问可下载数据