ecamp3 icon indicating copy to clipboard operation
ecamp3 copied to clipboard

docker-compose.yml: make it easy to restrict db resources

Open BacLuc opened this issue 1 year ago • 4 comments

As we learned, postgres may behave differently depending on the available RAM. You can now test the database nearer to production by adding DB_MEMORY_LIMIT=1G DB_CPU_LIMIT=1 to your .env file.

IntelliJ does not like the env variable interpolation, but it works.

I used 128G as fallback, because normally while developing you don't want a slow DB. With the cpus it was not possible to limit to more cpu than the machine has. Thus, i limited to 8 cores which every developer machine has hopefully.

BacLuc avatar Apr 15 '24 19:04 BacLuc

@BacLuc I was not able to apply the limits on my machine. Do they only work under kubernetes? Or should it also work with a Docker setup?

pmattmann avatar May 18 '24 15:05 pmattmann

@BacLuc I was not able to apply the limits on my machine. Do they only work under kubernetes? Or should it also work with a Docker setup?

This is only for docker compose, and has nothing to do with kubernetes. What was the output of docker compose config after you applied the limits?

BacLuc avatar May 19 '24 16:05 BacLuc

@BacLuc I was not able to apply the limits on my machine. Do they only work under kubernetes? Or should it also work with a Docker setup?

This is only for docker compose, and has nothing to do with kubernetes. What was the output of docker compose config after you applied the limits?

well docker compose config looks alright:

  database:
    container_name: ecamp3-database
    deploy:
      resources:
        limits:
          cpus: 1
          memory: "1073741824"

but if i connect to the container, it looks like there are more resources availlable:

CPU: cat /proc/cpuinfo lists 20 CPUs.

Memory:

free -g
              total        used        free      shared  buff/cache   available
Mem:             31           2          20           0          10          29

Are these information not reliable?

pmattmann avatar May 20 '24 11:05 pmattmann

I also don't see a change in /proc/cpuinfo or with free. But if you watch what docker stats does, you see that there is a limit, and that it is respected. And i also saw that the query plans of postgres changed, and that the queries we improved were slower with 1GB of RAM.

BacLuc avatar May 20 '24 11:05 BacLuc

Not sure I am happy with developers having to do more setup to get eCamp up and running locally (manually entering the number of cores and amount of memory into their .env). And also I'm not sure I like the statement "8 cores which every developer machine has hopefully". Could we instead add this commented out into docker-compose.yml, and if I want to restrict the db resources, I can uncomment it and tweak the values?

carlobeltrame avatar May 22 '24 14:05 carlobeltrame

Not sure I am happy with developers having to do more setup to get eCamp up and running locally (manually entering the number of cores and amount of memory into their .env). And also I'm not sure I like the statement "8 cores which every developer machine has hopefully". Could we instead add this commented out into docker-compose.yml, and if I want to restrict the db resources, I can uncomment it and tweak the values?

They don't have do do anything as long as they have 8 or more cores, and are happy with the 8 cores that are running the db. That's what the default values are for.

I am not a fan of changes to checked in files that you want different on your machine and accidentally check in.

BacLuc avatar May 25 '24 16:05 BacLuc