Hi,

Do you have suggestions for kernel tweaks for getting the most out of a RAM limited system?

I am running a service requiring 2GB of RAM (netbird) on a VPS which has just 1 GB of memory. I am doing so because I am a stingy bastard and I use only free VPSs for my personal use so I get what I am paying for.

Because of this hardware limit in about 12 hours from service start I begin swapping a bit too much. This would still be manageable but soon the hypervisor gets really pissed and steals up to 90% of the CPU. So the only solution so far is restarting the docker containers every 12 hours (not great, not terrible).

Looking to improve this, Iam now experimenting with ZRAM and swappiness and it seems some benefit can be achieved by using some of the Linux kernel feaures. Is there anything else I should look into?

You are viewing a single thread.
View all comments
3 points

In my experience kernel tweaks aren’t going to be a major change on memory usage. Most distros are meant to be full featured and not necessarily lightweight. So unless you are already running a minimalist distro, make sure you don’t have bunch of background services running you don’t need. I can recommend using Debian Minimal iso’s, they require 256MB of mem. Depending on what features you enable you could use a lot more.

permalink
report
reply
2 points

Thanks for sharing your experience, indeed the distribution is relevant here. I am running Arch (BTW) on this VPS which idles at about 300 MB with dockerd and containerd, I am not sure how does exactly compare to Debian on RAM usage (I have a couple of other VPS running debian which seem to use a little bit more RAM but it could be because those images are bastardized by the addition of cloud provider services). In any case my setup is pretty minimal, to get some large benefit there I fear I should use something without systemd :/

permalink
report
parent
reply
2 points

If you’re idling at 300mb with containerd running, you’re not getting better than that with a modern general-purpose distro. As others have said, switching to another vps’ free tier that offers more is your single best bet by a mile. About the only options you have on this one are compressed ramdisks being used as swapfile (zram) and literal disk swapfile to get you the rest. It’ll be very slow though if you have to load half your workload on shared platter swapfile.

permalink
report
parent
reply
3 points

Yeah the 300meg isn’t going to get much less. Switching to Debian won’t change much there. Perhaps you can look into running a minimalist container distro if you are just using the machine for that. I personally want to check out Talos, there’s also RKE and Burmilla. No experience with them, to me the memory doesn’t matter much because I run a homelab. So I currently just run Debian and k3s. On my systems the containers are actually what gobbles up all the memory. If you’re using public container images, there’s a good chance the memory configuration on them isn’t optimal. Especially JVM services are a lot of the time configured to just use whatever is available. If you give them less memory they will do more garbage collection. So if CPU is less an issue then mem, that could be worth looking into (it’s just parameters you can pass on startup). Hopefully any of this is of use. Good luck :)

permalink
report
parent
reply
2 points

Thanks again, I will look into your suggestions, never heard of neither Talos, RKE or Burmila. Indeed I should also look if I can do in the containers. The problem is only this database “CockroachDB” which is extremely memory hungry, maybe I can change something there.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 7.9K

    Monthly active users

  • 6.3K

    Posts

  • 175K

    Comments