Ways to reduce memory usage. Delete supervisor?

Hello,

I’m running balenaOS standalone version on a beaglebone black which has only ~480mb ram, without running any additional containers it already uses ~220mb of ram, as can be seen in the following figure, leaving ~260mb for application.

image

When I run my complete application the memory consumption floats around ~460mb, eventually if I leave it running for some time I get OOM error and my containers are killed. For that reason, I’m wondering if there are any ways to reduce the memory usage of the balenaOS, since I’m using the standalone version is it necessary to keep the resin_supervisor running? Are there anything that can be stoped?

My setup:
image

Hi,

The supervisor is needed if you are planning to push updates to your application.

If you deploy the application just once and don’t update it anymore, then you can disable the supervisor.

This could be done with these commands:
mount -o remount,rw /
systemctl disable resin-supervisor

Regards!

Note that the resin_supervisor container is in my case using about 40 MB.
Stopping it, assuming you can stop it, would only give you 40 MB more memory to allocate.

When I stop all containers then free reports the following for me:

 root@997563c:~# free
                 total       used       free     shared    buffers     cached
    Mem:        999116     475564     523552      11116      51832     200540
    -/+ buffers/cache:     223192     775924
    Swap:            0          0          0
    root@997563c:~#

So I would interpret this as the balena OS (including the 40 MB of the resin_supervisor) requires 220 MB - the rest of the memory is available for the other docker containers.

Thanks for that spanceac, I was having issues with resin-supervisor reverting my RPi’s /config.txt back to defaults after manually editing /mnt/boot/config.txt.

Even after disabling the service, resin-supervisor was self-launching again 15 minutes after boot, causing my changes to config.txt to be lost again. I’ve pasted the logs at the end, it might help others wanting to disable resin_supervisor to find this message.

After some digging I found a systemd timer that seemed the likely culprit, update-resin-supervisor.timer. I disabled it with

mount -o remount,rw /
systemctl disable update-resin-supervisor.timer

My Raspberry Pi hasn’t rebooted itself in 30 minutes, so it seems to have done the trick.

update-resin-supervisor induced reboot logs:

Jan 15 14:00:08 balena systemd[1]: Starting Resin supervisor...
Jan 15 14:00:09 balena resin-supervisor[1197]: resin_supervisor
Jan 15 14:00:09 balena resin-supervisor[1201]: active
Jan 15 14:00:09 balena systemd[1]: Started Resin supervisor.
Jan 15 14:00:10 balena systemd[1]: Started Resin supervisor updater.
Jan 15 14:00:11 balena sh[1203]: Getting image name and tag...
Jan 15 14:00:11 balena sh[1203]: No supervisor configuration found from API or required variables not set. Using arguments for image and tag.
Jan 15 14:00:11 balena sh[1203]: Set based on arguments image=balena/rpi-supervisor and tag=v9.0.1.
Jan 15 14:00:11 balena sh[1203]: Getting image id...
Jan 15 14:00:14 balena sh[1203]: Supervisor balena/rpi-supervisor:v9.0.1 already downloaded.
Jan 15 14:00:22 balena balenad[686]: time="2019-01-15T14:00:22.041216762Z" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/containers/create type="*events.ContainerCreate"
Jan 15 14:00:22 balena balenad[686]: time="2019-01-15T14:00:22Z" level=info msg="shim balena-engine-containerd-shim started" address=/containerd-shim/moby/d6498b06c6b3c7ccb84644094c2804681d500ae468984f29743867b2d34ee588/shim.sock debug=false module=containerd/tasks pid=1257
Jan 15 14:00:26 balena balenad[686]: time="2019-01-15T14:00:26.737042317Z" level=warning msg="unknown container" container=d6498b06c6b3c7ccb84644094c2804681d500ae468984f29743867b2d34ee588 module=libcontainerd namespace=plugins.moby
Jan 15 14:00:29 balena balenad[686]: time="2019-01-15T14:00:29.370655020Z" level=warning msg="unknown container" container=d6498b06c6b3c7ccb84644094c2804681d500ae468984f29743867b2d34ee588 module=libcontainerd namespace=plugins.moby
Jan 15 14:00:29 balena balenad[686]: Removing stale PID file /var/run/messagebus.pid.
Jan 15 14:00:29 balena resin-supervisor[1202]: Removing stale PID file /var/run/messagebus.pid.
Jan 15 14:00:30 balena balenad[686]: Starting system message bus: dbus.
Jan 15 14:00:30 balena resin-supervisor[1202]: Starting system message bus: dbus.
Jan 15 14:00:30 balena balenad[686]:  * Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon
Jan 15 14:00:30 balena resin-supervisor[1202]:  * Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon
Jan 15 14:00:30 balena balenad[686]:    ...done.
Jan 15 14:00:30 balena resin-supervisor[1202]:    ...done.
Jan 15 14:01:48 balena balenad[686]: [2019-01-15T14:01:48.863Z] Event: Supervisor start {}
Jan 15 14:01:48 balena resin-supervisor[1202]: [2019-01-15T14:01:48.863Z] Event: Supervisor start {}
Jan 15 14:01:49 balena balenad[686]: [2019-01-15T14:01:49.004Z] Unmanaged Mode is set, skipping API client initialization
Jan 15 14:01:49 balena resin-supervisor[1202]: [2019-01-15T14:01:49.004Z] Unmanaged Mode is set, skipping API client initialization
Jan 15 14:01:52 balena balenad[686]: [2019-01-15T14:01:52.200Z] Starting up in unmanaged mode, activating local mode
Jan 15 14:01:52 balena resin-supervisor[1202]: [2019-01-15T14:01:52.200Z] Starting up in unmanaged mode, activating local mode
Jan 15 14:01:52 balena balenad[686]: [2019-01-15T14:01:52.680Z] Switching logging backend to LocalLogBackend
Jan 15 14:01:52 balena resin-supervisor[1202]: [2019-01-15T14:01:52.680Z] Switching logging backend to LocalLogBackend
Jan 15 14:01:53 balena balenad[686]: [2019-01-15T14:01:53.485Z] Reporting initial state, supervisor version and API info
Jan 15 14:01:53 balena resin-supervisor[1202]: [2019-01-15T14:01:53.485Z] Reporting initial state, supervisor version and API info
Jan 15 14:01:53 balena balenad[686]: [2019-01-15T14:01:53.951Z] Attempting to load preloaded apps...
Jan 15 14:01:53 balena resin-supervisor[1202]: [2019-01-15T14:01:53.951Z] Attempting to load preloaded apps...
Jan 15 14:01:54 balena balenad[686]: [2019-01-15T14:01:54.361Z] Starting API server
Jan 15 14:01:54 balena resin-supervisor[1202]: [2019-01-15T14:01:54.361Z] Starting API server
Jan 15 14:01:54 balena balenad[686]: [2019-01-15T14:01:54.482Z] Unmanaged Mode is set, skipping API binder initialization
Jan 15 14:01:54 balena resin-supervisor[1202]: [2019-01-15T14:01:54.482Z] Unmanaged Mode is set, skipping API binder initialization
Jan 15 14:01:54 balena balenad[686]: [2019-01-15T14:01:54.513Z] Applying target state
Jan 15 14:01:54 balena resin-supervisor[1202]: [2019-01-15T14:01:54.513Z] Applying target state
Jan 15 14:01:56 balena balenad[686]: [2019-01-15T14:01:56.121Z] Supervisor API listening on all interfaces
Jan 15 14:01:56 balena resin-supervisor[1202]: [2019-01-15T14:01:56.121Z] Supervisor API listening on all interfaces
Jan 15 14:01:59 balena balenad[686]: [2019-01-15T14:01:59.781Z] Event: Apply boot config in progress {}
Jan 15 14:01:59 balena resin-supervisor[1202]: [2019-01-15T14:01:59.781Z] Event: Apply boot config in progress {}
Jan 15 14:02:00 balena balenad[686]: [2019-01-15T14:02:00.183Z] Event: Apply boot config success {}
Jan 15 14:02:00 balena resin-supervisor[1202]: [2019-01-15T14:02:00.183Z] Event: Apply boot config success {}
Jan 15 14:02:03 balena balenad[686]: [2019-01-15T14:02:03.129Z] Event: Reboot {}
Jan 15 14:02:03 balena resin-supervisor[1202]: [2019-01-15T14:02:03.129Z] Event: Reboot {}
Jan 15 14:02:04 balena systemd[1]: Shutting down.
Jan 15 14:02:05 balena systemd[1]: Failed to set timeout to 600s: Invalid argument
Jan 15 14:02:05 balena kernel: systemd-shutdow: 29 output lines suppressed due to ratelimiting

… and did it save you a lot of memory ?