ubergeek77 / Lemmy-Easy-Deploy

Deploy Lemmy the easy way!
MIT License
133 stars 14 forks source link

Feature request - expose docker memory limits for each container #72

Closed pallebone closed 8 months ago

pallebone commented 1 year ago

Did you check the FAQ & Troubleshooting section for answers to common questions and issues?

Yes

Describe the issue docker-compose.yml has 5 containers. For 3 months we have been struggling to contain postgres and other containers memory requirements, requiring scripted rebooting of the containers as they consume large amounts of memory continuously without limit. After troubleshooting many different things, limiting the containers memory requirements and allowing them to background swap prevents oom issues on LED and other deployments (tested with other admins on matrix).

Feature request:

I would like to be able to specify via a config file for each of the 5 containers the following settings: mem_limit: xxxxm mem_reservation: xxxxm memswap_limit: xxxxm

The compose file would then result in settings such as:

proxy: build: ./caddy mem_limit: xxxxm mem_reservation: xxxxm memswap_limit: xxxxm env_file:

And so on for each of the 5 containers specified. Ideally each of the 5 can have different limits as is appropriate from monitoring and testing.

Currently I am illegally editing the compose file directly to add these fixes in and keep the server from having memory issues, but ideally exposing these settings via a config file that can be read would be ideal.

Kind regards P

ubergeek77 commented 1 year ago

Are you able to resolve this need via Advanced Configuration?

https://github.com/ubergeek77/Lemmy-Easy-Deploy/blob/main/ADVANCED_CONFIGURATION.md

That allows you to define your own Docker Compose template. This is pretty much the sort of thing I designed it for.

pallebone commented 1 year ago

I mean technically yes but then I am throwing away the entire docker-compose.yml for my own at this point which feels kind of like throwing the baby out with the bathwater just because I want to add in a couple of missing lines into the auto generated one… seems a bit nuclear/over the top? Otherwise all config files could be dealt with in that way instead of allowing custompictrs to add in a few extra options for example which made sense because it preserves the rest of the settings while adding some desired flexibility?

airjer commented 10 months ago

What's your current settings because I'm having the same issue.

pallebone commented 10 months ago

What's your current settings because I'm having the same issue.

This is a complex question because I also use shared hugepages in my configuration This is dependent on your ram and so on.

However for each item in my docker compose I have to remember anytime I do an update of LED to edit the docker compose again and add in what I want for each container eg:


lemmy: image: ghcr.io/ubergeek77/lemmy:0.18.5 mem_limit: 1024m mem_reservation: 768m memswap_limit: 1536m volumes:

and so on for each container. Also there is a problem currently with LED that it does not account for shared memory size and leaves the docker at 64mb so if in cutompostgressql.conf you specify shared_bufferes higher than 64 MB as is recommend by lemmy because of the performance boost) vacuum no longer works at all in postgres.

To fix this requires you also set shm_size in docker compose to be equal or bigger to this value as per this person who noted the issue here: https://stackoverflow.com/questions/75937656/shm-size-of-docker-container-needs-to-be-equal-or-bigger-than-postgresql-shared

To be fixed correctly by LED all 4 of these values should be configurable:

shm_size: xxxm (for postgres container) mem_limit: xxxm mem_reservation: xxxm memswap_limit: xxxm

If this cant be done then lemmy runs sub optimally unfortunately.

airjer commented 10 months ago

Maybe a /custom/pre-deploy.sh to write these values in? Any knowledge there on doing that?

pallebone commented 10 months ago

I don’t currently know how to do this

ubergeek77 commented 8 months ago

Since I don't have the capacity to develop features, and because I allow this to be changed with advanced configuration, I won't be personally adding this to the script. However, I will gladly accept PRs for this feature if anyone wants to contribute.

pallebone commented 8 months ago

Ok thank you anyway :)