Linux performance and tuning guide 3.3 memory bottleneck

Source: Internet
Author: User

3.3 memory bottleneck
On a Linux system, using programs run at the same time.
These programs support multiple users, and some processes are more used than others.
Some of these programs use a portion of memory while the rest are "sleeping ."
When an application accesses cache, the performance increases because an in-memory access retrieves data,
Thereby eliminating the need to access slower disks.
In a linux system, multiple programs that support multiple users at the same time are running, and they have a small amount of memory usage;
The program should access the memory data more efficiently than the disk;


The OS uses an algorithm to control which programs will use physical memory and which are paged out.
This is transparent to user programs. Page space is a file created by the OS on a disk partition
To store user programs that are not currently in use. Typically, page sizes are 4 KB or 8 KB.
In Linux, the page size is defined by using the variable EXEC_PAGESIZE in the include/asm-<architecture>/param. h
Kernel header file. The process used to page a process out to disk is called pageout.
The operating system uses certain policies to determine which programs will use the physical memory and which programs will be replaced from the memory page;
These operations are transparent to the user program;
The page space is a file created by the operating system on the disk to store unused user programs;
Generally, the page size is 4 kb or 8 KB;
In Linux, the page size is determined by the kernel header file:
Include/asm-<architecture>/param. h
Macro EXEC_PAGESIZE in to define;
The page used by the process is replaced with a disk, which is called a Page Swap or page overflow;


3.3.1 Finding memory bottlenecks
Find memory bottlenecks
This part of the article uses the KDE tool KDE System Guard for memory detection;

KDE is short for Kool Desktop Environment.
A well-known operating system running on Linux, Unix, FreeBSD, and other operating systems,
The entire system uses the Qt library developed by TrollTech (now belongs to Digia ).
KDE and Gnome are the most popular desktop environment systems in Linux.

Start your analysis by listing the applications that are running on the server.
Determine how much physical memory and swap each application needs to run.
Figure 3-1 on page 83 shows KDE System Guard monitoring memory usage.

?
Figure 3.1 KDE System Guard memory monitoring

? The indicators in Table 3-1 can also help you define a problem with memory.

Table 3-1

Paging and swapping indicators
The meaning of page change and exchange
In Linux, as with all UNIX-based operating systems, there are differences between paging and swapping.
Paging moves individual pages to swap space on the disk;
Swapping is a bigger operation that moves the entire address space of a process to swap space in one operation.
In Linux, the distribution and exchange are different;
Page feed refers to moving an independent page to the swap space of the disk;
Swap is a larger operation, which moves the address space of the entire process to the swap space of the disk at one time;


Swapping can have one of two causes:
There are two reasons for the exchange.
. A process enters sleep mode.
Process enters sleep mode
This usually happens because the process depends on interactive action and editors, shells,
And data entry applications spend most of their time waiting for user input. During this time,
They are inactive.
This is usually because the process needs to interact with the editor, shell, and other applications, and the application needs to wait for user data input;
In this case, it is non-active;


. A process behaves poorly.
Abnormal process Behavior
Paging can be a serious performance problem when the amount of free memory pages falls
Below the minimum amount specified, because the paging mechanic is not able to handle
The requests for physical memory pages and the swap mechanic is called to free more pages.
This significantly increases I/O to disk and will quickly degrade a server's performance.
When the idle Memory Page is over an hour, page feed may cause serious performance problems,
Because the page feed mechanism cannot process physical memory page requests, the swap mechanism will call more idle memory pages.
This will greatly increase disk I/O and quickly reduce server performance.

If your server is always paging to disk (a high page-out rate), consider adding more memory.
However, for systems with a low page-out rate, it might not affect performance.
If the server is always changing pages (a high page rate), you need to consider increasing the memory;
Of course, when the system page feed rate is low, it will not affect the performance;

3.3.2 Performance tuning options
Performance adjustment options
It you believe there is a memory bottleneck,
Consider discovery Ming one or more of these actions:
If you confirm it is a memory bottleneck, you can use the following methods to solve it:
. Tune the swap space using bigpages, hugetlb, shared memory.
Adjust swap space, use large pages, large memory, and shared memory

. Increase or decrease the size of pages.
Increase or decrease the page size;
?
. Improve the handling of active and inactive memory.
Improve the processing of active and inactive memory;

. Adjust the page-out rate.
Adjust the page feed rate;
?
. Limit the resources used for each user on the server.
Restrict the available resources of each user on the server;

. Stop the services that are not needed, as discussed in "Daemons" on page 97.
Stop unnecessary services

. Add memory.
Increase memory;

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.