环境
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 5
- Red Hat OpenStack Platform (all versions)
问题
- If I add several hundred gigabytes of RAM to a system, do I really need several hundred gigabytes of swap space?
- What are the recommended swap size settings for Red Hat Enterprise Linux 5, Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 8?
- What are the recommended swap size settings for Red Hat OpenStack Platform?
- How much swap should I assign to a virtual guest, is the recommendation different from a normal system?
决议
-
In years past, Red Hat recommended a linear increase to the amount of swap space on a system as the amount of RAM increased. Specifically, the recommendation was that swap space should equal twice the amount of RAM when the system has up to 2 GB of RAM installed, and the amount of RAM plus 2GB when the system has more than 2GB of RAM installed.
-
This advice is no longer practical for modern computers and modern platforms as amounts of installed RAM have increased to multiple terabytes on some systems. The following guidelines are a better way to determine the amount of swap space a system should have:
Red Hat Enterprise Linux 5
Amount of installed RAM | Recomended swap space |
---|---|
4GB or less | 2GB swap space |
4GB - 16GB | 4GB swap space |
16GB - 64GB | 8GB swap space |
64GB - 256GB | 16GB swap space |
Note: A swap space of at least 100GB is recommended for systems with over 140 logical processors.
Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 8, Red Hat OpenStack Platform (all versions)
Amount of installed RAM | Recommended swap space | Recommended swap space if allowing for hibernation |
---|---|---|
2GB or less | Twice the installed RAM | 3 times the amount of RAM |
> 2GB - 8GB | The same amount of RAM | 2 times the amount of RAM |
> 8GB - 64GB | At least 4GB | 1.5 times the amount of RAM |
> 64GB or more | At least 4GB | Hibernation not recommended |
Note: A swap space of at least 100GB is recommended for systems with over 140 logical processors or over 3TB of RAM.
-
The following items also influence the decision on how much swap space should be allocated:
- Do specific application requirements exist? Applications may have been written with a specific amount of swap space in mind. If this is the case, the system should be set up with the amount of swap that is recommended by the application vendor.
- Do other requirements exist? Workstations and laptops may use hibernation functions that store the RAM contents in the swap area. In this case, the swap space would need to be equal to or greater than the amount of RAM installed in the system to enable hibernation.
- Assigning swap as 'last effort' memory While the block devices hosting swap are generally many times slower than RAM, it is useful to have swap as another layer of memory that's available when needed. In the case of applications with high memory utilization, swap space can allow memory to be swapped out to disk to delay or prevent the termination of applications by the OOM killer.
-
Virtual guests: for virtual guests, the same considerations as for physical systems apply. Also for these, using a bit of swap can influence the behaviour of a process requesting more and more memory, so the process gets slowed down first (leaving time for a sysadmin to manually fix the situation) before eventually also the swap is exhausted and the OOM killer terminates processes. If the memory written by the processes is not exceeding the available swap, the system will just experience a temporary slowdown.
-
Red Hat OpenStack Platform: Red Hat OpenStack Platform Director swap space is configured at install time following the standard RHEL partitioning guidance provided above. To configure swap space for Director deployed overcloud nodes please refer to Solution 4005521.
https://access.redhat.com/solutions/15244