Welcome to Incremental Social! Learn more about this project here!
Check out lemmyverse to find more communities to join from here!

Lemmy instance using a lot of ram

I have my own Lemmy instance (Lemmy.emphisia.nl) but I had to take it offline, after running a while it was using more than half of the system memory (16gb in total). Causing the computer to crash as there are a lot of other services also running on it.
The problem appears to come from postgress. In btop I can see it spawning a lot of processes all taking up about 80 MB in the beginning but rising as it runs, rising as high as 250 MB per process.
I have already tried adjusting the postgress config to be optimized for less memory, but it seems to do nothing.

Is this normal, and if not, what is going wrong?

stown ,
@stown@sedd.it avatar

I wonder if this is the cause for the UI failing and showing a white page with "server error". It has something to do with a failure to retrieve the site icon and if postgres is crashing that could explain why lemmy-ui is failing to retrieve the site icon.

My current "fix" for this is a script that runs every 10 minutes and sets the site image to NULL, curls the site URL, then sets the site image back to what it was. This does seem to work around the problem and if the UI does crash it's only down for a maximum of 10 minutes.

romano ,
@romano@lemmy.shtuf.eu avatar

Yea, I had to make a crontab task that resets lemmy every day. Hope it gets fixed in the future but for now it sorta works.

Die4Ever ,
@Die4Ever@programming.dev avatar
youpie_temp OP ,

oh wow thanks, ill see if that fixes it! weird that it doesnt get killed by OOM killer on my server

redcalcium ,

Does your server has a big swap space?

youpie_temp OP ,

It has zswap and a swapfile of about 8 gb, and it gets fully utilized

redcalcium ,

Yeah, this is why I have small swap on my servers. I'd rather the process got killed by the oom killer and got restarted automatically instead of running very slowly and trashing the entire server when it uses too much memory.

jeena ,
@jeena@jemmy.jeena.net avatar

Since my upgrade to 0.19 I really struggle to keep my servr online. It sounds like what is happening to me too. The whole server beco.en unesponsive after the load goes to 100. After I kicked NextCloud from the server in only kept happening every coupple of days. Let's see if this workaround helps to fix it. If not then I'll remove swap.

poVoq ,
@poVoq@slrpnk.net avatar

I have been running a cron script to automatically restart the lemmy backend, which in turn resets the postgres memory use ever since this problem started to happen months ago. For me 0.19.x actually made it less bad, but it is still an annoying issue.

redcalcium ,

Try limiting the database connection pool size too in lemmy.hjson. It helped a lot in my instance. I set mine to 30 in a small server with 8gb ram. You can set it to even lower value for lower postgres memory consumption.

database: {
        host: dbhost
        user: "lemmy"
        password: "secret"
        database: "lemmy"
        pool_size: 30
}
  • All
  • Subscribed
  • Moderated
  • Favorites
  • incremental_games
  • selfhosted@lemmy.world
  • random
  • meta
  • All magazines