A brief introduction to Linux performance monitoring commands free

A brief introduction to Linux performance monitoring commands free

When the system encounters various IO bottlenecks, high memory usage, high CPU usage and other problems, how do we locate the error? Linux provides many commands to help us quickly locate errors. The free command is one of the most commonly used commands in Linux: it can view the system's memory status, including the server's total memory, used memory, and remaining unused memory, as well as the memory occupied by the buffer and cache.

$ free -m
total used free shared buffers cached
Mem: 994 787 207 0 121 227
-/+ buffers/cache: 437 557
Swap: 0 0 0

To fully understand the above three lines of data, first understand what buffer and cache are.

buffer: buffer

Buffer the data to solve the handover problem between slow and fast speeds; the fast speed needs to pass the data bit by bit to the slow speed area through the buffer. For example: when writing data from memory to hard disk, it is not written directly, but buffered to a certain size and then flushed to the hard disk.

A buffer is something that has yet to be "written" to disk.

cache: cache

To achieve data reuse, slow devices need to cache frequently used data, and the cached data can provide high-speed transmission to fast devices. For example: reading data from the hard disk and placing it in the cache area of ​​the memory will allow the same resource to be accessed much faster in the future.

A cache is something that has been "read" from the disk and stored for later use.

The buffer is used to store data to be output to the disk (block device), while the cache is used to store data read from the disk. Both are designed to improve IO performance.

After understanding the role of buffer and cache, the information displayed by free is easy to understand. Now let's analyze the meaning of each line of the free command output:

First row: Mem

The total memory 994 (total) = 787 (used) + 207 (free), used indicates the memory that has been used by the system, which includes the memory used by the application and the sum of the memory used for buffering and caching.

Second line: -/+ buffers/cache

-buffers/cache: 437(used) = 787(used) - 121(buffers) - 227(cached), 437 means that excluding the memory consumed by buffers and caches, the actual memory consumed by the application is 437M.

+buffers/cache: 557(free) = 207(free)+121(buffers)+cached(227), 557 means the system has 557M of available memory, because if there is a memory shortage, the memory occupied by buffers and cache can still be used by applications.

Third row: Swap

I have seen many articles that simply say no need to explain, but I want to explain here that Swap means swap partition, which is what we usually call virtual memory. You can use part of the disk space as memory. This space is called virtual memory. When the system memory is insufficient, the system will temporarily put those programs that are still resident in the memory but not currently running into the virtual memory.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the performance monitoring ideas of specified processes in Linux system based on Python
  • PHP+swoole+linux to achieve system monitoring and performance optimization operation example
  • Detailed explanation of using top command to analyze Linux system performance
  • Detailed explanation of Linux server status and performance related commands
  • Detailed explanation of Linux performance test pmap command
  • 20 Linux server performance optimization tips worth collecting
  • Tutorial on using http_load, a web performance stress testing tool, under Linux
  • Four ways to achieve web data synchronization under Linux (performance comparison)
  • Linux+Nginx+Php to build a high-performance WEB server
  • Linux performance monitoring tool nmon installation and usage tutorial analysis

<<:  How to use CSS custom variables in Vue

>>:  MySQL 8 new features: Invisible Indexes

Recommend

Keepalived+Nginx+Tomcat sample code to implement high-availability Web cluster

Keepalived+Nginx+Tomcat to achieve high availabil...

SQL implementation LeetCode (185. Top three highest salaries in the department)

[LeetCode] 185. Department Top Three Salaries The...

How to elegantly back up MySQL account information

Preface: I recently encountered the problem of in...

Example of compiling LNMP in Docker container

Table of contents 1. Project Description 2. Nginx...

How to use selenium+testng to realize web automation in docker

Preface After a long time of reading various mate...

Steps to export the fields and related attributes of MySQL tables

Need to export the fields and properties of the t...

Tutorial on Installing Nginx-RTMP Streaming Server on Ubuntu 14

1. RTMP RTMP streaming protocol is a real-time au...

The complete process of Docker image creation

Table of contents Preface Creation steps Create a...

Detailed example of locating and optimizing slow query sql in MySQL

Table of contents 1. How to locate and optimize s...

Oracle deployment tutorial in Linux environment

1. Environment and related software Virtual Machi...

js to achieve interesting countdown effect

js interesting countdown case, for your reference...

The difference between Display, Visibility, Opacity, rgba and z-index: -1 in CSS

We often need to control the hidden, transparent ...