Tuesday 23 October 2018

Re: Setting up cgroups on Ubuntu

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEo8IRgA3Fv3Xo6y9gae/s08YdJkUFAlvPVuwACgkQae/s08Yd
JkVxRQ/+ITNl3v6XoZoVu8fNto4SnTUp5qEmJsiEnTS77nLg0c4dp53s7SYwcsrb
3/DY836DAMGx8AJOxnp//hLu7SP4Hf7gtTw+L5uJjQ4wisMWazBZTh0e0EqliK0u
x0elM2SkWpIcnt3GotTr6hPbMl/KuPlMHaswS1c1RqwiJR+3zo1LImBG9q9pRteA
zAU5S//q3gq2OfhvL2h+nFVzytdUykeNJFeLbdHdSVizrql4hszHNtgHOXuucAA0
wNXY8cDwkeajlV6bn6FFTllNgOQTztAFjuRur0H+XnOOtwyu6FwBRsxaFXXNLnAs
JuyeBpb6WzCU3M0pPHDDAL0t5RIw5groS52syYoCXTc07sgIF1D41QLt0OlECQZN
9FiI5D5fnwtl8aCVWPPEbAe8Ak6/UM0vlJ3n/XFdcbKebC8AjSoM4I0R3uRfTDn7
VCz8ub0BgV3+RG1NL3z1gjQJ0lxeJ15IupVQSKDThmlAtBksXipHeiEkytY0kkVv
RtCHWlGnRW3QB5Z+wQFNY2pmvNDlqhHN3xr3EMbI6Q6/BZ3whNcDaj7jUVLeQAF9
SNlMMcUs4x0IoTviO5HjgJeHtlO8mMXGsPp+lZTwcdwNwWmQ137wQyFuDV7ndZWK
w/33AMSIldoWKbJRDE+9uQU/Dk7jYGu8a5U8qwrpleNLTWcBvRg=
=iUPi
-----END PGP SIGNATURE-----
W dniu 23.10.2018 o 09:57, Dimitri John Ledkov pisze:
>> Hey all,
>>
>> Is there a recommended way of setting up cgroups on Ubuntu? I see we
>> don't have `cgrulesengd` set up as a service, so is just running
>> `cgconfigparser` on boot and using `cgexec` the recommended approach?
>>
>> Or even dealing directly with the cgroups filesystem?
>>
> This is a very low-level question, which feels like one is jumping to
> conclusions/solution without stating the problem/user-story/goal. Can
> you elaborate and start from the beginning and what prompted you to
> find cgrulesengd?
>
> All system, user, and container processes on Ubuntu are segregated
> into cgroups with a default equal balancing of resources. And one can
> further adjust resource allocations using service, slice, scope
> settings. Or use delegation for further management. There are examples
> of using all of those things by various things in Ubuntu by default...
> but it's hard to point you at something specific, without at all
> knowing what is your actual use case.
>
> Also, I'm not sure if you are trying to escape default allocation and
> get a bigger slice, or on the contrary further sub-divide the
> resources your process was given.

Hey,

OK let me track back:

I'm asking this in the context of multipass - when memory in the
instance is exhausted, the virtual machine becomes unresponsive, there's
no way to investigate what's going on, and the OOM killer doesn't seem
to be able to kick in either. There's no swap configured, btw, but we
wouldn't like to add that.

So what we wanted to do is limit the memory usage of user-invoked
commands (those via `multipass exec`) to leave a minimum amount of
memory free so that you can always access the vm.

So the plan was to create a cgroup limited to a certain amount of memory
and put all the tasks created through `multipass exec` in there.

That led me to cgconfigparser / cgrulesengd, but I couldn't find much in
terms of a "guide" on how it's recommended to work it on Ubuntu.

HTH,
--
MichaƂ Sawicz <michal@sawicz.net>