简体   繁体   中英

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. 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.

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 . The live reloader is fully optional (it is just to reload via 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM