Linux Performance Tuning Command essence
Time: 2010-6-23
First, see the hard drive read speed
Command: Hdparm-t/dev/sda5
Printed: Timing buffered disk reads:254 MB in 3.01 seconds = 84.34 mb/sec
Description: Can specify which hard disk to query the OH.
Ii. finding the most iowait-consuming process
Operation Steps:
1./etc/init.d/syslog Stop
2. Echo 1 >/proc/sys/vm/block_dump
3. DMESG | Egrep "read| Write|dirtied "| Egrep-o ' ([a-za-z]*) ' | Sort | uniq-c | Sort-rn | Head
Don't forget to turn off Block_dump and start syslog after you've finished grasping
4. echo 0 >/proc/sys/vm/block_dump
5./etc/init.d/syslog Start
Iii. Iostat Order
Format: Iostat [-C |-d] [-K] [-t] [-v] [x [Device]] [interval
Description: Iostat is an abbreviation for I/O statistics (input/output statistics), and the Iostat tool will monitor the system's disk operation activities. It is characterized by reporting disk activity statistics and also reporting CPU usage. Like Vmstat, Iostat also has a weakness that it cannot analyze a process in depth and only analyze the overall situation of the system.
Parameters:
-C to report CPU usage;
-D for reporting on disk usage;
-K indicates that data is displayed per second by kilobytes byte;
-P Displays all storage device partition information.
-T for print reporting time;
-V means to print out version information and usage;
-X device Specifies the name of the device to be counted, and defaults to all devices;
Interval refers to the time of each statistical interval;
Count refers to the number of times that this interval is counted.
Output information:
RRQM/S: Number of read operations per second for merge. Delta (rmerge)/s
wrqm/s: Number of write operations per second for merge. Delta (wmerge)/s
R/S: Number of Read I/O devices completed per second. Delta (RIO)/s
W/S: Number of write I/O devices completed per second. Delta (WIO)/s
RSEC/S: Number of sectors read per second. Delta (rsect)/s
WSEC/S: Number of sector writes per second. Delta (wsect)/s
RKB/S: The number of K bytes read per second. Is half the rsect/s, because each sector size is 512 bytes.
WKB/S: The number of K bytes written per second. is half the wsect/s.
Avgrq-sz: The average data size (sector) per device I/O operation. Delta (rsect+wsect)/delta (Rio+wio)
Avgqu-sz: Average I/O queue length. The Delta (AVEQ)/s/1000 (because the Aveq unit is in milliseconds).
Await: The average wait time (in milliseconds) for each device I/O operation. Delta (ruse+wuse)/delta (Rio+wio)
SVCTM: Average service time (in milliseconds) per device I/O operation. Delta (use)/delta (RIO+WIO)
%util: How much time is spent in a second for I/O operations, or how many times in a second I/O queues are non-empty.
CPU: Represents all CPUs within the machine;
The%user represents CPU utilization;
%nice represents the percentage of CPU priority at the user level, 0 indicates normal;
%system represents the percentage of CPU consumed on the user application layer when the system is running;
%iowait indicates the percentage of CPU consumed when the hard drive i/0 data is being streamed;
%idle represents the free CPU percent, the larger the value the lower the system load
Example:
AVG-CPU:%user%nice%sys%iowait%idle
0.88 0.00 0.29 0.60 98.24
I've found that the percentage of CPU used for IO processing is higher. Because what I am doing is to log processing and MV change the name so the CPU is relatively high.
Example:
1, iostat-d-K 1 10
Device:tps kb_read/s kb_wrtn/s Kb_read Kb_wrtn
SDA 121.00 356.00 888.00 356 888
SDA1 0.00 0.00 0.00 0 0
SDA2 0.00 0.00 0.00 0 0
Sda3 0.00 0.00 0.00 0 0
SDA4 0.00 0.00 0.00 0 0
Sda5 243.00 356.00 888.00 356 888
Description
-D display device (disk) Usage status
-K certain columns that use the block to force the use of kilobytes as a unit
Tps: The number of times the device transmits per second (one transmission, IO request)
KB_READ/S The amount of data read from the device per second
KB_WRTN/S The amount of data written to the device per second
Total amount of data read by Kb_read
Total amount of data written by Kb_wrtn
2, iostat-d-x-k 1 10
device:rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkb/s wkb/s avgrq-sz avgqu-sz await SV
CTM%util
SDA 2.00 0.00 15.00 0.00 600.00 0.00 300.00 0.00 40.00 0.25 15.53-7
.20 10.80
Description: The number of read requests related to this device rrqm/s per second (when the system call needs to read the data, the VFS sends the request to each FS.
If FS discovers that data from the same block that is read by different read requests, FS will merge the request one at a time; wrqm/s how much of this device-related write requests per second has been merged.
RSEC/S number of sectors read per second; WSEC/S writes per second r/s
Await: The average time of processing each IO request (in microseconds) indicates that the general system's IO response time should be less than 5ms if it is larger than 10ms.
%util: In the statistical time of all processing IO time/Total statistic time This parameter describes the device's busy program. If this parameter is 100%, this device is approaching the full load operation.
(If the disk is more than 100% because there is concurrency may not reach the bottleneck)
3, Iostat-c 1 10
Output:
AVG-CPU:%user%nice%sys%iowait%idle
65.30 0.00 1.61 2.23 30.86
Can be used to obtain CPU performance data.
Example Analysis:
1, iostat-d-K 1|grep Sda5
Output:
Sda5 7.48 17.44 22.41 527084575 677241228
SDA5 20.79 380.20 0.00 384 0
Sda5 132.65 367.35 428.57 360 420
Sda5 39.60 582.18 0.00 588 0
Description: The SDA5 represents a physical logical partition rather than a physical hard disk. If you have more than one hard drive, it is represented as a SDA SDB with multiple physical hard drives
2, iostat-d-x-k 1
Output:
device:rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkb/s wkb/s avgrq-sz avgqu-sz await SVCTM%util
SDA 0.05 6.46 1.85 2.43 35.34 71.15 17.67 35.57 24.87 0.10 22.25 6.20 2.66
Average disk response time at 22.25 disk utilization at 2.66%
Indicates a slow disk response.
Four, Vmstat
Name: Reporting Virtual Memory statistics
Format: Vmstat [n] [delay [times]]
Description: This command is very useful and must be mastered skillfully.
Options:
-N begins with the first information displayed only once rather than periodically
-S Unit size
-a displays active and inactive memory information
-S show related virtual memory statistics
Introduction to Output information:
Proc
R: The number of processes running and waiting (CPU time slices) to run, and this value can also determine whether the CPU needs to be increased (longer than 1)
B: Number of processes in a non-disruptive state. Common situations are caused by IO
Memory
SWPD: Switch to memory on swap memory (default in KB)
Description: If it is not 0 or larger such as more than 100M, but the value of SI so for a long period of 0. You don't have to worry about system performance.
Free: Idle physical memory
Buff: As buffer cache memory, read-write buffer for block devices
Cache: For page cache memory, file system level cache
If the cache value is large enough to indicate the number of cache files, if frequently accessed files can be cache that disk read IO bi will be very small.
Swap
Si: Swap memory usage, disk transfer into memory
So: Swap memory usage, disk transfer from memory
Note: If the system has enough memory, both values are 0, and if these two values are longer than 0, the performance is affected.
If the system is free of memory, but Si so is very little, the system performance will not be affected.
Io
BI: Total amount of data read from block device (read disk) (KB/S)
Bo: Total amount of data written to a block device (write disk) (KB/S)
System
In: Number of interrupts generated per second
CS: The number of context switches generated per second
Note: The larger the two values, the more CPU time is consumed by the kernel.
Cpu
US: Percentage of CPU time consumed by the user process
US is a higher value, indicating that the user process consumes more CPU time, if longer than 50% of the use of the optimizer to consider the algorithm or acceleration.
Percentage of CPU time consumed by the SY kernel process
If Sy's value is high, the system kernel consumes more CPU resources. To check for reasons
Percentage of CPU time that WA IO waits to consume
The WA value indicates that IO wait is more serious if it is high. May be due to a large amount of random access to the disk, or disk bandwidth bottlenecks
Id:cpu percent of time in idle state
Scenario Analysis:
What we need to be concerned about.
Procs R: Running a lot of processes, the system is very busy
Io bo: Disk to write a slightly larger amount of data, if it is a large file to write, within 10M basic need not worry, if it is small file to write 2M within the basic normal
CPU US: Lasts greater than 50, if it is peak can be accepted
CPU wa: slightly higher
CPU ID: Duration is less than 50, peak can be accepted
Five, Top command
Command: Top
The output is as follows:
top-12:47:48 up 349 days, 21:50, 2 users, Load average:3.81, 4.23, 4.34
tasks:112 Total, 1 running, sleeping, 0 stopped, 0 zombie
Cpu (s): 38.7% us, 0.6% sy, 0.0% ni, 58.9% ID, 1.7% wa, 0.0% Hi, 0.0% si
mem:4147272k Total, 4117996k used, 29276k free, 459344k buffers
swap:1052248k Total, 192k used, 1052056k free, 3174936k cached
PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND
2274 Root 0 24976 18m 2436 S 0.4 151:00.05 python
First line: top-12:47:48 up 349 days, 21:50, 2 users, Load average:3.81, 4.23, 4.34
12:47:48 indicates current system time
349 days, 21:50 indicates how long it will be since the system was started
2 users log on to the user's terminal number. The same user at the same time to open multiple terminals are considered multiple users
Load average:3.81, 4.23, 4.34 the current system load, followed by three values 1 minutes ago, 5 minutes ago, 15 minutes before the average number of processes
It is generally considered that the CPU will be more laborious than the number of CPUs.
Description: View the current server CPU Count command: Cat/proc/cpuinfo |grep processor|wc-l My output: 8
Line two: tasks:112 Total, 1 running, sleeping, 0 stopped, 0 zombie
tasks:112 total represents current system process totals
1 running the number of processes currently running
Sleeping is the number of processes in the current wait state
0 stopped for the number of system processes stopped
0 The number of zombie for the zombie process
Third line: Cpu (s): 38.7% us, 0.6% sy, 0.0% ni, 58.9% ID, 1.7% wa, 0.0% Hi, 0.0% si
Displays the utilization of the CPU. If you have more than one CPU press 1, you can display information for one CPU per line.
Line four: mem:4147272k total, 4117996k used, 29276k free, 459344k buffers
Show available memory and utilized memory
Line five: swap:1052248k total, 192k used, 1052056k free, 3174936k cached
Note: Swap partitions are frequently used so that they can be considered to be a result of insufficient physical memory.
Line six starts by listing information about each process
PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND
PID Process ID
USER who runs this process
Priority of the PRI process
NI Nice value: The higher the value, the lower the priority of the task
SIZE the memory used by this process (code + data + stack)
RSS This process takes up the physical memory
SHARE shared memory used by this process
STAT status information for the process.
R is running
S is resting.
Z hysteresis
T stop
W the process that has been swapped out
N is the value of Nice
%cpu percentage of CPU consumed by this process
Percent of memory consumed by%mem
The total CPU time used by this process
CPU If this is a multiprocessor system, this column represents the ID of the CPU on which the process is running
CPU utilization, a very intuitive concept, in any time, the CPU has 7 states:
1.idle, indicating that the CPU is idle and waiting for assignment.
2.user, which indicates that the CPU is running the user's process
3.system, indicates CPU is performing kernel work
4.nice, which means that the CPU spends time on process that has been changed by Nice to a priority
(Note: The process of changing the priority by the Nice command refers only to the process where nice values are negative.) The time spent on tasks that are changed by the Nice command to change the priority will also be calculated in the system and user time,
So the whole time may add up to more than 100%.
5.iowait, indicating when the CPU waits for IO operations to complete
6.IRQ, indicating the time of CPU overhead in response to a hard interrupt
7.SOFTIRQ, indicating the time at which CPU overhead is responding to a soft interrupt.
We generally see with vmstat are four states: Sy,us,id,wa, through his and load AVG combination, the basic can know the state of the CPU
US-> user indicates that the CPU is running the users ' process
The Sy-> system indicates that the CPU is performing kernel work
Ni-> Nice indicates that the CPU spends time on process that has been changed by Nice to a priority
The ID-> idle indicates that the CPU is idle and waits for an assignment.
WA-> iowait indicates that the CPU waits for IO operations to complete%WA high, indicating that the disk is busy. For example, disk read and write times are very high.
Hi-> h/w Interrupt Requests hardware interrupt
Si-> s/w interrupt requests software interrupt%si High, whether it indicates soft interrupt busy. Frequent transitions between processes cause.