[英]Elixir requests slow in docker with phoenix code reloader on
I currently use docker-sync but it crashes a lot when changing branches when lots of files change. 我目前使用docker-sync,但是当更改许多文件时,更改分支时会崩溃很多。 I am trying to find a way to get everything working without it just using volumes, but I am running into the typical Mac volume performance issues. 我试图找到一种在不使用卷的情况下不使一切工作的方法,但是我遇到了典型的Mac卷性能问题。
With this configuration I have everything running fast inside the container, however, when the code reloader is enabled, every network request is slowed down (I'm guessing because it is scanning the entire directory). 通过这种配置,我可以使容器中的所有内容运行得很快,但是,当启用代码重新加载器时,每个网络请求都会变慢(我猜是因为它正在扫描整个目录)。 Is there a work around for this that will still recompile changes? 是否有解决方法,仍然可以重新编译更改?
version: '3.7'
services:
phoenix:
image: us.gcr.io/zipbooks-157701/phoenix
volumes:
- ./phoenix-api:/app/phoenix-api:delegated
- /app/phoenix-api/deps/
- /app/phoenix-api/_build/
environment:
DB_PASSWORD: root
DB_HOSTNAME: mysql
TESTING_DB_HOSTNAME: mysql
REDIS_HOST: redis
depends_on:
- mysql
- redis
...
There are two things: the code reloader, which compiles your code on every request and the live reloader which scans your filesystem for changes. 有两件事:代码重载器,它会在每个请求时编译您的代码;以及实时重载器,它会扫描文件系统中的更改。 The code reloader should be as fast as calling mix compile
. 代码重新加载器应与调用mix compile
一样快。 The live reloader is fully optional (it is just to reload via websockets). 实时重新加载器是完全可选的(仅通过websockets重新加载)。
If the issue is in the live reloader, you can either remove it or you can restrict the directories it watches for performance. 如果问题出在实时重新加载器中,则可以将其删除,也可以限制其监视性能的目录。 See the relevant note in the README: https://github.com/phoenixframework/phoenix_live_reload#backends 请参阅自述文件中的相关说明: https : //github.com/phoenixframework/phoenix_live_reload#backends
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.