home page » operating system » linux » The most commonly used commands for Linux performance tuning

The most commonly used commands for Linux performance tuning

 

#CPU performance evaluation

Use the following command to find out whether the CPU has performance bottlenecks, and then combine top After further checking with commands such as ps, you can find out which processes are causing excessive CPU load

Vmstat command: View CPU load

[ blackfox@localhost ~]$vmstat 2 3 # Print 3 times every 2s

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----

r b swpd free buff cache si so bi bo in cs us sy id wa st

4 0 0 244824 932 497892 0 0 0 0 3 9 0 0 100 0 0

0 0 0 244824 932 497892 0 0 0 0 38 91 0 1 99 0 0

0 0 0 244824 932 497892 0 0 0 0 40 90 0 1 99 0 0

Sar command: statistics CPU performance

Scenario: In a multi CPU system, The overall utilization rate of CPU is not high, but the system application response is slow. Conclusion: A single thread only uses one CPU, resulting in a 100% CPU utilization rate and inability to process other requests, while other CPUs are idle, which leads to a low overall CPU utilization rate and slow application.

#Sar - P 0 3 5 # Make statistics on the first CPU

[ blackfox@localhost ~]$sar - u 3 5 # Display CPU utilization every 3s for 5 times

Linux 3.10.0-327.el7.x86_64 (localhost.localdomain) 01/22/2017 _x86_64_ (1 CPU)

07:35:52 AM CPU %user %nice %system %iowait %steal %idle

07:35:55 AM all 0.00 0.00 0.00 0.00 0.00 100.00

07:35:58 AM all 0.00 0.00 0.34 0.00 0.00 99.66

07:36:01 AM all 0.34 0.00 0.34 0.00 0.00 99.32

07:36:04 AM all 0.00 0.00 0.34 0.00 0.00 99.66

07:36:07 AM all 0.34 0.00 0.00 0.00 0.00 99.66

Average: all 0.14 0.00 0.20 0.00 0.00 99.66

Iostat command: View CPU usage

[ blackfox@localhost ~]$ iostat -c

Linux 3.10.0-327.el7.x86_64 (localhost.localdomain) 01/22/2017 _x86_64_ (1 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle

0.13 0.00 0.23 0.01 0.00 99.63

The uptime command: 1, 5, 15 minute average load

Experience: 8-core CPU, The three values of load average are more than 8 for a long time, indicating that the load is high and will affect the system performance.

[ blackfox@localhost ~]$ uptime

07:54:27 up 17 days, 16:56, 1 user, load average: 0.00, 0.02, 0.05

#Memory performance evaluation

Free command: view memory usage

Experience: Available memory/physical memory<20%, indicating memory shortage and need to increase memory

[ blackfox@localhost ~]$free - m # - m takes MB as the unit, and continuously monitors during - s period

total used free shared buff/cache available

Mem: 977 249 240 49 487 488

Swap: 2048 0 2048

Vmstat command: monitor memory

Sar - r command: monitor memory (Centos installs yum install sysstat)

#Disk I/O performance evaluation

Sar - d command: count disk I/O status

Experience:

  • 1. Normal svctm<await.
  • 2、 The svctm is close to await, which means there is almost no I/O waiting, and the performance is very good
  • 3、 CPU/memory combination/too many requests will increase svctm
  • 4. % util is close to 100%, indicating I/O full load.

[ blackfox@localhost ~]$ sar -d

Linux 3.10.0-327.el7.x86_64 (localhost.localdomain) 01/22/2017 _x86_64_ (1 CPU)

12:00:01 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util

12:10:01 AM dev8-0 0.10 0.00 0.89 9.03 0.00 3.97 1.10 0.01

12:20:01 AM dev8-0 0.05 0.00 0.35 7.56 0.00 64.63 61.70 0.28

12:30:01 AM dev8-0 0.02 0.00 0.16 7.08 0.01 254.77 128.

Iostat - d command:

[ blackfox@localhost ~]$ iostat -dx /dev/sda3

Linux 3.10.0-327.el7.x86_64 (localhost.localdomain) 01/22/2017 _x86_64_ (1 CPU)

Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util

sda3 0.00 0.01 0.01 0.05 0.21 0.34 17.98 0.00 41.36 30.56 42.60 7.77 0.05

#Network performance evaluation

Ping command: check network connectivity

Netstat command: - i View network interface information, - r Detect system routing table information

Sar - n command: display system network operation status

[ blackfox@localhost ~]$sar - n DEV 2 3 # DEV: network interface, EDEV: network error statistics, SOCK: socket information, FULL: Display all

Linux 3.10.0-327.el7.x86_64 (localhost.localdomain) 01/22/2017 _x86_64_ (1 CPU)

09:26:26 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s

09:26:28 AM eno16777736 0.00 0.00 0.00 0.00 0.00 0.00 0.00

09:26:28 AM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Traceroute command: trace the transmission path of data packets

Nslookup command: judge DNS resolution information

#Dynamic monitoring performance

Watch command: dynamic monitoring, executed once every 2 seconds by default, and the execution results are updated on the screen

[ blackfox@localhost ~]$watch - n 3 - d free # - n Repeat execution time, - d Highlight changes

Every 3.0s: free Sun Jan 22 09:21:48 2017

total used free shared buff/cache available

Mem: 1001332 256792 245500 50948 499040 498864

Swap: 2098172 0 2098172

Original link: The most commonly used commands for Linux performance tuning , Please indicate the source for reprinting!

fabulous three