mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-09 07:13:36 -05:00
[HELP] komodo-periphery memory leak #140
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rita7lopes on GitHub (Nov 26, 2024).
Hello,
I've been testing out Komodo for some weeks now.
I'm running it all in docker containers, with the default/vanilla configuration, only adding a
PERIPHERY_PASSKEYto the periphery environment variables, as visible below:However, I've noticed a memory leak, as seen in the screenshot below.

I started the container on the 14th when I started the test.
On the 18th we needed to reboot the system due to
kswapd0spiralling and today the same happened and I noticed the memory leak.Am I doing something wrong?
@mbecker20 commented on GitHub (Nov 27, 2024):
Thanks for the information. This is not typical for the memory to rise indefinitely. Does anything unusual stand out in the Periphery container logs?
First possible culprits may be the number of processes on the host. I see you mount /proc into the container. Periphery uses https://docs.rs/sysinfo/latest/sysinfo/ to get the system stats and the implementation includes processes, which the sysinfo library caches internally. So many processes on the host will increase the memory usage as it caches the process metadata. I do need to investigate this libary a bit more, but I don't really expect it to leak over time, maybe the process list is actually growing for another reason. Also the docker rust library https://github.com/fussybeaver/bollard has a client loaded in memory for the lifetime of the Periphery application, if this client somehow leaks memory internally. I haven't seen anything close to these Gigabytes of memory uses if I read the graph correctly. You can try removing
/procfrom the container volumes and see if anything changes.Second possibility is the number of docker resources on the host. While I have plenty of testing with big Komodo deployments, usually there are many servers and not very many containers on each host. Can you also estimate the number of eg containers running?
@rita7lopes commented on GitHub (Nov 27, 2024):
These are the only logs I see each time I restart the container:
Containers running: 23
Processes running: 242
I tried removing the /proc, and the issue seems to be gone. No memory leak.

I noticed something interesting.
There's no memory leak on the machine where I have Komodo core and periphery on the same compose file:
And this machine has even more containers and processes running
Containers running: 29
Processes running: 880
And this containers has the
/procSo this most likely means, that it's not the komodo-periphery itself leaking memory, but some process and/or machine spec that's the problem.
Processes that are running in the "memory-leaking" server and not on the "good" server:
processes.txt
There's nothing specific I see, all seems kernel/OS dependent. But I decided to share nonetheless, maybe it helps.
The machines are 100% different. Different host, different OS, different kernel, different specs...
"memory-leaking" server:
5.10.0-33-amd64"good" server:
4.19.0-26-amd64@mbecker20 commented on GitHub (Nov 28, 2024):
The
/procmount was added so periphery can pick up the process info on the host. While it does seem to work under many conditions,/procit may have unintended consequences, as these are not normal files but handled by the kernel: https://stackoverflow.com/questions/47072586/docker-access-host-procMaybe it affected the docker containers report of its own memory usage?
@rita7lopes commented on GitHub (Nov 29, 2024):
I don't believe that to be the case @mbecker20
The server needed a reboot after the OOM. kswapd0 was visibly trying to handle the situation without success... Reboot was needed.
The memory is reporting accurately, it indeed starts memory leaking on that server if I add the
/procThis is not a blocker but something I believe to be worth sharing.
Keep up the good work.
@mbecker20 commented on GitHub (Dec 2, 2024):
I think I may have found something related to processes / memory usage. It looks like the method in
sysinfolibrary used to refresh the process list in periphery memory will not remove dead processes by default: https://github.com/GuillaumeGomez/sysinfo/blob/main/src/common/system.rs#L104. See the second parameter passed torefresh_processes_specificsis always false here.It looks like this will cause the in memory process list to grow indefinitely, and faster when your host has a lot of processes coming and going.
@mbecker20 commented on GitHub (Dec 2, 2024):
Hi, I've made the change the change to clear the dead processes from the
sysinfocache on process refresh in 1.16.12.Could you try mounting
/procagain on the problem server when you update to 1.16.12, and see if the problem still happens?@rita7lopes commented on GitHub (Dec 3, 2024):
Hey @mbecker20 sorry for the delay.


I'm testing it now.
Just FYI this is how the memory consumption looks like for the container for the last 7 days (without the
/procmounted)At 15:38 UTC today I updated the image to 1.16.12 and mounted the
/procagain. As you can see below it had a spike of memory at the start but then stabilized and even decreased compared to before.I will keep it running and update you tomorrow so that we can come to a better conclusion.
@rita7lopes commented on GitHub (Dec 6, 2024):
Hello @mbecker20

Here's the memory consumption during the last two days (since I restarted it with the new version and
/procmounted).It's clear that now the memory consumption is much better. However, it's still slowly increasing constantly, as it was happening with the previous version without the
/procmounted.I will leave it running to see if eventually it stabilises.
@2q2code commented on GitHub (Dec 13, 2024):
Just had my main server (which never crashes) crash and I traced it to this periphery leak, and OOM killer subsequently killing everything in sight. I am just looking for docs on how to update periphery (komodo has been updated, but the periphery has not been - explicitly, anyway).
Note that my periphery install was done by
portainerbecause I was migrating all and it was easier this way. I am now changing it to be done bydocker compose, deploying by ansible, as I wasn't expecting to find that portainer was still running (along with all its agents).It's worth noting it is a very slow leak, as it took 3 weeks to eat up all the memory I had available (an extra 2-3GB, I think).
Now updating all periphery and will set up memory watches.
@mbecker20 commented on GitHub (Dec 13, 2024):
@2q2code Sorry about the crash! Luckily I believe the latest release already fixes this. To update Periphery installed with container, use the
latestor1.16.12version tags, and launch the container. If you check the container logs after launch, you should see log saying starting up, and print the version1.16.12. You can also see the version currently running in the UI, navigate to the Server in UI and you will see the Periphery version of the Server in the header / info area.If you were previous using
latest-aarch64or1.16.11-aarch64, you should remove the-aarch64, Komodo now releases multi arch image. Both x86_64 and ARM hosts can use thelatesttag now.@mbecker20 commented on GitHub (Dec 13, 2024):
@rita7lopes Any updates on the memory usage? I see in the last graph it climbed from
36.5 MBto almost39MB, but thats still pretty tiny. All my servers steady under 100MB now, I think always-growing list of processes in that sysinfo crate were the culprit.@2q2code commented on GitHub (Dec 13, 2024):
I will do a network-wide ansible playbook to upgrade and redeploy all periphery containers, so I won't need this, but do you think it might be an idea to support bootstrap-updating Komodo's own periphery containers?
@mbecker20 commented on GitHub (Dec 13, 2024):
@2q2code I've considered how to do self updating for years, but its not so easy. It seems like Komodo should be able to do it because it can launch containers etc. Why not launch itself.
In fact, I set up Komodo Core compose files as a Stack in Komodo after I spin it up from cli. And then can see Komodo Core logs from the UI. And it does work for Komodo to Deploy itself.
But my Komodo Core compose doesn't include Periphery. I run Periphery under
systemd --user, outside container. It is Periphery that is able to complete the redeploy process for Core container. Core doesn't update itself, Periphery does that.But I'm not sure of any open source project which has container able to do self update. Maybe the Nextcloud AIO monstrosity (sorry NC) which has you launch a master container, mount docker socket in there, which then spins up a bunch of other containers. But single container deployments? Don't think so.
This is the problem for the Komodo case: All deploying is done by Periphery spawning shell child processes which run docker commands. But if that child process happens to kill its parent Periphery process, say in the course of updating the container, the child process will be killed as well, and the operation will fail to complete. In this case, Periphery will just kill itself, it cannot resurrect.
I've considered whether its possible to spawn a temporary container with
-d --rmflags, and perform the update from there. If all users set up their Periphery exactly the same, maybe it could be done. However then consider all the edge cases from different users specific setups, mainlysystemdvscontainerinstalls.Again, been considering this for a while, it may be possible its just not so easy, hopefully you can see why now.
I have used both Puppet and Ansible to manage the Periphery deployment fully automated via Github Webhook. I prefer Ansible, and have a really nice flow figured out using the
alpine/ansiblecontainer. I structure a git repo using this simple following layout, and use webhook to Deploy it as a Komodo Stack on commit, which updates all Periphery in the network.root folderhosts.iniplaybook.yamlperiphery.config.tomlansible.compose.yamlIn ansible.compose.yaml its something like:
@rita7lopes commented on GitHub (Dec 18, 2024):
Hello @mbecker20,
I've been testing the new version
1.16.12for a while nowI can confidently report that the memory leak issue has been resolved on version
1.16.12The machine I've used to test this version has faced OOM caused by other containers running, but the periphery never freaked out. Even with the machine and its processes OOM, the periphery kept memory under 100MB always—solid as a rock!
Great work @mbecker20!!
@2q2code This version 100% works for me and I tested it pretty much under fire, so if you use the latest version I believe you should be fine!
@2q2code commented on GitHub (Dec 19, 2024):
Outstanding. I updated it soon after this conversation and haven't had it running away with memory since. Yay!
@ggirard07 commented on GitHub (Feb 20, 2025):
@mbecker20 not sure I understood the statement properly, but I think linuxserver.io has some, like their plex image.