In my relentless pursuit of trying to coax more performance out of my Lemmy instance I read that PostgreSQL heavily relies on the OSs disk cache for read performance. I’ve got 16 GB of RAM and two hdds in RAID 1. I’ve PostgreSQL configured to use 12 GB of RAM and I’ve zram swap set up with 8 GB.

But according to htop PostgreSQL is using only about 4 GB. My swap gets hardly touched. And read performance is awful. Opening my profile regularly times out. Only when it’s worked once does it load quickly until I don’t touch it again for half an hour or so.

Now, my theory is that the zram actually takes available RAM away from the disk cache, thus slowing the whole system down. My googling couldn’t bring me the answer because it only showed me how to set up zram in the first place.

Does anyone know if my theory is correct?

    • chirping@infosec.pub
      link
      fedilink
      arrow-up
      2
      ·
      4 hours ago

      If you are on HDD then looking at what else is using the same disk, and reducing that usage, may yield some results. Forexample, if /var/log is on the same disk and can’t be avoided, then reducing log volume or batching writes may reduce the “context switches” your HDD has to do. There should be options for I/O limits/throttling/priority in systemd. If you have only postgres on the HDD, I’d consider giving it 90% of the max bandwidth – maybe that’d be more effective than going full throttle and hitting the wall. If you have postgres and some other service fighting for the HDD’s time, these limits could help. Make sure access time tracking is off (or set to relatime).