Linux Common commands (6)-Performance bottleneck analysis (Java)

Source: Internet
Author: User

The Top:top command monitors CPU utilization, process state and memory utilization, and can detail how much CPU and how much memory each process consumes.
[email protected] sectionlocus]$ Top

Top-10:52:24 up, 21:31, 6 users, load average:1.67, 2.01, 1.83
tasks:665 Total, 2 running, 663 sleeping, 0 stopped, 0 zombie
Cpu (s): 7.3%us, 2.4%sy, 0.0%ni, 84.8%id, 4.6%wa, 0.0%hi, 1.0%si, 0.0%st

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
20042 Map 0 8681m 4.8g 10m S 165.4 30.7 59:46.66 java
3023 Root 0 150m 5464 R 74.2 0.0 84883:39 Redis-sentinel
8066 Root 0 0 0 0 D 2.5 0.0 11:10.48 flush-8:16

First line: 10:52:24 up, 21:31 current system time; 6 Users: There are currently 6 user login systems; load average:1.67, 2.01, 1.83 the three numbers are 1 minutes, 5 minutes, 15 minutes, respectively.
Second line: tasks:665 task (Process) Total 665, of which 2 runs, 663 sleep, stoped status of 0, zombie State (zombie) has 0
Third line: CPU status
6.7% the percentage of CPU occupied by US user space.
0.4% Sy Core Space consumes a percentage of the CPU.
0.0% NI changes the priority of the process to occupy a percentage of the CPU
92.9% ID Idle CPU percent
0.0% wa io waiting for CPU percentage
0.0% Hi Hard Interrupt (Hardware IRQ)% of CPU occupied
0.0% si soft interrupt (software interrupts)% of CPU occupied
In the top basic view, press the keypad number 1 to monitor the status of each logical CPU:
Top-13:44:20 up, Min, 7 users, Load average:3.32, 2.72, 2.25
tasks:664 Total, 2 running, 662 sleeping, 0 stopped, 0 zombie
Cpu0:14.8%us, 38.5%sy, 0.0%ni, 21.9%id, 0.0%wa, 0.0%hi, 24.8%si, 0.0%st
Cpu1:1.0%us, 40.8%sy, 0.0%ni, 0.3%id, 57.8%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu2:1.3%us, 4.0%sy, 0.0%ni, 94.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu3:0.0%us, 0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us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu20:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu21:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu22:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu23:0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
mem:16280412k Total, 16117744k used, 162668k free, 324536k buffers
swap:32767992k Total, 11516272k used, 21251720k free, 13336076k cached

[Email protected] sectionlocus]$ Vmstat
procs-----------Memory-------------Swap-------io------System-------CPU-----
R b swpd free buff cache si so bi bo in CS us sy ID WA St
1 1 12131504 163788 275616 8459504 0 0 29 23 0 0 8 2 90 0 0

R indicates the size of the running queue,
b indicates the number of threads in the block due to IO waiting,
In indicates the number of interrupts,
CS indicates the number of context switches,
The US represents the user's CPU time,
SYS indicates system CPU time,
WA represents the time that the CPU is idle due to IO wait,
The ID indicates the total amount of time the CPU is in an idle state.
Dstat can give the number of interrupts that are generated by each device:

1. For each CPU to run the queue do not exceed 3, for example, if the dual-core CPU should not exceed 6;
2. If the CPU is running at full load, the following distribution should be met
A) User time:65%~70%
b) System time:30%~35%
c) idle:0%~5%

Mapstat: By default, only all averages are output
[Email protected] sectionlocus]$ Mpstat
Linux 2.6.32-431.1.2.0.1.el6.x86_64 (ctb-test) 09/16/2014 _x86_64_ (CPU)

10:53:53 AM CPU%usr%nice%sys%iowait%irq%soft%steal%guest%idle
10:53:53 AM All 7.87 0.00 1.33 0.20 0.00 0.64 0.00 0.00 89.95
Mpstat-p All

View the situation of each CPU
[Email protected] sectionlocus]$ mpstat-p all
Linux 2.6.32-431.1.2.0.1.el6.x86_64 (ctb-test) 09/16/2014 _x86_64_ (CPU)

10:53:26 AM CPU%usr%nice%sys%iowait%irq%soft%steal%guest%idle
10:53:26 AM All 7.87 0.00 1.33 0.20 0.00 0.64 0.00 0.00 89.95
10:53:26 AM 0 16.66 0.00 31.15 0.96 0.06 17.06 0.00 0.00 34.11
10:53:26 AM 1 8.80 0.00 0.46 2.30 0.00 0.01 0.00 0.00 88.42
10:53:26 AM 2 7.59 0.00 0.30 0.13 0.00 0.00 0.00 0.00 91.98
10:53:26 AM 3 7.92 0.00 0.10 0.05 0.00 0.00 0.00 0.00 91.94
10:53:26 AM 4 7.29 0.00 0.25 0.08 0.00 0.00 0.00 0.00 92.38
10:53:26 AM 5 7.48 0.00 0.09 0.03 0.00 0.00 0.00 0.00 92.40
10:53:26 AM 6 7.00 0.00 0.12 0.05 0.00 0.00 0.00 0.00 92.83
10:53:26 AM 7 7.30 0.00 0.07 0.03 0.00 0.00 0.00 0.00 92.60
10:53:26 AM 8 6.82 0.00 0.09 0.04 0.00 0.00 0.00 0.00 93.05
10:53:26 AM 9 7.19 0.00 0.07 0.02 0.00 0.00 0.00 0.00 92.72
10:53:26 AM 10 6.68 0.00 0.09 0.04 0.00 0.00 0.00 0.00 93.19
10:53:26 AM 11 7.08 0.00 0.06 0.02 0.00 0.00 0.00 0.00 92.83
10:53:26 AM 12 7.09 0.00 1.20 0.67 0.00 0.00 0.00 0.00 91.03
10:53:26 AM 13 8.16 0.00 0.13 0.25 0.00 0.00 0.00 0.00 91.46
10:53:26 AM 14 7.78 0.00 0.10 0.06 0.00 0.00 0.00 0.00 92.06
10:53:26 AM 15 7.60 0.00 0.13 0.03 0.00 0.00 0.00 0.00 92.24
10:53:26 AM 16 7.56 0.00 0.09 0.04 0.00 0.00 0.00 0.00 92.31
10:53:26 AM 17 7.79 0.00 0.05 0.02 0.00 0.00 0.00 0.00 92.14
10:53:26 AM 18 7.56 0.00 0.06 0.03 0.00 0.00 0.00 0.00 92.35
10:53:26 AM 19 7.80 0.00 0.05 0.01 0.00 0.00 0.00 0.00 92.14
10:53:26 AM 20 7.50 0.00 0.05 0.03 0.00 0.00 0.00 0.00 92.41
10:53:26 AM 21 7.81 0.00 0.05 0.01 0.00 0.00 0.00 0.00 92.13
10:53:26 AM 22 7.50 0.00 0.05 0.02 0.00 0.00 0.00 0.00 92.42
10:53:26 AM 23 7.80 0.00 0.05 0.01 0.00 0.00 0.00 0.00 92.13


By using the PS command, you can clearly see which process is eating the CPU
[Email protected] sectionlocus]$ Ps-eo Pcpu,pid,user,args | Sort-k 1-r | Head-16
%cpu PID USER COMMAND
6.2 17319 Map sshd: [Email protected]
59.0 3023 root./src/redis-sentinel *:26379
1.6 17320 Map/usr/libexec/openssh/sftp-server

Memory
Free-b,k,m,g
[[email protected] section]$ free
Total used free shared buffers Cached
mem:16280412 16114224 166188 0 305212 8181816
-/+ buffers/cache:7627196 8653216
swap:32767992 12064588 20703404

Total: Overall size of physical memory
Used: The amount of physical memory already in use
Free: idle physical memory size
Shared: The amount of memory that multiple processes share
buffers/cached: Size of the disk cache
Second line of Mem: representing physical memory usage
Third row (-/+ buffers/cached): Represents the disk cache usage status
Line four: Swap indicates swap space memory usage state
The memory state of the free command output can be viewed in two angles: one from the kernel point of view, one from the application layer perspective.

IO Monitoring
Top%wa refers to the time that the CPU waits for disk writes to complete. Is the disk busy, how to prove that the disk is busy?
Df-h viewing partition information for a hard disk
[Email protected] sectionlocus]$ df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root 244G 164G 68G 71%/
Tmpfs 7.8G 0 7.8G 0%/dev/shm
/DEV/SDA1 485M 54M 406M 12%/boot
/DEV/SDB1 1.8T 1.1T 687G 61%/map

[Email protected] sectionlocus]$ iostat-d-k-t 2
Linux 2.6.32-431.1.2.0.1.el6.x86_64 (ctb-test) 09/16/2014 _x86_64_ (CPU)

09/16/2014 11:35:05 AM
Device:tps kb_read/s kb_wrtn/s Kb_read Kb_wrtn
SDB 26.34 679.38 486.98 5865509664 4204394924
SDA 8.41 12.06 51.23 104118766 442327556
dm-0 11.68 6.29 45.14 54302885 389705884
Dm-1 2.97 5.77 6.09 49812588 52621612

TPS: The number of transmissions per second of the device (indicate, transfers per second, were issued to the.). "One-time transfer" means "one-time I/O request". Multiple logical requests may be merged into "one I/O request". The size of the "one transfer" request is unknown.
KB_READ/S: The amount of data read from the device (drive expressed) per second;
KB_WRTN/S: The amount of data written to the device (drive expressed) per second;
Kb_read: The total amount of data read;
KB_WRTN: The total amount of data written, these units are kilobytes.

Linux Common commands (6)-Performance bottleneck analysis (Java)

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: info-contact@alibabacloud.com 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.