The commands for performance monitoring analysis include the following:
1, Vmstat
2. Sar
3, Iostat
4. Top
5. Free
6, uptime
7, Netstat
8, PS
9, Strace
10, Lsof
Command Description:
The free command is the most common command for monitoring Linux memory usage
Syntax format:
free [options]
Parameter description:
-M: View content usage in m (default is KB)
-B: View memory usage in bytes
-S: Allows uninterrupted monitoring of memory usage over a specified time period
-K: Display memory usage in kilobytes
-G: Display memory usage in gigabytes
-O: Do not display buffer throttling columns
-T: Show memory sum column
-V: Display version information
The free command performs the following results:
Description of each field:
Total: Amount of physical memory
Used: Size used
Free: Size available for idle
Shared: Total amount of memory shared by multiple processes
buffers/cached: Size of the disk cache
Line three (-/+ Buffers/cache)
Used: How much has been used
Free: How many are available
Line four is swap partition swap, which is what we usually call virtual memory.
The second row differs from the third row used/free:
The difference between the two is that the first line is from the OS point of view, because for the os,buffers/cached are all belong to be used, so his available memory is 1651532KB, the used memory is 287436KB, which includes, the kernel (OS) uses + Application (X, ORACLE,ETC) uses the +buffers+cached.
The third line refers to the application from the point of view, buffers/cached is equal to the availability of the application, because buffer/cached is to improve the performance of the file read, when the application needs to use memory, buffer/cached will be quickly recycled.
So from the application's point of view, available memory = System Free memory+buffers+cached.
If the available memory for this machine condition is:
1864980=1651532kb+23688kb+760kb
We use names such as Total1, Used1, Free1, Used2, and free2 to represent the values of the above statistic data.
You can sort out the following equation:
Total1 = used1 + free1
Total1 = Used2 + free2
used1 = buffers1 + cached1 + used2
Free2 = buffers1 + cached1 + free1
The difference between cache and buffer:
Cache: Caching is a small but high-speed memory that sits between the CPU and the main memory. Because the CPU speed is much higher than the main memory, the CPU accesses the data directly from memory to wait for a certain period of time, the cache holds the CPU just used or recycled part of the data, when the CPU again use the part of the data can be directly called from the cache, which reduces the CPU waiting time, The efficiency of the system is high. The cache is also divided into one-level cache (L1 cache) and level two cache (L2 cache), L1 cache is integrated within the CPU, L2 cache is usually soldered to the motherboard, and is now integrated into the CPU, with a common capacity of 256KB or 512KB L2 Cache.
Buffer: An area where data is transferred between devices that are not synchronized or that have different priority levels. Through buffers, you can reduce the number of waits between processes, so that when you read data from a slow device, the operating process of a fast device is uninterrupted.
Buffer and cache in free: (They are all memory-intensive):
Buffer: Memory as buffer cache, which is the read and write buffer of the block device
Cache: As the page cache memory, the file system cache
If the cache has a large value, it indicates that the cache has a high number of files. If the files that are frequently accessed are available to the cache, the disk's read Io bi is very small.
The difference between buffers and cached
Cache (cached) is to save the read data, re-read if hit (find the required data) do not read the hard disk, if not hit the hard drive. The data will be organized according to the frequency of reading, the most frequently read content in the most easily found in the location, the content is no longer read to the back row, until removed from it.
Buffer (buffers) is based on the disk read-write design, the decentralized write operations centralized, reduce disk fragmentation and hard disk repeatedly seek, thereby improving system performance. Linux has a daemon that periodically empties buffered content (that is, writes like a disk) or manually empties the buffer via the Sync command. For example: I have a ext2 u disk here, I went to the inside CP a 3M MP3, but the U disk's light does not beat, after a while (or manually input sync) u disk light will beat up. The buffering is emptied when the device is uninstalled, so there are times when uninstalling a device takes a few seconds.
Modifying the number to the right of vm.swappiness in/etc/sysctl.conf can adjust the swap usage policy at the next boot. The number range is 0~100, and the larger the number, the more likely it is to use swap. The default is 60, you can change it to try.
Both are data in RAM. In a nutshell, buffer is about to be written to disk, and the cache is read from disk.
Buffer is allocated by various processes and is used in areas such as input queues, a simple example where a process requires multiple fields to be read, and before all fields are read into full, the process saves the previously read-in fields in buffer.
The cache is often used on disk I/O requests, and if more than one process accesses a file, the file is made into a cache for next access, which provides system performance.
Next, explain when the memory will be exchanged, and by what side:
When the available memory is less than the rated value, a meeting is exchanged; the command to view the rating:
#cat/proc/meminfo
The exchange will reduce the number of physical pages used in the system in three ways:
1. Reduce the buffer and the size of the page cache,
2. Swap out the memory page of the System V type
3. Swap out or discard the page. (Application occupies a memory page, that is, insufficient physical memory).
In fact, a small amount of swap use does not affect the performance of the system.
Common operations
Free//In kilobytes, explicit system memory usage
Free-ml-s 1/Per second in M, explicit system memory detail usage.
Free-c 4-s 2//KB, explicit system memory usage every 2 seconds, total display 4 times
FREE-T//Display memory usage information in the form of a sum
Free-s 10//Periodic query memory usage information, execute a command every 10s
Reference Documentation:
Https://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316438.html
Https://www.cnblogs.com/peida/archive/2012/12/25/2831814.html
http://blog.csdn.net/hylongsuny/article/details/7742995
Linux Performance Monitoring Analysis command (v)-free command Introduction