Server load? top command/CPU usage/load average calculation method

when we learn to useLinux VPS server toBuilding websiteAfter that, it is necessary to understand the meaning of load average of various load averages, because we need to usetopThe command understands the completion status of the system and pays attention to the real-time changes of variables.

To understand this, it is necessary to understand the following variable descriptions.

Detailed explanation of top command load average

Server load? top command/CPU usage/load average calculation method

Here is a detailed instruction on how to use it ▼

top - 01:06:48 up 1:22, 1 user, load average: 0.06, 0.60, 0.48
Tasks: 29 total, 1 running, 28 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3% us, 1.0% sy, 0.0% ni, 98.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 191272k total, 173656k used, 17616k free, 22052k buffers
Swap: 192772k total, 0k used, 192772k free, 123988k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1379 root 16 0 7976 2456 1980 S 0.7 1.3 0:11.03 sshd
14704 root 16 0 2128 980 796 R 0.7 0.5 0:02.72 top
1 root 16 0 1992 632 544 S 0.0 0.3 0:00.90 init
2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
  • The first 5 lines of the statistics area are the statistics of the entire system.
  • Line 1 is the task queue information, withuptimeThe execution result of the command is the same.

Its contents are as follows:

  • 01:06:48 Current time
  • up 1:22 System running time in the format of hours:minutes
  • 1 user Number of currently logged in users
  • load average: 0.06, 0.60, 0.48 System load, which is the average length of the task queue.
  • The three values ​​are the average values ​​from 3 minute, 1 minutes, and 5 minutes ago to the present.
  • Lines 2 and 3 are process and CPU information.
  •  

When there are multiple CPUs, this content may exceed 2 lines.The content is as follows:

  • Tasks: 29 total total number of processes
  • 1 running Number of running processes
  • 28 sleeping Number of processes sleeping
  • 0 stopped Number of processes stopped
  • 0 zombie number of zombie processes
  • Cpu(s): 0.3% us The percentage of CPU occupied by user space
  • 1.0% sy The percentage of CPU occupied by kernel space
  • 0.0% ni The percentage of CPU occupied by processes whose priorities have changed in the user process space
  • 98.7% id idle CPU percentage
  • 0.0% wa Percentage of CPU time waiting for input and output
  • 0.0%hi
  • 0.0% Si

The following are the last two lines of memory information:

  • Mem: 191272k total total physical memory
  • 173656k used total physical memory used
  • 17616k free total free memory
  • 22052k buffers Amount of memory used as kernel cache
  • Swap: 192772k total total swap area
  • 0k used total swap area used
  • 192772k free total free swap area
  • 123988k total cached buffered swap area.

The contents of memory are swapped out to the swap area and then back into memory, but the used swap area has not been overwritten.

This value is the size of the swap area where the content already exists in memory.

When the corresponding memory is swapped again, it is no longer necessary to write to the swap area.

Detailed information about the process, displayed below the statistics area in each process information area.

First, let's understand what each column means.

column name meaning

  • PID process id
  • PPID parent process id
  • RUSER Real user name
  • UID The user id of the process owner
  • USER username of the process owner
  • GROUP the group name of the process owner
  • TTY The name of the terminal from which the process was started.Processes not started from a terminal are displayed as ?
  • PR priority
  • NI nice value.Negative values ​​indicate high priority, positive values ​​indicate low priority
  • P The last CPU used, only meaningful in a multi-CPU environment
  • %CPU The percentage of CPU time used since the last update
  • TIME The total CPU time used by the process, in seconds
  • TIME+ The total CPU time used by the process, in 1/100 seconds
  • %MEM The percentage of physical memory used by the process
  • The total amount of virtual memory used by the VIRT process, in kb. VIRT=SWAP+RES
  • The size of the virtual memory used by the SWAP process to be swapped out, in kb.
  • The size of the physical memory used by the RES process and not swapped out, in kb. RES=CODE+DATA
  • CODE The size of the physical memory occupied by the executable code, in kb
  • DATA The size of the physical memory occupied by the part other than the executable code (data segment + stack), in kb
  • SHR shared memory size, in kb
  • nFLT page faults
  • The number of pages modified since the last nDRT write.
  • S Process status.
  • D = uninterruptible sleep state
  • R = run
  • S = sleep
  • T=track/stop
  • Z = zombie process
  • COMMAND command name/command line
  • WCHAN If the process is sleeping, display the name of the sleeping system function
  • Flags task flags, refer to sched.h

linux load average debugging instructions

looking attopAfter the status displayed by the command, it needs to be optimized according to it, buttopThe command shows only the appearance, so we can passiostatOrvmstatOrder further observations.

vmstat to view system load

vmstat
procs -------memory-------- ----swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 100152 2436 97200 289740 0 1 34 45 99 33 0 0 99 0

processes

  • The r column represents the number of processes running and waiting for the CPU time slice. If it is greater than 1 for a long time, it means that the CPU is insufficient and the CPU needs to be increased.
  • The b column indicates the number of processes waiting for resources, such as waiting for I/O, or memory swapping, etc.

cpu indicates the usage status of the cpu

  • The us column shows the percentage of CPU time spent in user mode. When the value of us is relatively high, it means that the user process consumes a lot of CPU time, but if it is greater than 50% for a long time, it is necessary to consider optimizing the user's program.
  • The sy column shows the percentage of cpu time spent by the kernel process.Here, the reference value of us + sy is 80%. If us + sy is greater than 80%, there may be insufficient CPU.
  • The wa column shows the percentage of CPU time occupied by IO waits.
  • The reference value of wa here is 30%. If wa exceeds 30%, it means that the IO wait is serious. This may be caused by a large number of random accesses to the disk, or the bandwidth bottleneck of the disk or disk access controller (mainly block operations).
  • The id column shows the percentage of time the cpu is idle.

The following article explains how high the Linux Load Average is?

What should I do if the VPS load is too high?

Now my website cannot be accessed because the load is too high, what should I do?

top – 20:44:30 up 12 min, 1 user, load average: 2.21, 8.39, 6.48

  • Your server is self-managing, what you should do is check your server itself via SSH.
  • Check what is it running?What process and so on?
  • If necessary, try restarting the server.
  • If after restarting the server, the load is still too high, try to identify the overloaded process and stop it.
  • If necessary, restart the process (not the server) individually.
  • Or after consulting the customer service "why the VPS/server load is too high", there is still no way to do it, and finally the only way is to increase the server configuration.

How much space is suitable for a foreign trade company's website?

How to choose the right server configuration?Click the link below to view the daily average 1 IP server solution ▼

Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "Server Load? top command/CPU usage/load average calculation method", it will help you.

Welcome to share the link of this article:https://www.chenweiliang.com/cwl-1029.html

Welcome to the Telegram channel of Chen Weiliang's blog to get the latest updates!

🔔 Be the first to get the valuable "ChatGPT Content Marketing AI Tool Usage Guide" in the channel top directory! 🌟
📚 This guide contains huge value, 🌟This is a rare opportunity, don’t miss it! ⏰⌛💨
Share and like if you like!
Your sharing and likes are our continuous motivation!

 

Comment

Your email address will not be published. Required fields * Callout

scroll to top