Swap usage ?

Aug 6, 2018
21
2
8
31
Hi i'm in trouble
On my LXC containter
free, give me
free
total used free shared buff/cache available
Mem: 8388608 219568 7360020 456368 809020 8169040
Swap: 12582912 1271816 11311096

That mean 1.2Go Swap..
But smem give me

smem
PID User Command Swap USS PSS RSS
160 root /sbin/agetty --noclear --ke 92 8 23 516
163 root /sbin/agetty --noclear --ke 88 8 24 536
121 root /usr/sbin/cron -f 196 116 145 832
655 root /usr/lib/postfix/sbin/maste 656 132 176 872
2926 centreon (sd-pam) 1576 4 204 1384
192 redis /usr/bin/redis-server 127.0 900 228 270 836
657 postfix qmgr -l -t unix -u 616 220 385 1272
154 root /usr/sbin/sshd -D 620 184 500 2316
2920 centreon /lib/systemd/systemd --user 712 84 523 2856
26214 root tail -f -n0 /var/log/auth.l 0 404 629 2052
26215 root /bin/bash /opt/open-dsi/aut 0 152 638 2552
26210 root /bin/bash /opt/open-dsi/aut 0 136 716 2980
274 root /usr/sbin/apache2 -k start 1556 60 765 3264
21352 postfix tlsmgr -l -t unix -u -c 572 624 831 1796
128 messagebus /usr/bin/dbus-daemon --syst 1040 824 945 2076
26209 root SCREEN -S authprotect -d -m 0 908 1051 2160
3463 root (sd-pam) 1272 1008 1216 2412
109 root /usr/sbin/nscd 988 1092 1249 2316
3451 root /lib/systemd/systemd --user 0 784 1255 3604
11584 root /bin/bash 0 664 1290 3728
114 root /usr/sbin/rsyslogd -n 280 1476 1526 2264
293 www-data /usr/sbin/apache2 -k start 2096 2888 3826 6744
294 www-data /usr/sbin/apache2 -k start 2100 2896 3832 6748
9567 postfix pickup -l -t unix -u -c 0 3484 4428 6948
124 root /lib/systemd/systemd-logind 404 8112 8455 10540
13056 root /usr/bin/python /usr/bin/sm 0 8864 9169 11056
1 root /sbin/init 324 8512 9174 11952
155 Debian-snmp /usr/sbin/snmpd -Lsd -Lf /d 28100 11260 11392 12480
19367 www-data php-fpm: pool www 616 5724 12462 23988
19366 www-data php-fpm: pool www 616 6280 12900 24308
19365 root php-fpm: master process (/e 616 23064 27671 38560
503 mysql /usr/sbin/mysqld 229792 66732 66906 68016
43 root /lib/systemd/systemd-journa 308 28000 124559 226036


and


for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done
nscd 996 kB
rsyslogd 340 kB
bash 0 kB
cron 196 kB
systemd-logind 476 kB
dbus-daemon 1040 kB
sshd 620 kB
snmpd 28100 kB
agetty 92 kB
agetty 88 kB
redis-server 900 kB
php-fpm7.0 0 kB
php-fpm7.0 0 kB
php-fpm7.0 0 kB
systemd 324 kB
tlsmgr 572 kB
screen 0 kB
authprotect.sh 0 kB
tail 0 kB
authprotect.sh 0 kB
apache2 1296 kB
systemd 712 kB
(sd-pam) 1576 kB
apache2 1916 kB
apache2 1904 kB
systemd 0 kB
(sd-pam) 1272 kB
systemd-journal 304 kB
mysqld 230392 kB
master 656 kB
qmgr 616 kB
pickup 0 kB
awk 0 kB
awk 0 kB


And a script give me :

PID=1 swapped 324 KB (systemd)
PID=43 swapped 304 KB (systemd-journal)
PID=109 swapped 996 KB (nscd)
PID=114 swapped 340 KB (rsyslogd)
PID=121 swapped 196 KB (cron)
PID=124 swapped 476 KB (systemd-logind)
PID=128 swapped 1040 KB (dbus-daemon)
PID=154 swapped 620 KB (sshd)
PID=155 swapped 28100 KB (snmpd)
PID=160 swapped 92 KB (agetty)
PID=163 swapped 88 KB (agetty)
PID=192 swapped 900 KB (redis-server)
PID=274 swapped 1296 KB (apache2)
PID=293 swapped 1916 KB (apache2)
PID=294 swapped 1904 KB (apache2)
PID=503 swapped 230392 KB (mysqld)
PID=655 swapped 656 KB (master)
PID=657 swapped 616 KB (qmgr)
PID=2920 swapped 712 KB (systemd)
PID=2926 swapped 1576 KB ((sd-pam))
PID=3463 swapped 1272 KB ((sd-pam))
PID=21352 swapped 572 KB (tlsmgr)
Overall swap used: 274388 KB


Where is the 1.2Go of swap ?

I have a lot of containers...
My Proxmox said 20go of swap but smem and other script said 5go swap.
 
Here you have the lxc config :

arch: amd64
cores: 4
cpulimit: 4
hostname: XXXXX
memory: 8192
nameserver: 10.0.0.60 62.210.16.6 62.210.16.7
net0: name=eth0,bridge=vmbr1,gw=10.0.10.12,hwaddr=9A:6B:30:5D:36:1C,ip=10.0.40.69/16,type=veth
ostype: debian
rootfs: local:4069/vm-4069-disk-0.raw,size=10G
searchdomain: XXX.lan
swap: 4096

Proxmox :
4.15.18-15-pve
 
Hi,

Thanks for config.

May i ask you why need to use swap?

*Just a personal experience in general*

Even swap is more than simply extending available memory cases (as reported from users as well as I have seen by own experience) when swap was eliminated completely.

Also there is no general recommendation from our side, if you have issue with memory try to disable the swap.
 
Hi,
I'm using a lot of container with mariadb inside, but mariadb swap a lot even if i'm giving lot of "Pool memory and buffer" i don't understand why still using swap when i have free memory..

my swapiness is to 1

but in process there is not a lot usage of swap... but there is like "ghost" swap usage
 
I'm still having troubles with swap..


free -mh
total used free shared buff/cache available
Mem: 8.0G 714M 6.1G 833M 1.2G 7.3G
Swap: 12G 748M 11G


748 Swap usage :



PID User Command Swap USS PSS RSS
155 root /sbin/agetty --noclear --ke 92 8 16 296
156 root /sbin/agetty --noclear --ke 92 8 18 316
5477 centreon (sd-pam) 1548 4 129 756
819 root tail -f -n0 /var/log/auth.l 0 132 139 384
630 root /usr/lib/postfix/sbin/maste 656 132 167 564
5471 centreon /lib/systemd/systemd --user 720 72 195 948
815 root /bin/bash /opt/open-dsi/aut 0 132 206 608
77 root /usr/sbin/cron -f 120 196 218 664
193 redis /usr/bin/redis-server 127.0 900 228 249 560
182 root /usr/sbin/sshd -D 616 284 311 792
632 postfix qmgr -l -t unix -u 616 196 392 1248
820 root /bin/bash /opt/open-dsi/aut 0 152 465 1220
814 root SCREEN -S authprotect -d -m 0 556 565 844
8175 root (sd-pam) 988 580 705 1332
8164 root /lib/systemd/systemd --user 0 800 912 1632
80 messagebus /usr/bin/dbus-daemon --syst 1036 960 979 1368
371 root /usr/sbin/apache2 -k start 180 596 1110 2532
26659 postfix tlsmgr -l -t unix -u -c 516 1056 1294 2072
82 root /usr/sbin/nscd 860 1216 1324 1964
79 root /usr/sbin/rsyslogd -n 248 1460 1535 2196
10545 root /bin/bash 0 1336 1917 3372
8355 postfix pickup -l -t unix -u -c 0 4312 5033 6856
14917 www-data /usr/sbin/apache2 -k start 172 3616 5103 7632
14918 www-data /usr/sbin/apache2 -k start 172 3736 5226 7772
76 root /lib/systemd/systemd-logind 392 8672 8877 9828
11042 root /usr/bin/python /usr/bin/sm 0 9808 10294 11700
1576 www-data php-fpm: pool www 4132 4664 10758 19880
1 root /sbin/init 324 10668 11035 12444
1575 root php-fpm: master process (/e 4132 13736 16752 22628
1577 www-data php-fpm: pool www 4132 12196 19000 28832
153 Debian-snmp /usr/sbin/snmpd -Lsd -Lf /d 21552 33184 33213 33756
43 root /lib/systemd/systemd-journa 244 25372 98446 172296
4528 mysql /usr/sbin/mysqld 0 514792 514846 515340


Smem output

PID=1 swapped 324 KB (systemd)
PID=43 swapped 240 KB (systemd-journal)
PID=76 swapped 392 KB (systemd-logind)
PID=77 swapped 120 KB (cron)
PID=79 swapped 248 KB (rsyslogd)
PID=80 swapped 1036 KB (dbus-daemon)
PID=82 swapped 864 KB (nscd)
PID=153 swapped 21552 KB (snmpd)
PID=155 swapped 92 KB (agetty)
PID=156 swapped 92 KB (agetty)
PID=182 swapped 616 KB (sshd)
PID=193 swapped 900 KB (redis-server)
PID=371 swapped 200 KB (apache2)
PID=630 swapped 656 KB (master)
PID=632 swapped 616 KB (qmgr)
PID=5471 swapped 720 KB (systemd)
PID=5477 swapped 1548 KB ((sd-pam))
PID=8175 swapped 988 KB ((sd-pam))
PID=14917 swapped 172 KB (apache2)
PID=14918 swapped 172 KB (apache2)
PID=26659 swapped 516 KB (tlsmgr)
Overall swap used: 32064 KB


in reality only 32mo is used for swapping.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!