Analyze the impact of Swap space on performance

Source: Internet
Author: User
Analyze the impact of Swap space on performance when the system's physical memory is insufficient, a part of the physical memory needs to be released for the current running program. The released space may come from some programs with no operations for a long time.
Analyze the impact of Swap space on performance when the system's physical memory is insufficient, a part of the physical memory needs to be released for the current running program. The released space may come from some programs that haven't been operated for a long time. the released space is temporarily saved to the Swap space and will be executed by those programs, then, the stored data is restored from the Swap partition to the memory. In this way, the system always performs Swap switching when the physical memory is insufficient. The size of each page is the same as that of the memory page, which facilitates data exchange between the Swap space and the memory. In the earlier version of Linux, when implementing the Swap space, the first page of the Swap space is used as a Bit map for all the Swap space pages ). This means that each bit on the first page corresponds to a page of Swap space. If this parameter is set to 1, Swap is available on this page. if it is set to 0, this page is a bad block and cannot be used. If you allocate too much Swap space, the disk space will be wasted, and the Swap space is too small, the system will encounter an error. If the system's physical memory is used up, the system will run slowly but still run. if the Swap space is used up, the system will encounter an error. For example, a Web server can generate multiple service processes (or threads) based on the number of requests. if Swap space is used up, the service process cannot be started, generally, the error "application is out of memory" may occur. in severe cases, the service process may be deadlocked. Therefore, Swap space allocation is very important. Generally, Swap space should be greater than or equal to the size of physical memory, and the minimum should not be less than 64 M. Generally, the size of Swap space should be 2-times that of physical memory. However, different applications should have different configurations: for a small desktop system, only a small Swap space is required, A large server system requires different sizes of Swap space depending on the situation. Especially for database servers and Web servers, as the access traffic increases, the requirements for Swap space will also increase. for detailed configuration, see the description of each server product. In addition, the number of Swap partitions has a great impact on the performance. Because Swap operations are disk IO operations, if there are multiple Swap areas, the Swap space allocation will operate on all Swap in turn, this will greatly balance the IO load and speed up Swap switching. If there is only one swap area, all the swap operations will make the swap area very busy, so that the system is waiting for most of the time, the efficiency is very low. The performance monitoring tool will find that the CPU is not very busy at this time, but the system is slow. This shows that the bottleneck lies in I/O, and it cannot be solved by increasing the CPU speed. The number of Swap spaces and Swap partitions affects the performance.
 

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.