Projet

Général

Profil

Actions

Demande #4450

fermé

Améliorer la gestion du swap

Ajouté par Christian P. Momon il y a environ 4 ans. Mis à jour il y a environ 4 ans.

Statut:
Fermé
Priorité:
Normale
Assigné à:
Christian P. Momon
Catégorie:
-
Version cible:
Début:
02/05/2020
Echéance:
% réalisé:

0%

Temps estimé:
Difficulté:
2 Facile

Description

Nous constatons des problèmes d'I/O sur le SI April. Ça peut venir de débordement en swap.
Le swap est connu pour être très défavorable aux performances I/O.
Actuellement, la présence de swap sur les VM s'appuie sur deux considérations :
  • en fonctionnement nominal, le swap est inutile sur les VM ;
  • en cas de manque de RAM, le swap peut permettre :
    • d'amortir les problèmes,
    • de détecter qu'il faut faire quelque chose :
      • paramétrer un processus,
      • rajouter de la RAM.

État des swap le 02/05/2020 à 10h27 (uptime global : 2 jours) :

                                                total (Mo)  used (Mo)   free (Mo)  swappiness   vfs_cache_pressure
===== bastion =====              Swap:          1903          93        1810           1               100
===== admin =====                Swap:          1903         204        1699           1               100
===== dns =====                  Swap:           951           3         948           1               100
===== mail =====                 Swap:           951          40         911           1               100
===== sympa =====                Swap:           951         380         571           1               100
===== adl =====                  Swap:           951         127         824           1               100
===== lamp =====                 Swap:           951         112         839           1               100
===== agir =====                 Swap:           951         146         805           1               100
===== bots =====                 Swap:           951          42         909           1               100
===== dtc =====                  Swap:           951         133         818           1               100
===== drupal6 =====              Swap:           951          31         920           1               100
===== republique-numerique ===== Swap:           951          43         908           1               100
===== mumble =====               Swap:           951          22         929           1               100
===== candidatsfr =====          Swap:           951         311         640           1               100
===== pad =====                  Swap:           951         104         847           1               100
===== scm =====                  Swap:           951           9         942           1               100
===== pouet =====                Swap:           951         157         794           1               100
===== webchat =====              Swap:           951          12         939           1               100
===== photos =====               Swap:           951          88         863           1               100
===== cms-dev =====              Swap:           951          36         915           1               100
===== virola.april.org =====     Swap:          6143         176        5967           1               100
===== calamus.april.org =====    Swap:          6143         114        6029           1               100
===== galanga.april.org =====    Swap:           951          95         856           1               100

/proc/sys/vm/swappiness

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

swappiness

This control is used to define how aggressive the kernel will swap
memory pages.  Higher values will increase aggressiveness, 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.

The default value is 60.

/proc/sys/vm/vfs_cache_pressure

vfs_cache_pressure
------------------

This percentage value controls the tendency of the kernel to reclaim
the memory which is used for caching of directory and inode objects.

At the default value of vfs_cache_pressure=100 the kernel will attempt to
reclaim dentries and inodes at a "fair" rate with respect to pagecache and
swapcache reclaim.  Decreasing vfs_cache_pressure causes the kernel to prefer
to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will
never reclaim dentries and inodes due to memory pressure and this can easily
lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100
causes the kernel to prefer to reclaim dentries and inodes.

Increasing vfs_cache_pressure significantly beyond 100 may have negative
performance impact. Reclaim code needs to take various locks to find freeable
directory and inode objects. With vfs_cache_pressure=1000, it will look for
ten times more freeable objects than there are.

La valeur par défaut est 60.

Articles

https://haydenjames.io/linux-performance-almost-always-add-swap-space/

Questions

  • 1) alors que le swappiness est à 1, pourquoi ça swap sur les vm ?
  • 2) faut-il modifier le paramétrage ? swappiness à 0 ? vfs_cache_pressure à 1 ? vfs_cache_pressure à 0 ?
  • 3) comment différencier swap intelligent (page extrêmement rarement utilisée) du swap par manque de ram (celui qui explose les I/O) ?
  • 4) faut-il désactiver le swap sur les VM ?
    • A priori, non. Le swap est censé protéger des OOMKILL malheureux.

Demandes liées 1 (0 ouverte1 fermée)

Lié à Admins - Demande #4664: Améliorer la gestion du swap (suite)FerméChristian P. Momon17/08/2020

Actions
Actions

Formats disponibles : Atom PDF