I'm trying to implement a solution to this problem using control groups, which I have never worked with before. As a first step, I thought I would create a control group, add a process to it, and view its memory usage.
I ran the following code:
sudo apt install cgroup-tools
sudo cgcreate -g memory:/jupyterHub
sudo cgclassify -g memory:/jupyterHub --sticky 805
805 here is the jupyterhub
process. Ultimately, I want to limit the memory usage of 805 and all of its children, so that the OOM-killer is invoked when the memory usage is too high. When I run
sudo ps -o cgroup 805
it shows the jupyterHub
group as expected.
However, when I run
sudo cgget -g memory:/jupyterHub
it reports 4KB of memory usage, which is definitely wrong and I'm pretty sure corresponds to the process using zero memory.
systemd-cgtop
gives the same result. How can I create a control group containing jupyterhub
and its children that will report the correct amount of memory usage?
Also, please tell me if I'm doing something dangerous here (although I'm already planning on creating a duplicate server for testing so that I don't bork up the production one).
cgroups
. And what I've known is that to managecgroups
you can usesystemd
(I'd prefer learning to use cgroups by the commands rather than using systemd). Maybe you have to enable/disable some option in your system (maybe kernel parameters in/etc/default/grub
). Or maybe you are using the wrong cgroups version since therev1
andv2