[PATCH] ctdb-scripts: Drop script configuration variable CTDB_MONITOR_SWAP_USAGE

L. van Belle belle at samba.org
Thu May 2 12:47:05 UTC 2019


Hai Marting, 

> Monitoring of swap is based on the idea that swap
> space stacks on top of main memory, so that when a system starts
> filling swap space then this is supposed to be a good sign that
> the system is running out of memory. 

Not completely right in my option. 
Swap can be full while your ram is not. 

Maybe its good to check swappiness also, most distro's have default
swappiness set to 60.
The parameter value set to 60 means that "your kernel will swap when RAM
reaches 40% capacity."
40% ! All other is used for caching and/or services.

This control is used to define how aggressive the kernel will swap memory
pages. 
Higher values will increase agressiveness, lower values decrease the amount
of swap. 
A value of 0 instructs the kernel not to initiate swap until the amount of
free and 
file-backed pages is less than the high water mark in a zone.

Let say 5-10 years ago this was fine, but these days we have much more ram
and swap/swappiness ratio's can be changed to increase performance and lower
IO. 

How you calculate the swappiness ratio to this? 
This is a small formule what i personaly made/use to calculate my (safe)
ram/swap/swappiness ratios. 

In your example of 128GB Ram and 4GB swap
128/60 = 2.133 ratio.   ((128/4) / 2.133) = 15.23 +10 for safety = 25 so
minimaal 25 swappiness. 

That leaves about 32 Gb available for services/caching when its start to
swap. 
Swap starts now at 75% memory filled, and not at the default of 40%, result
in less IO due to swapping. 

Few other examples. Let say 32GB. 

Ram/def-swappiness    (Ram/Swap)
32/60 = 0.533 		(32/4) / 0.533 = 7.5+10=17.5, where in my option
anything below 25 should be avoided.
Try 8gb swap		(32/8) / 0.533 = 15+10=25 , here increasing swap to
8GB is better .. 
Try 64Ram 64/60=1.066	(64/4) / 1.066 = 15+10=25 , same with adding ram. 

256GB 
256/60 = 4.266	     (256/4) / 4.266 = 15+10=25 , so 256, with 4GB swap,
could use swappiness 25. 

What if you only have 2GB ram, with 4GB swap. 
2/60=0,005			(2/4) / 0.005 = 100 +10 = 110, which means
to me, not enough ram expect swapping. 

What if you only have 4GB ram, with 2GB swap. 
4/60=0,066			(4/2) / 0.066 = 30 +10 = 40, which looks
safe to me to avoid swapping and use max ram/caching.

(((RAM:"swap size") : (RAM:"default swappiness")) + 10(safety) = possible
safe swappiness value. 

Maybe worth checking this out. 
This is what i've learned in last 20 years of linux use. 

Unsafe ranges for swappiness 0-24.
Resonable, swappiness 25-39.
Ok for average use 40-59. 
Default 60.
Avoid 61-99
Above 100, not enough ram, expect lots of swapping. 
Setting swappines to 0-20, is an option but then you can expect OOM killer
messages .. 

Im not calculating possible need of suspend-to-ram(sleep) or suspend to
disk(hybernate). 
Since we dont use that on servers. 

Source: https://www.kernel.org/doc/Documentation/sysctl/vm.txt

I hope you can use it. 

Greetz, 

Louis
 




> -----Oorspronkelijk bericht-----
> Van: samba-technical 
> [mailto:samba-technical-bounces at lists.samba.org] Namens 
> Martin Schwenke via samba-technical
> Verzonden: donderdag 2 mei 2019 12:43
> Aan: Samba Technical
> Onderwerp: [PATCH] ctdb-scripts: Drop script configuration 
> variable CTDB_MONITOR_SWAP_USAGE
> 
> CTDB's system memory monitoring in 05.system.script monitors both main
> memory and swap.  Monitoring of swap is based on the idea that swap
> space stacks on top of main memory, so that when a system starts
> filling swap space then this is supposed to be a good sign that the
> system is running out of memory.  Additionally, performance on a Linux
> system tends to be destroyed by the I/O associated with a lot of
> swapping to spinning disks.
> 
> However, some platforms default to creating only 4GB of swap space
> even when there is 128GB of main memory.  With such a small swap to
> main memory ratio, memory pressure can force swap to be nearly full
> even when a significant amount of main memory is still available and
> the system is performing well.  This suggests that checking swap
> utilisation might be less than useful in many circumstances.
> 
> So, remove the separate swap space checking and change the memory
> check to cover the total of main memory and swap space.
> 
> Test function set_mem_usage() still takes an argument for each of main
> memory and swap space utilisation.  For simplicity, the same number is
> now passed twice to make the intended results comprehensible.  This
> could be changed later.
> 
> A couple of tests are cleaned up to no longer use hard-coded
> /proc/meminfo and ps output.
> 
> Pipeline: https://gitlab.com/samba-team/devel/samba/pipelines/59394125
> 
> Please review and maybe push...
> 
> peace & happiness,
> martin
> 




More information about the samba-technical mailing list