Memory Issues / Configuring For Kubernetes #1744
Unanswered
pinkfloydx33
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Problem
We are using Magick.NET as part of an ASP.NET application that runs as a Linux Docker containers in Kubernetes. The application creates thumbnails for any images our users might upload. The maximum upload size is 30Mb. Everything has been working generally fine. However once we get a handful of user uploads (usually in short succession or triggered by QA testing) the pod's memory consumption rises and Kubernetes OOM kills the pod.
We run our containers with a memory limit of
350Mi
. Because of this, before the OOM's I originally setResourceLimits.LimitMemory
to 35% out of precaution. Once we started getting the OOM kills I lowered it even further to 20% which didn't seem to help. I even increased the container max memory to700Mi
and despite this it eventually gets OOM killed.I had read some other threads here that suggested making sure you were running as x64 (since we're using the AnyCPU build) and that
ResourceLimits
were configured properly. So I added some basic console logging to check whatResouceLimits.Memory
was actually defaulting to, and this was the output:Well,
14653595648
bytes equates to more than 13GB which is well over the memory limits set on the pods. It appears that when running in Kubernetes as a Linux container, the defaults are being taken from theMemTotal
entry in/proc/meminfo
(or it's equivalent) which equate to the node's resources, and not the pod's.Here's the relevant portion of
/proc/meminfo
:Instead, the defaults should be taken from the cgroups (v2) file at
/sys/fs/cgroup/memory.max
, which in this instance containscorrelating to the limit of
350Mi
that this pod currently has.Questions
Now that I realize what's happening, I can make changes to both the pod configuration and our application so that I'm able to set
ResourceLimits
based on the pod's actual memory availability. That leaves me with a couple of questions:ResourceLimits.Memory
in this constrained environment (350mi), where the largest images we work with are 30mb?ResourceLimits.Memory
tune the same knobs asResourceLimits.LimitMemory
? I can't use the latter since passing a percentage won't workResourceLimits.MaxMemoryRequest
as well?Memory
andMaxMemoryRequest
. The documentation doesn't really explain it to meIn case it matters:
MagickNET.SetTempDirectory
as we were expecting to spill to disk.Magick.NET-Q8-AnyCPU
version14.0.0
Beta Was this translation helpful? Give feedback.
All reactions