Say, you have a large partition (1Tb or higher), for example,/home, which is almost full. This means that there are a lot of users' files on it. When some software, like backup, scans all these files, the Slab cache starts to grow. Here is an example:
# cat /proc/meminfo
MemTotal: 131822716 kB
MemFree: 8396188 kB
MemAvailable: 125324428 kB
Buffers: 18040 kB
Cached: 94444 kB
SwapCached: 741444 kB
Active: 873220 kB
Inactive: 972620 kB
Active(anon): 818524 kB
Inactive(anon): 925616 kB
Active(file): 54696 kB
Inactive(file): 47004 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 31999996 kB
SwapFree: 20412420 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 1228792 kB
Mapped: 40932 kB
Shmem: 8124 kB
Slab: 120366508 kB
SReclaimable: 117102628 kB
SUnreclaim: 3263880 kB
As you see Slab is over 100 Gb!
This can negatively impact the overall performance of your server, especially when some heavy IO software is running.
There are a few kernel settings to control the Slab cache size. They can be set with# sysctl -w option=value
. To make custom kernel settings persistent upon reboot, add them to/etc/sysctl.conf
First, we recommend setting the vm.vfs_cache_min_ratio
to0
.
Important notice:settingvm.vfs_cache_min_ratio
to0
for the kernel version prior to3.10.0-614.10.2.lve1.4.46will crash it. So, you can safely setvm.vfs_cache_min_ratio
to0
if your server is running the kernel3.10.0-614.10.2.lve1.4.46 or higher.
vm.vfs_cache_min_ratio
parameter controls the minimum amount (in percentage) of dentry\inode cache which can not be reclaimed. The default value is2
, which is rather small, but with a lot of cgroups used in the system, this can turn out to be a very big value.
If you see this error when trying to apply the parameter
"sysctl: cannot stat /proc/sys/vm/vfs_cache_min_ratio: No such file or directory"
note that/proc/sys/vm/vfs_cache_min_ratio
is only available on CloudLinux 6, CloudLinux 6 Hybrid, and CloudLinux 7. It isnotavailable on CloudLinux 7 Hybrid and CloudLinux 8.
The second parameter isvm.vfs_cache_pressure
, the default value is100
. Basically, this parameter controls how aggressively the kernel will try to shrink the dentry/inode cache, so setting it to a bigger value could help to reduce the Slab cache size. The value can be set to500
or even1000
.
Comments
0 comments
Please sign in to leave a comment.