Linux memory subsystem and common tuning parameters, linux subsystem Tuning

Source: Internet
Author: User

Linux memory subsystem and common tuning parameters, linux subsystem Tuning

1. memory subsystem

1> components:

Slab allocator

Buddy system

Kswapd

Pdflush

2> virtualization environment:

PA: process address;

HA: Virtual Machine address;

MA: Machine address;

Virtual Machine conversion: PA ----> HA

GuestOS (guest host), OS (host );

Shadow PT: Shadow list

3> Memory:

TLB: improves performance;

Hugetable page:

Used File System: Hugetlbfs;

Enable hugepages:

1) Modify/etc/sysctl. conf:

Vm. nr_hugepages = n

                    

2) Kernel parameter:

Hugepages = n

2. Create hugepages to be used by the application (you do not need to specify the file system type. The application will be called automatically when it is to be used. Generally, a large page is required for the MYSQL cache block ):

          

          

3. Strace:

1> strace-p PID *** view the system call of the startup process;

2> strace command: view the system call of the command;

Strace-c command: You can add-c to output only the abstract information in the command process;

-O: Save the tracing result to a file for subsequent analysis;

4. optimize the use of the memory subsystem:

1> minimize the overhead of small memory objects;

Slab cache:

2> reduce or delay the service time of the slow subsystem;

Filesystem metadata: buffer cache (slab cache) ==> use buffer cache to cache file metadata;

Disk IO: page cache ==> use page cache to cache disk io and accelerate read operations;

Interprocess communications: shared memory ==> use shared memory for inter-process communication;

Network IO: buffer cache, arp cache, connection ruacking ==> use buffer cache, arp cache, and connection tracking to improve Network I/O performance;

3> set the minimum idle KB of memory;

4> avoid excessive memory usage:

The excess physical memory usage is based on swap, which can be part of the physical memory;

              

0: Do not recycle dentries and inodes;

1-99: tend not to recycle;

100: The tendency is the same as that of page cache and swap cache;

100 +: tend to recycle;

Memory overflow (OOM): When the kernel finds that it cannot be used due to memory overflow, it will forcibly kill the process that occupies a large amount of memory;

5> adjust the ARP cache for network I/O (/proc/net/arp );

5. Optimization of memory related to inter-process communication:

1> inter-process communication types: messages, semaphores, and shared memory;

            

2> view the current limits of the three:

3> inter-process communication management commands:

Ipcs: view some message queues;

Ipcrm: deletes some expired message queues and releases the memory;

4> share memory and messages parameters:

Shm:

Shmmni: the maximum number of shared memory segments allowed at the system level;

Shmall: the maximum number of pages allocated to the shared memory at the system level;

Shmmax: the upper limit of a single shared memory segment;

Messages:

Msgmnb: Maximum number of message queues in bytes. The default value is 16384;

Msgmni: the maximum number of message queues at the system level;

Msgmax: the maximum size of a single message, in bytes;

5> manually clear the dirty cache and cache, and then recycle:

Sync:

Echo s>/proc/sysrq-trigger

Recycling:

Echo 1>/proc/sys/vm/drop_caches

              

1 to free pagecache

2 to free dentries and inodes

3 to free pagecache, dentries and inodes

6> Out-of-memory killer:

Oom_score:

-16-15: Help calculate oom_score

-17: disables the oom_killer for that process

6 Swap problems:

1> which pages will be swap:

Inactive page;

Anonymous page;

Swap cache: This effectively avoids resource competition;

2> How to Improve the Performance of swap:

Reducing the think time of swap means we use small swap partitions;

Reduce the number of accesses. Do not use swap as much as possible. Increase the physical memory. If not, add multiple swap partitions;

Reduce service time;

7. Monitor memory usage commands:

Sar-r: view memory activity;

Sar-R: Memory Conversion Rate;

Sar-W: cache space activity;

Sar-B: I/O usage. The report page is swapped in and out;

                    

                  

     

        

                  

                  

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.