linux平均负载什么意思_在Linux中什么是平均负载?

linux平均负载什么意思

Load Average in Linux is a metric that is used by Linux users to keep track of system resources. It also helps you monitor how the system resources are engaged.

Linux中的平均负载是Linux用户用来跟踪系统资源的指标。 它还可以帮助您监视系统资源的使用方式。

While Load Average is one of the most fundamental metrics of resource usage, the metric is pointless unless you understand what it tells a user. In this tutorial, we will help you understand what Load Average in Linux means.

尽管平均负载是资源使用情况的最基本指标之一,但是除非您了解它告诉用户的内容,否则该指标毫无意义。 在本教程中,我们将帮助您了解Linux中的平均负载含义。

Further, we will discuss some easy methods to monitor the load average for your system.

此外,我们将讨论一些简单的方法来监视系统的平均负载。

Linux中平均负载的基础 (Basics of Load Average in Linux)

To understand the Load Average in Linux, we need to know what do we define as load. In a Linux system, the load is a measure of CPU utilization at any given moment.

要了解Linux中的平均负载,我们需要知道我们定义的负载是什么。 在Linux系统中,负载是任何给定时刻CPU利用率的度量。

It refers to the number of processes which are either currently being executed by the CPU or are waiting for execution.

它指的是当前正在由CPU执行或正在等待执行的进程数。

An idle system has a load of 0. With each process that is being executed or is on the waitlist, the load increases by 1.

空闲系统的负载为0。对于每个正在执行的过程或在等待列表中的进程,负载将增加1。

On its own, the load doesn’t give any useful information to the user. The load can change in split seconds. This is because the number of processes using or waiting for the CPU time doesn’t remain constant. This is why we use Load Average in Linux to monitor resource usage.

负载本身不会给用户提供任何有用的信息。 负载可以瞬间变化。 这是因为使用或等待CPU时间的进程数未保持恒定。 这就是为什么我们在Linux中使用平均负载来监视资源使用情况的原因。

熟悉Linux中的平均负载 (Getting familiar with the Load Average in Linux)

Load average, as the name suggests, depicts the average load on a CPU for a set time interval. These values are the number of processes waiting for the CPU or using it in the given period.

顾名思义,平均负载表示在指定时间间隔内CPU的平均负载。 这些值是在给定时间段内等待CPU或使用它的进程数。

While most people are used to the load percentages shown in Windows systems, Load Average in Linux is depicted as three different decimal values.

虽然大多数人习惯于Windows系统中显示的负载百分比,但Linux中的“平均负载”被描述为三个不同的十进制值。

Load Average
Load Average
平均负载

Have look at the image above where it says “load average: 0.03, 0.03, 0.01”

看上图显示“平均负载:0.03、0.03、0.01”的图片

Going left to right:

从左到右:

  • The first value depicts the average load on the CPU for the last minute.

    第一个值描述了最后一分钟CPU的平均负载。
  • The second gives us the average load for the last 5-minute interval

    第二个为我们提供了最近5分钟间隔的平均负载
  • The third value gives us the 15-minute average load

    第三个值提供了15分钟的平均负载

This helps a user get an idea of how the CPU is being utilized by the processes on a system over time.

这有助于用户了解一段时间内系统上的进程如何利用CPU。

While a load of 1 can mean approximately 100% resource usage on a single processor system, such systems are practically non-existent today. Unless you haven’t upgraded your system in over a decade, your system should run on a multi-core processor.

虽然负载为1可能意味着在单个处理器系统上大约100%的资源使用,但是今天实际上不存在这样的系统。 除非您十年以上没有升级系统,否则您的系统应在多核处理器上运行。

For a dual-core processor, a load of 1 means that 1 core was 100% idle. This translates to approximately 50% CPU usage. Similarly, it would represent 25% CPU usage for a quad-core processor.

对于双核处理器,负载为1表示1个内核处于100%空闲状态。 这相当于大约50%的CPU使用率。 同样,对于四核处理器,这将代表25%的CPU使用率。

Load Average in Linux takes into account the waiting threads and tasks along with processes being executed. Also, it is an average value instead of being an instantaneous value.

Linux中的平均负载考虑了等待的线程和任务以及正在执行的进程。 另外,它是平均值而不是瞬时值。

However, an approximate idea of resource usage can be determined by the ratio of Load Average over the number of cores of your processor. While it is not an exact value for the CPU utilization at any given time, it can be helpful for resource monitoring.

但是,可以通过平均负载与处理器内核数之比来确定资源使用的大致概念。 尽管在任何给定时间它都不是CPU利用率的确切值,但它对于资源监视很有帮助。

如何在Linux中检查平均负载 (How to Check the Load Average in Linux)

Now that we know what Load Average represents, we will discuss a few ways to check the Load Average in Linux. Load Average can be looked up in three common ways. 

现在我们知道平均负载代表什么了,我们将讨论几种检查Linux平均负载的方法。 可以通过三种常见方式查找平均负载。

1.使用正常运行时间命令 (1. Using uptime command)

The uptime command is one of the most common methods for checking the Load Average for your system. To use the uptime command, we simply open the command line and type the following.

uptime命令是检查系统平均负载的最常用方法之一。 要使用uptime命令,我们只需打开命令行并键入以下内容。


uptime
Uptime Command Load Average
Uptime Command Load Average
正常运行时间命令平均负载

This displays the amount of time that our system has been up for, along with the number of active users and the Load Average for our system. The following screenshot shows what should you see when you use the uptime command on your system.

这将显示我们的系统已使用的时间,以及活动用户的数量和系统的平均负载。 以下屏幕截图显示了在系统上使用uptime命令时应该看到的内容。

As you can see, the load average for the last minute is 0.03. For the last five minutes and fifteen minutes, the Load Average values are 0.03 and 0.01 respectively.

如您所见,最后一分钟的平均负载为0.03。 对于最后五分钟和十五分钟,平均负载分别为0.03和0.01。

2.使用top命令 (2. Using top command)

Another way to monitor the Load Average on your system is to utilise the top command in Linux. To do so, simply open the terminal and type this.

监视系统平均负载的另一种方法是利用Linux中的top命令。 为此,只需打开终端并输入即可。


top

This will open the top interface in your terminal. Unlike the uptime command, this gives an in-depth view of the resource usage for your system.

这将打开终端的顶部界面。 与uptime命令不同,这可以深入了解系统的资源使用情况。

The following screenshot shows what should you see when you use the top command on your system.

以下屏幕截图显示了在系统上使用top命令时应该看到的内容。

Top Command Load Average
Top Command Load Average
最高命令平均负载

As you can see in the top-most line, the load average for the last minute is 0.34. For the last five minutes and fifteen minutes, the Load Average values are 0.14 and 0.405 respectively.

正如您在最上面的行中看到的那样,最后一分钟的平均负载为0.34。 对于最后五分钟和十五分钟,平均负载分别为0.14和0.405。

3.使用扫视工具 (3. Using glances tool)

The glances tool is a system monitoring tool which works similar to the top command. It gives a detailed overview of the system resource usage. To use the glances tool on your system, you need to install its package using this command.

扫视工具是系统监视工具,其工作原理与top命令相似。 它提供了系统资源使用的详细概述。 要在您的系统上使用glances工具,您需要使用此命令安装其软件包。


sudo apt-get install glances

Once you are done with the installation, type the following in your terminal.

安装完成后,在终端中键入以下内容。


glances

This will open the glances interface in your terminal. Unlike the top command, this gives the number of processor cores available along with the Load Average for your system.

这将在您的终端中打开扫视界面。 与top命令不同,它给出了可用处理器核心的数量以及系统的平均负载。

The following screenshot shows what should you see when you use the glances command on your system.

以下屏幕截图显示了在系统上使用glances命令时应该看到的内容。

Glances Command Load Average
Glances Command Load Average
概览命令平均负载

As you can see in the highlighted region, the load average for the last minute is 0.14. For the last five minutes and fifteen minutes, the Load Average values are 0.12 and 0.05 respectively.

在突出显示的区域中可以看到,最后一分钟的平均负载为0.14。 对于最后五分钟和十五分钟,平均负载值分别为0.12和0.05。

结语 (Wrapping up)

The Load Average in Linux is an essential metric to monitor the usage of system resources easily. Keeping the load average in check helps ensure that your system does not experience a crash or sluggish sessions.

Linux中的平均负载是一项重要指标,可以轻松地监视系统资源的使用情况。 保持平均负载水平有助于确保系统不会出现崩溃或会话变慢的情况。

We hope this tutorial was able to help you to get familiar with the concept of Load Average in Linux.

我们希望本教程能够帮助您熟悉Linux中平均负载的概念。

翻译自: https://www.journaldev.com/39214/load-average-in-linux

linux平均负载什么意思

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值