What is a safe memory limit for docker containers?

Currently reading
What is a safe memory limit for docker containers?

280
79
NAS
DS920+, DS916+, DS211j
Operating system
  1. macOS
  2. Windows
Mobile operating system
  1. Android
  2. iOS
Sometimes I come across docker-compose files in which a memory limit is set for the docker container.

I personally have never done that for my containers, but I was wondering who among you have done that and why?
I always thought that Synology's GUI took care of that automatically.

So if you guys set a limit what is a safe average memory limit that you set.
How do you know what to set for each container?
Is it really necessary to set that?
 
I have done it.
Not sure why or which container but I'm pretty sure at least one of the containers I run has had a memory leak in the past and it's brought my NAS down. Limiting the memory to something sensible means whilst 1 container may stop working, the whole NAS does not and the other 59 containers continue to run without a problem.

Not sure about if you use the Synology interface for docker rather than docker-compose but I really doubt it.

I check the stats of each container within portainer and then limit accordingly.
I've had to tweak a couple since, but it's also a matter of thinking.. What's the container actually doing?

Something like rss-bridge shouldn't need much, say 50-100m but jellyfin will need considerably more.


FWIW I've found everything running far more smoothly since starting this process and only had to tweak a couple of containers to get them working properly.
 
Upvote 0
I generally haven't used RAM limits. I guess the reason to use it would be to stop a container going rogue and eating up all the RAM, if that is possible. If you want to place a limit then why not see how much is normally used and add some to that.

FYI:
  • My hungriest container is PostgreSQL which is using 186MB RAM.
  • The lowest RAM container was Calibre-Web which had 16KB with no connections but jumped to 50MB when I browse to it.
 
Upvote 0
@fredbert It is indeed possible, I've seen it happen on my NAS a couple of times.
The problem is, when it happens you can't even log into the NAS to find out which one has done it, not even via SSH.

My Jellyfin consumes 3GB but that is a large library of my movies, tv series, music, photos etc etc etc...
 
Upvote 0
Last edited:
As someone who had run Containers with Swarm and Kubernetes in production, I can say it's usualy careless to run containers in production without requested or reserved memory and a memory limits. No one wants to experience random OOM Kills on containers that run process with buisness value.

Thus said, the memory limit, is a hard limit that appear like the existing ram in a container, that is if the process is CGROUP aware. If a container exeeds the limit it will be OOM killed. Even when the process inside a container is CGROUP aware, it might sill happen that visible, but unused memory will be used as cache. Plex and Emby are candidates that leverage the spare memory for cache.

To find the sweat spot of a memory limit, tools that allow to show ram usage metrics help a lot! Prometheus/Influx + Grafana or the dashboard build-in in Influx 2.0 help a lot get a better understanding. Typicaly the more fine grained you are able to get metrics for a service in a container, the easer it becomes to identify the sweat spot for the container limit.

The requested/reserved (depending on the container orchestration) limit on the other hand will be handled as a constraint for a scheduler and indeed reserve that amount of ram on the nodes.
 
Upvote 0
Just wanted to say that Grafana helped me with this as well. I run several containers that did lose control and started to fail altogether. Once started to limit their ram there was no more problem at all.
 
Upvote 0

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

Thank you, I was not aware of this table. From my database you can see which manufacturers' memories are...
Replies
2
Views
712
Realistically, brands don't matter. Only three companies make RAM chips: Hynix, Micron, and Samsung...
Replies
5
Views
4,709

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending threads

Back
Top