Swappiness on FreePBX Distro

I run my FreePBX on a ESXi VM. For years, I’ve given it 2GB of RAM and it’s run just fine.

After a recent upgrade earlier this year, I noticed that my machine would have some sluggishness even when handling a single call. Often there would be a delay of several seconds after calls were answered and before audio was passed.

I examined the memory chart on the main FreePBX page and noticed that the memory was 52% used with 41% being cached. 3% was being used in swap file. I developed a theory that the swap file was slowing everything down.

I did some research and learned about how the cache and the swap file are used, and started to wonder why my system was using a swapfile at all. Cache is supposed to be freed up when memory is needed. In theory, swap shouldn’t be used at all unless there simply isn’t enough RAM to run the apps. At 52% usage, I was nowhere near there.

So, I learned a bit more about “Swappiness,” and I ran across this page:

https://linuxhint.com/understanding_vm_swappiness/

which indicates that Swappiness tells Linux when to start using swap files. The default is 60, which appears to mean that when free memory reaches 60% (or less), it should start using a swap file. The same page indicates that server systems should use a much lower setting. It also indicates that MariaDB based systems should set Swappiness to 1 (ONE).

The FreePBX distro has Swappiness set to 30. Given that FreePBX used MariaDB, and that swapping is undesirable, shouldn’t the FreePBX distro have swappiness set to 1???

In the meantime, I’ve increased by available RAM to 4GB, and the system seems to be working again. All the same, I thought that I’d consult the gurus and see what you think…

Should swappiness be set to 1?

Hi.
I don’t know why you’ve got this value, because everywhere on my systems it’s set on 30 and not 60.
Weird

You’ve misread my initial post. In it, I specifically said that:

Even with Swappiness set at 30, the system is going to start swapping when free space (which is calculated by deducting both used space and cache) is less than or equal to 30 percent. Given that the recommendation is to set Swappiness at 1 for systems that use MariaDB, shouldn’t the FreePBX Distro set Swappiness to 1, and not 30?

I’m running CentOS 7 (with kernel 4.14.188) and 4 GB RAM and can’t see any swap related problem.

# sysctl vm.swappiness
vm.swappiness = 10

# free -m
              total        used        free      shared  buff/cache   available
Mem:           3930         964         202         255        2763        2428
Swap:           767           1         766

# uptime
 13:12:28 up 74 days,  6:54,  1 user,  load average: 0,03, 0,08, 0,04

Are you probably sometimes running memory consuming jobs like backups or other things? They could be responsible for existing swap. But that shouldn’t harm as long as it doesn’t swap all the time.
Or is there another memory consuming process? Did you check with top or ps -aux?

I was running my system with 2GB when the problem occurred. I increased my RAM to 4GB and the problem seems to be resolved.

The FreePBX distro has Swappiness set to 30. Given that FreePBX used MariaDB, and that swapping is undesirable, shouldn’t the FreePBX distro have swappiness set to 1???

1 Like

Sorry I confused 30 and 60% memory :wink:
Anyway, how many extensions have you?
Concurent calls,
Usage?

I have about 15 extensions. Usually, zero calls. Occasionally, one. Rarely, two at a time.

The FreePBX distro has Swappiness set to 30. Given that FreePBX used MariaDB, and that swapping is undesirable, shouldn’t the FreePBX distro have swappiness set to 1 as suggested in this article?

https://linuxhint.com/understanding_vm_swappiness/

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.