Disk Performance optimization

Source: Internet
Author: User

First, check the hard disk read speed

Command: Hdparm-t/dev/sda5

Printed: Timing buffered disk reads:254 MB in 3.01 seconds = 84.34 mb/sec

Description: Be able to specify which hard disk to query for!

Second, find the most consumption of iowait 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 the syslog when you're done.

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 monitors the system's disk operation activity. It is characterized by the reporting of disk activity statistics, as well as the reporting of CPU usage. Like Vmstat, Iostat also has a weakness, that is, it cannot analyze a process in depth, only the overall situation of the system.

Parameters:

-C to report CPU usage;

-D to report disk usage;

-K indicates that the data is displayed by kilobytes bytes per second;

-P Displays all storage device partition information.

-T is the time to print the report;

-V means to print out version information and usage;

-X devices Specify the name of the device to be counted, and the default is all devices;

Interval refers to the time of each statistic interval;

Count refers to the number of times that are counted by this interval.

Output information:

RRQM/S: The number of read operations per second for the merge. Delta (rmerge)/s

WRQM/S: The number of write operations per second for the 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 Read sectors per second. Delta (rsect)/s

WSEC/S: Number of Write sectors per second. Delta (wsect)/s

rkb/s: Reads K bytes per second. is half the rsect/s because the size of each sector is 512 bytes.

wkb/s: Writes K bytes 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. That is Delta (AVEQ)/s/1000 (because the Aveq is in milliseconds).

Await: The average wait time (in milliseconds) for each device I/O operation. Delta (ruse+wuse)/delta (Rio+wio)

SVCTM: The average service time (in milliseconds) per device I/O operation. Delta (use)/delta (RIO+WIO)

%util: How much time in a second is spent on I/O operations, or how many times in a second I/O queues are non-empty.

CPU: Indicates all CPU in the machine;

%user indicates the utilization of CPU;

%nice represents the percentage of CPU priority at the user level, 0 indicates normal;

%system indicates the percentage of CPU consumed on the user's application tier when the system is running;

%iowait indicates the percentage of CPU consumed when requesting hard disk i/0 data outflow;

%idle indicates the percentage of idle CPU, the higher 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 found that the CPU used by IO processing is higher than the percentage of CPUs. Because what I'm doing is remembering the log processing and the MV changing the name so the CPU is higher!

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 Some columns that use block are forced to use kilobytes units

Tps: The number of times the device is transmitted per second (an IO request at a time of transmission)

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

Kb_read Total amount of data read

Kb_wrtn Total amount of data written

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: rrqm/s How much of this device-dependent read request is being merge per second (the VFS will send the request to each FS when the system call needs to read the data).

If FS finds that different read requests read the same block of data FS, the request will be merged one at a time, and how much of this device-related write request is wrqm/s per second.

RSEC/S number of sectors read per second, wsec/s number of sectors written per second r/s

Await: Average time (in microseconds) of processing per IO Request Description: The general system IO response time should be less than 5ms if more than 10ms is larger!

%util: All processing IO time/Total statistic time during the statistic time this parameter describes the busy program of the device. If this parameter is up to 100%, this device is running close to the manufactoring load

(If you have more than 100% disks, you may not be able to reach the bottleneck if you have concurrency)

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 get 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 disk, it is represented as multiple physical hard disks such as SDA SDB

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 in 22.25 disk usage at 2.66%

Description disk response is a bit slow.

Iv. Vmstat

Name: Reporting statistics for virtual memory

Format: Vmstat [-n] [delay [times]]

Description: This command is very useful and must be mastered!

Options:

-N causes the first message to appear only once rather than periodically

-S Unit size

-a displays active and inactive memory information

-s display related virtual memory statistics

Introduction to Output information:

Proc

R: The number of processes running and waiting (CPU time slices) to run, this value can also determine whether to increase the CPU (longer than 1)

B: The number of processes in a non-interruptible state. Common situations are caused by IO

Memory

SWPD: Switch to memory on swap memory (default in kilobytes)

Note: If it is not 0 or larger, such as more than 100M, the value of SI so is longer than 0. This situation does not have to worry about system performance

Free: Idle physical memory

Buff: Memory for buffer cache, read write buffer for block device

Cache: Memory for page cache, file system level cache

If the cache value is larger than the number of files cache, if the frequently accessed files can be cache the disk read IO bi will be very small.

Swap

Si: Swap memory usage, disk into memory

So: Swap memory usage, memory is transferred into disk

Note: If the system has sufficient memory, both values are 0, and if the two values are longer than 0, the performance is affected.

If the system has very little memory, but si so is very few, the system performance will not be affected!

Io

BI: Total amount of data read from a block device (read disk) (KB/S)

Bo: Total amount of data written to the block device (write disk) (KB/S)

System

In: Number of interrupts generated per second

CS: Number of context switches generated per second

Note: The larger the two values, the more CPU time will be seen by the kernel!

Cpu

US: Percentage of CPU time consumed by user processes

When the value of us is higher, it indicates that the user process consumes more CPU time, and if more than 50% is used in the long term, the optimizer algorithm or acceleration should be considered.

Percentage of CPU time consumed by the SY kernel process

If the value of SY is high, it indicates that the system kernel consumes more CPU resources. To check the cause

WA io wait% of CPU time consumed

The WA value if high indicates that IO waits are more severe. It could be that the disk is doing a lot of random access, or it could be a bottleneck in the bandwidth of the disk.

ID:CPU in idle state time percentage

Scenario Analysis:

What are some of the things we need to be concerned about?

Procs r: Running more processes, the system is busy

Io bo: Disk write a slightly larger amount of data, if it is a large file write, 10M within the basic need not worry, if it is small files write 2M or less basic normal

Cpu US: Lasts more than 50, if it is peak can accept

CPU wa: A little bit high

CPU ID: Duration Less than 50, peak can be accepted

V. 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, 111 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 the current system time

349 days, 21:50 indicates the operating time since the system started.

2 users log on to the user's terminal number. Multiple endpoints are considered multiple users at the same time by the same user

Load average:3.81, 4.23, 4.34 the average load of the current system, and the last three values were 1 minutes ago, 5 minutes ago, and 15 minutes ago. Average of processes

It is generally possible to think that this value exceeds the CPU number when the CPU will be more laborious!

Description: View the current server CPU number command: Cat/proc/cpuinfo |grep processor|wc-l My output: 8

Second line: tasks:112 Total, 1 running, 111 sleeping, 0 stopped, 0 zombie

tasks:112 Total indicates the current number of system processes

1 running the number of processes currently running

111 sleeping as the number of processes in the current wait state

0 stopped for the number of system processes stopped

0 Zombie of the dead number of processes

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 multiple CPUs press 1, you can display one CPU per line of information.

Line four: mem:4147272k total, 4117996k used, 29276k free, 459344k buffers

Show available memory and utilized memory

Line five: swap:1052248k Total, 19

2k used, 1052056k free, 3174936k cached

Note: The swap partition is frequently used, which can be considered to be due to insufficient physical memory.

Line six begins to enumerate information about each process

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND

PID Process ID

USER who runs this process

Precedence 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 consumes the physical memory

SHARE shared memory used by this process

Status information for the STAT process.

R is running

S is resting

Z hysteresis

T stop

W swapped-out process

Value of N Nice

%cpu percentage of CPU consumed by this process

Percentage of memory occupied 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, at any time, the CPU has 7 states:

1.idle, which indicates that the CPU is idle and waiting for assignment.

2.user, which indicates that the CPU is running the user's process

3.system, which means the CPU is performing kernel work

4.nice, indicating the amount of time the CPU spends on a process that has been changed over priority by Nice

(Note: The process by which the priority is changed by the Nice command refers only to those that have a nice value of negative.) The time spent on tasks that are prioritized by the Nice command 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 the IO operation to complete

6.IRQ, which indicates how long the CPU cost is in response to a hard interrupt

7.SOFTIRQ, which indicates how long the CPU overhead is in response to a soft interrupt.

What we generally see with vmstat are four states: Sy,us,id,wa, which, by combining him with the load AVG, can basically know the state of a CPU.

US-user indicates CPU is running the user's process

SY-and system indicates that the CPU is performing kernel work

Nice, ni, says the CPU spends time on a process that has been changed by Nice.

The-ID---idle indicates that the CPU is idle and waiting for assignment.

WA-iowait indicates that the CPU is waiting for the IO operation to finish%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 the soft interrupt is busy. Frequent switching between processes results!

 

Disk Performance optimization

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.