简体   繁体   English

Elixir在phoenix代码重新加载器打开的情况下在docker中请求变慢

[英]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.

相关问题 Docker +旧版本的Elixir / Phoenix - Docker + older version of Elixir/Phoenix Dockerized Phoenix / Elixir应用程序拒绝所有HTTP /套接字请求 - Dockerized Phoenix/Elixir App Rejects All HTTP/socket requests 如何在 Heroku 上创建/迁移 Elixir Phoenix Docker 镜像? - How to create/migrate Elixir Phoenix Docker image on Heroku? 在Docker中使用Erlang Observer App和远程Elixir Phoenix服务器 - Using the Erlang Observer App with a remote Elixir Phoenix server inside Docker 无法从Docker中的elixir / phoenix连接到SQL Server - Can't connect to SQL Server from elixir/phoenix in Docker 如何使用 Phoenix Guides 中的示例在生产模式下运行 Elixir Phoenix Docker? - How do I run Elixir Phoenix Docker in production mode using example from Phoenix Guides? Docker上的Erlang / Elixir和热代码交换 - Erlang/Elixir on Docker and Hot Code Swap 如何使用 elixir phoenix 版本和指南中的示例 MyApp.Release.rollback 在 docker 容器中回滚数据库 - How to rollback database in docker container using elixir phoenix releases and the example MyApp.Release.rollback in the guides 无法从 Phoenix Elixir App 到达 RabbitMQ broker 到 RabbitMQ Container Docker - Unable to reach RabbitMQ broker from Phoenix Elixir App to RabbitMQ Container Docker Sinatra :: Reloader无法在Docker容器中重新加载文件 - Sinatra::Reloader not reloading files in Docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM