How many swap partitions are suitable for Linux servers?

Source: Internet
Author: User

Talking about how many swap partitions are set for a Linux server a customer called a year ago, saying that a Linux server in their information center is running slowly, and the system service has intermittently stopped responding, let me help you solve this problem. When www.2cto.com arrived at the site, it was found that the physical memory of the server was 16 GB, but when it was first installed, the system administrator allocated only 2 GB of virtual memory. Check the memory usage. The physical memory is not completely exhausted, but the virtual memory is exhausted. The CPU load and disk IO of the entire system are very high. Knowing the problem is caused by insufficient swap partitions, the solution is to increase the virtual memory to 8 GB through virtual files, and the system running status is obviously improved. In fact, the virtual memory is not used until the physical memory is used up. whether to use swap as much as possible or not, there is a parameter control in the kernel space. [Root @ server ~] # Cat/proc/sys/vm/swappiness 60 swappiness = 0 indicates that the physical memory is used to the maximum extent, and then the swap space is used. swappiness = 100 indicates that swap partitions are actively used, in addition, the data in the memory is promptly moved to the swap space. How many swap partitions are suitable for servers with dozens of GB or hundreds of GB of physical memory? For this reason, I reference a text section in the official RedHat library for analysis. Currently, Red Hat recommends that the swap partition size be linearly proportional to the physical memory size of the system. However, in systems with less than 2 GB physical memory, the swap partition size should be set to twice the memory size. If the memory size is greater than 2 GB, the swap partition size should be the physical memory size plus 2 GB. The reason is that the larger the physical memory in the system, the greater the load on the memory. Www.2cto.com, however, if the physical memory size is expanded to several hundred GB, it makes no sense to do so. In fact, the size of swap partitions in the system does not depend on the amount of physical memory, but on the memory load in the system. Red Hat Enterprise Linux 5 can work in this situation: there is no swap partition at all, and the anonymous Memory Page and shared memory page in the system are less than 3/4 of the physical memory. In this case, the system will lock anonymous memory pages and shared memory pages in the physical memory, and use the remaining physical memory to buffer the file system data (pagecache ), when the memory is exhausted, the system kernel only recycles the pagecache memory. Consider the following situations: 1) It is difficult to determine the memory load when installing the system, how to set the swap partition size 2) The larger the physical memory in the system, the less swap partitions required, in Red Hat Enterprise Linux 5, the following are rules for setting the appropriate swap partition size: Note: Applicable to RHEL 5.x( CentOS 5.x) "5 version"
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.