Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

BacLuc
Copy link
Contributor

@BacLuc BacLuc commented Apr 15, 2024

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.

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 BacLuc requested review from usu, pmattmann and carlobeltrame and removed request for usu, pmattmann and carlobeltrame May 15, 2024 20:01
@pmattmann
Copy link
Member

@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?

@BacLuc
Copy link
Contributor Author

BacLuc commented May 19, 2024

@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?

@pmattmann
Copy link
Member

@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?

@BacLuc
Copy link
Contributor Author

BacLuc commented May 20, 2024

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.

@carlobeltrame
Copy link
Member

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?

@BacLuc
Copy link
Contributor Author

BacLuc commented May 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants