Linux memory performance metrics, CPU performance metrics

Source: Internet
Author: User
Tags cpu usage

Memory performance Metrics

Memory-based concepts

Execute the top command first to see the relevant parts of the memory in the results

# Top

What are the VIRT,RES, andswaps ?

The following 3 concepts are:

Physical Memory Resident- RES

Actual memory space RAM

Swap Area Swapped- SWAP

When there is not enough physical memory, the operating system will swap out the infrequently used pages in memory to disk space

Swap into physical memory when the page being swapped out needs to be accessed

So the swap area is used to temporarily store the infrequently used content in memory, and feel like a small repository of memory

Virtual Memory Virtual- VIRT

Virtual memory = physical memory + Swap Area

When the program is operating memory, it is actually manipulating the address in virtual memory, the operating system is responsible for mapping to the physical address, or the swap area

Quick understanding of memory status

# free

Main indicators

Total-Overall physical memory size

used -The amount of physical memory already in use

Free-Idle physical memory

Shared-the size of multiple processes sharing memory

buffers/cached -memory size as cache

Swap -The use state of the interaction space

A few common questions about memory:

1, less free space, is not enough memory?

In fact, the free physical space in Linux is often very small, and Linux uses memory thinking about

Linux tries to increase memory usage, often by caching the contents of the disk to memory, to speed up

Linux thinks that memory is idle, it's better to cache it.

When there is not enough memory, Linux frees up the cache to be used by the program that really needs it.

2. What is the difference between buffer and cache?

Buffer caches the metadata for disk files, such as file attributes, directory structure, and so on.

The cache caches the actual file contents.

3, how to determine the real lack of memory?

There are 2 obvious manifestations of memory shortage

(1) Continuous memory swap in and out

(2) More main pages are interrupted

The concept of the main pages break:

Page break contains primary/secondary pages interrupt

The page is broken, and the target is found in memory.

The main missing pages are missing in memory and need to be found on the disk.

So more main pages interrupt means more access to the disk

The indicator can be viewed via the SAR command

# sar-b 1 3

pgpgin/pgpgout is the swap-in and swap out of memory

Fault page break

majflt main missing pages interrupt

vmstat command can also view some memory information

# vmstat 1 5

Memory part is the RAM information

Si/so is swapped-in swap out

Supplemental skills

When the top command is executed, the SWAP column is usually not displayed and you need to specify the display

In the top interface, click 'f', enter the column editing mode, press the letter 'P', you will see the Swap column is selected, and then press the enter key to return to the top interface, the Swap column is displayed

CPU Performance Metrics

CPU performance metrics can be viewed in two ways: static , dynamic

static indicators mainly include:

CPU model, frequency, number of cores, cache, etc.

dynamic indicators mainly include:

What are the average CPU load conditions, CPU usage, and CPU-consuming processes?

To view static information:

In the process of running the server, we generally pay less attention to the static information of the CPU, but when we first get a server, we will be very concerned about static information

Well, based on this information, how much pressure to allocate to this server

View by /proc/cpuinfo file

View dynamic information:

When the server slows down, you will usually see if the load on the CPU is too high, if it is higher, and then see which processes are the most expensive CPU,CPU usage is also an important indicator, let us know what part of CPU consumption

01. CPU Load Condition

The load information provides an intuitive understanding of the CPU's stress situation, and Linux gives the average load value for the last 1 minutes, 5 minutes, 15 minutes

You can view it with the top command

Uptime commands more concise and intuitive

After viewing the load value, how can I tell if the CPU load is too high?

There is an empirical standard:

CPU Load Upper value = number of cores of CPU * 4

For example, a 4-core CPU, the CPU load is best not more than 16, otherwise, the CPU pressure is very large

Like a supermarket, there are 4 cashier, if there are 16 customers in line checkout, each window 4 people, customers can accept, cashier will not feel pressure

02, CPU-consuming main process

When we find that the CPU load is too high, we'll want to know who's doing the CPU so much.

View with the top command

Sort processes based on CPU usage with the PS command

# Ps-aux--sort-pcpu | Less

03. CPU Utilization

View with the top command

You can also view the usage status of each core, and then press the number 1 key after performing top to list the usage per CPU

There are several key information items

ID -The idle degree of the CPU

US -User Process CPU utilization

SY -System Process CPU utilization

wa -io wait condition

St -If a virtual machine is running on the system, this item shows how the VM uses the CPU

Linux memory performance metrics, CPU performance metrics

Related Article

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: 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.