Inventory 12 Performance Tuning commands in a Linux system.

Source: Internet
Author: User

Guide Performance tuning has always been one of the most important work of operations engineers, if you are in a production environment encountered a slow system response, hard disk IO throughput anomalies, data processing speed is lower than expected, or such as CPU, memory, hard disk, network and other system resources have been exhausted for a long time, Then this article will really help you, if not, please collect them first.
1,hdparm viewing hardness reading speed:
Command: hdparm-t/dev/sda5 print: Timing buffered disk reads:254 MB in 3.01 seconds = 84.34 mb/sec Description: Able to specify which hard disk to query!
2,iostat detection of disk IO:
Format: Iostat [-C |-d] [-K] [-t] [-v] [-X [Device]] [interval] Description: Iostat is an abbreviation for I/O statistics (input/output statistics), the Iostat tool will To monitor the disk operation activity. It is characterized by reporting disk activity statistics, but also to report the CPU usage, like Vmstat, Iostat also has a weakness, that is, it can not be in-depth analysis of a process, only the overall situation of the system analysis, every 1 seconds detection statistics (5 times total).

blk_read/s number of data blocks read per second BLK_WRTN/S number of data blocks written per second blk_read indicates the number of all data blocks read BLK_WRTN represents the number of blocks written
3,vmstat report memory and CPU status:
Name: report The statistics format for virtual memory: Vmstat [-n] [delay [times]]

R: The number of processes running and waiting for CPU time slices. long-term greater than the number of CPUs, representing insufficient CPU
B: The number of processes waiting on the resource, if the number of waits is large, the problem may be in I/O or memory
SWPD: The memory size of the switch to the memory swap area [in kilobytes]
Free The amount of physical memory currently idle [in kilobytes]
Si The disk is transferred into memory
So Dial-in Disk from memory
Bi The total amount of data read from a block device
Bo The total amount of data written to the block device
Bi+bo 1000 if more than 1000, indicates that the hard disk read and write speed problem
In Number of device interrupts per second observed at a certain time interval [too many interrupts are bad for performance]
Cs: Column represents the number of context switches produced per second
Us+sy > 80% Represents insufficient CPU resources
us Percentage of CPU time consumed by user processes
Sy: Percentage of CPU time consumed by kernel processes
Id: Percentage of time that the CPU is in idle state
Wa The percentage of time that IO waits
Runq-sz: Number of processes that can run in memory
Plist-sz: Number of active tasks in the system

4,sar Detecting CPU resources:
Task Scheduler/etc/cron.d/sysstat Log Directory/var/log/sa View method sar–q–f/var/log/sa/sa10

5,LSCPU Display CPU information:
DMESG displays information about the boot start LSCPU displays the CPU information lscpu-p the number of nodes corresponding to the CPU getconf Long_bit know the number of bits getconf-a view all the parameters/sys/class/dmi/id can view the BIOS Information bios_*
6,strace shows the call to the program:
STRACE–FC Elinks–dump http://localhost
7, tune the hard drive to write/read data in priority:

read the amount to be written beforehand and then process the write request, ↑ The value read will be half of the set value ↑. The greater the number of values that the setting reads into the cache. When writing, it slows down because of the large amount of data. The larger the/sys/block/sda/queue/nr_requests queue length, the hard disk IO speed will increase, but the memory/sys/block/sda/queue/scheduler scheduling algorithm NoOp, anticipatory, Deadline, [CFQ]

8, the log function of the Ext3 file system is independent:
1. Create 200M/dev/sdb1 format to Ext32, DUMPE2FS/DEV/SDB1 view Has_journal3, Tune2fs–o ^has_journal/dev/sdb1 included in file system features Remove the default original log function 4, and then divide a 200M partition./dev/sdb2. The block of the log volume must be equal to/dev/sdb1mke2fs–o journal_dev–b 1024/dev/sdb25,/dev/sdb2 as the/DEV/SDB1 log volume. Tune2fs–j–j DEVICE=/DEV/SDB2/DEV/SDB1
9. Close the recording file system atime:
For web site files, frequent modification of atime is meaningless and can affect performance Mount–o Remount,noatime DEVICE
10, modify the file log submission time:
The default is 5 seconds to commit the log, and modifying it for a longer time can improve performance, but it is easy to lose data. Mount–o remount,commit=15 DEVICE
11,raid Round write tuning for 0/5/6:
chunk size. The round-robin Byte is written once. The default is 64K, as long as it is not full, it will not move to the next device settings on each hard disk to write only one file to switch to the next hard disk, then if all are small files 1K, the system resources will be wasted on the switch drive if the chunk The value of size is set very large, such as 100M, then there is no meaning, it is better to use a hard disk. Stripe size. Stripe sizes, not write with data, but set the amount of data written each time, typically 16K write once. So. Chunk size (64K)/stripe size (16K), which means that each hard drive is written four times. ------------------------------------calculate how much the chunk size should be now------------------------------------use iostat– X View the average number of requests per second since power on avgrq-sz chunk size = number of requests per second *512/1024/disk, take one integer immediately preceding twice times Stride = Chunk Size/block (default is 4k) create raid and set chunk Si Nze mdadm–c/dev/md0–l 0–n3–chunk=8/dev/sdb[123] Modify raid mke2fs–j–b 4096–e stride=2/dev/md0
12, block retention of hard disks:
DUMPE2FS/DEV/SDA1 tune2fs–m 10/dev/sda1 reserved block percentage tune2fs–r keep block number of blocks too little, affect performance, retain too much and waste hard disk, default is 5%

Learn the above performance tuning commands and methods, and then summarize a few tuning of the golden sentence: independent device performance faster than the integration of strong, because do not occupy the overall resources of the host computer engineers generally do not remotely manage computers, need to provide information such as log the larger the disk space, the slower the reading speed, You can consider using multiple hard disks to make up a larger space partition just on the hard disk to do the identification, rather than the format in the file system features, so speed faster hard disk faster than the outside speed [partition number is smaller, the outer region, so the volume of data large first partition]. Program developers focus on the employer's functional requirements, and the system administrator pays attention to the program's resource costs

Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/

Inventory 12 Performance Tuning commands in a Linux system.

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.