Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the average load in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what is the average load in Linux, the article is very detailed, has a certain reference value, interested friends must read it!

What is average load?

Those familiar with Linux know that you can view the load average metric using the top uptime command.

Use man uptime to view Load average Explanation:

System load averages is the average number of processes that are either in a runnable or uninterruptable state. A process in a runnable state is either using the CPU or waiting to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg waiting for disk. The averages are taken over the three time intervals. Load averages are not normalized for the number of CPUs in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time.

Understand the key place, average load refers to the average number of processes in the runnable state and non-interruptible state in the system per unit time, referred to as the average number of active processes. It is worth noting that it has no direct relationship with CPU usage.

You can check the status stat of a process using ps aux, as noted in this article:

R state, Running / Runnable state, processes that are using or waiting for the CPU D state, Uninterruptible state (Disk Sleep ), processes that are in kernel-state critical processes and are non-interruptible.

D state why can not be interrupted, for example, the system calls the I/O response from the hardware device, in order to ensure the consistency of the data, before the disk device returns the data, it is not times other processes or interrupt interruption, if interrupted, it is easy to cause disk data and process data inconsistent problem. Thus, the non-interruptible (D) state is a system protection mechanism for processes and hardware devices.

The average number of active processes, strictly speaking, is the exponential decay average of the number of active processes (the rate at which a quantity declines is proportional to its value). Usually, it is understood as the number of active processes per unit time.

CPU utilization and load balancing

From the CPU point of view, Load average only reflects the number of processes occupying CPU per unit time, and CPU utilization has no direct relationship with the number of processes. We can use the command top vmstat to view CPU utilization. There are several indicators:

%us: CPU usage for user space programs (not scheduled by nice) %sy: CPU usage for system space, mainly kernel programs. % ni: CPU usage of programs scheduled through nice in user space. % id: idle cpu%wa: cpu runtime time waiting for io %hi: cpu handles hard interrupts %si: cpu handles soft interrupts %st: cpu stolen by virtual machine

How to Measure Reasonable Average Load

Generally speaking, if the Load average is lower than the number of CPUs, the machine performance meets the service demand. It doesn't matter if it exceeds some. The Load average does not directly represent the CPU utilization rate. It may be that there are more io blocks. When the Load average is higher than 70% of the number of CPUs, it may cause the process response to slow down, which may affect the normal function of the service.

Based on historical variation,

Generally speaking, top uptime provides load average indicators at three time points: 1 minute, 5 minutes, and 15 minutes. This reflects recent trends in the state of the system. In the actual production environment, we need to make long-term monitoring records. If there is an abnormal numerical change, such as the average load is twice that of the CPU, it is necessary to analyze and investigate the problem.

Comprehensive Analysis of Load Balance and CPU Utilization

The difference between the two types of indicators results in the following possible situations:

Load average high, CPU use high, either CPU-intensive processes (threads) running, or a large number of processes (threads) waiting for CPU scheduling Load average high, CPU use bottom, IO-intensive processes running Both are relatively low, normal Load average bottom, CPU use high, which does not exist

Simulation cases and tools

How do we analyze cases of different combinations of load balancing and CPU utilization metrics to find the source of the metric change?

Linux Arch 4.19 / 4 CPU / 8 GB Memory

tool list

stress system stress test tool

sysstat Performance Analysis Toolkit:

mpstat multicore CPU profiling tool, mp means multi processors pidstat process profiling tool, pid means process ID. It is used to view metrics such as CPU, memory, I/O, and context switches for processes

simulation scenario

Using stress, you can simulate the following scenarios

CPU-intensive processes

#Simulate a process, CPU usage 100%, time limit 600sstress --cpu 1 --timeout 600

IO-intensive processes

stress-i option, spawn N workers spinning on sync()

#Simulate a process executing syncstress -i 1 --timeout 600

Scenarios of mass processes

#Simulate 16 processes, CPU usage 100%, time limit 600sstress --cpu 16 --timeout 600

Tool indicators

mpstat -P ALL 5 monitors all CPUs, outputs a set of data every 5 seconds, notes the metrics %usr usage, %iowait IO blocking time, from which you can determine whether CPU intensive or IO intensive pidstat -u 5 1 counts the data of processes that have used CPUs within 5 seconds of each other, notes the metrics %usr usage, %wait for CPU usage, from which you can determine whether there are too many processes (threads)

That's all there is to what average load is in Linux, thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report