泊坞窗 - 缓存挂载音量同步延迟

我正在使用docker撰写本地开发环境在macOS上撰写。我们有多个用php编写的应用程序,并且可以与Symfony一起运行。代码通过卷附加到容器上。与Linux主机相比,我遇到了非常差的性能问题。泊坞窗 - 缓存挂载音量同步延迟

事实证明,问题是由基于osxfs(一种共享文件系统解决方案,专门用于Mac的Docker)的挂载卷导致的。

问题是很好的解释在这里:https://blog.docker.com/2017/05/user-guided-caching-in-docker-for-mac/

性能大大提高,引进安装卷的缓存模式后。但是,它允许在主机上的更新出现在容器中之前出现一些延迟。文件没有具体说明这个延迟。你知道主机上的代码和容器内部的代码之间的同步有多快?

volumes: 

- ./php_code:/var/www:cached

回答:

  1. 使用NFS(不与高塞拉利昂工作 - more details here)

泊坞窗机,NFS $ {} DOCKER_MACHINE_NAME --mount-OPTS = “noacl,async,nolock,vers = 3,udp,noatime,actimeo = 1”

  1. 让您PHP缓存容器内 - 例如在/tmp/app_cache/* - 或者内存/dev/shm/app_cache/*(不推荐)

要保持容器改变内部缓存中的AppKernel.php(用于Symfony的4.0 Kernel.php

...  

public function getCacheDir()

{

if ($this->environment === 'env') {

// Store in RAM.

// return '/dev/shm/symfony_docker_test/cache/'.$this->environment;

// Store in docker container (not docker-machine unless docker-compose volume is mounted).

return '/tmp/symfony_cache/cache/' . $this->environment;

}

return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();

}

...

结果与解决方案提到和:cached

Time taken for tests: 20.396 seconds 

Complete requests: 100

Failed requests: 0

Total transferred: 82700 bytes

HTML transferred: 31900 bytes

Requests per second: 4.90 [#/sec] (mean)

Time per request: 203.963 [ms] (mean)

Time per request: 203.963 [ms] (mean, across all concurrent requests)

Transfer rate: 3.96 [Kbytes/sec] received

结果与解决方案提到而不:cached

Time taken for tests: 18.911 seconds 

Complete requests: 100

Failed requests: 0

Total transferred: 82700 bytes

HTML transferred: 31900 bytes

Requests per second: 5.29 [#/sec] (mean)

Time per request: 189.111 [ms] (mean)

Time per request: 189.111 [ms] (mean, across all concurrent requests)

Transfer rate: 4.27 [Kbytes/sec] received

以上是 泊坞窗 - 缓存挂载音量同步延迟 的全部内容, 来源链接: utcz.com/qa/258558.html

回到顶部