Check 12 Performance Tuning commands in linux

Source: Internet
Author: User

Check 12 Performance Tuning commands in linux
GuidePerformance Tuning is one of the most important tasks for O & M engineers. If your production environment experiences slow system response speed, abnormal hard disk I/O throughput, and the data processing speed is lower than the expected value, or if the CPU, memory, hard disk, network, and other system resources are exhausted for a long time, this article will help you. If not, add them to your favorites first.1. hdparm:

Command: hdparm-t/dev/sda5 print: Timing buffered disk reads: 254 MB in 3.01 seconds = 84.34 MB/sec Description: You can specify which hard disk to query!
2. iostat checks disk I/O status:
Format: iostat [-c |-d] [-k] [-t] [-V] [-x [device] [interval] Description: iostat is short for I/O statistics (input/output statistics). The iostat tool monitors disk operation activities of the system. It reports disk activity statistics and CPU usage. Like vmstat, iostat also has a weakness that it cannot perform in-depth analysis on a process, only the overall situation of the system is analyzed, and the detection statistics are collected once every 1 second (5 times in total ).

Number of data blocks read per second by blk_read/s

Blk_wrtn/s

Blk_read indicates the number of all data blocks read.

Blk_wrtn indicates the number of all data blocks written.

3. vmstat reports memory and CPU status:
Name: statistical information of the reported virtual memory. Format: vmstat [-n] [latency [times]

R: Number of processes that run and wait for the CPU time slice.Longer than the number of CPUs, indicating insufficient CPUB: Number of processes waiting for resources. If the number of waiting processes is large,The problem may be in I/O or memory.Swpd: memory size for switching to the memory swap zone [in KB] free: number of currently idle physical memory [in KB] si: Memory transferred from disk to so: from memory to disk bi: the total amount of data read from the block device bo: the total amount of data written to the block device bi + bo1000 if more than 1000, representing a hard disk read/write speed problem in: the number of device interruptions per second observed during a certain interval [too many interruptions may be poor performance] cs: column indicates the number of context switches generated per second. us + sy> 80% indicates insufficient CPU resources. us: CPU time consumed by the user process. sy: CPU time consumed by the kernel process. id: CPU idle time percentage wa: percentage of time occupied by IO wait runq-sz: Number of processes that can run in memory plist-sz: Number of active tasks in the system

4. sar detection of CPU resources:
Task Plan/etc/cron. d/sysstat log directory/var/log/sa view method Sar-q-f/var/log/sa/sa10

5. lscpu displays CPU information:
Dmesg displays boot information. lscpu displays CPU information. lscpu-p displays the number of CPU nodes. getconf LONG_BIT indicates the number of host locations. getconf-a. View All parameters./sys/class/dmi/ id to view Bios information bios _*
6. Call the strace display program:
strace –fc elinks –dump http://localhost
7. Optimize the hard disk for Data Writing/reading first:


Read the amount of data to be written in advance, and then process the write request. The value read by the iterator will be half the set value.
Set the value to be read to the cache. The write speed slows down because of the large amount of data.

The larger the length of the/sys/block/sda/queue/nr_requests queue, the higher the hard disk I/O speed, but the memory occupied
/Sys/block/sda/queue/scheduler scheduling algorithm Noop, anticipatory, deadline, [cfq]

8. Separate the log function of the Ext3 File System:
1. Create a m/dev/sdb1 file, format it to ext32, dumpe2fs/dev/sdb1, and view has_journal3 and Tune2fs-O ^ has_journal/dev/sdb1 in the file system function. log function 4. Split the log into another MB partition. /dev/sdb2. the block of the log volume must be/dev/sdb1Mke2fs-O journal_dev-B 1024/dev/sdb25, And/dev/sdb2 must be used as the/dev/sdb1 log volume. tune2fs-j-J device =/dev/sdb2/dev/sdb1
9. Disable the recording file system atime:
Frequent modification of atime to website files does not make sense, and affects the performance of mount-o remount and noatime DEVICE.
10. Modify the file log submission time:
By default, logs are submitted once every 5 seconds. Modifying logs for a longer time can improve performance, but data is easy to lose. Mount-o remount, commit = 15 DEVICE
11. RAID round robin write optimization, suitable for 0/5/6:

Chunk size. The number of bytes written at a time. The default value is 64 KB. As long as it is not fully written, it will not be moved to the next device.

It is set to switch to the next hard disk if only one file is written on each hard disk. If it is a 1 K small file, system resources will be wasted on switching the hard disk.

If you set the chunk size value to a large value, such as 100 MB, it makes no sense. It is better to use a hard disk.

Stripe size. The size of the Strip. Instead of writing data when there is data, it sets the data volume to be written each time. Generally, it is written once at 16 kb.

So. Chunk size (64 K)/stripe size (16 K), that is, write each Hard Disk four times.

---------------------------------- Calculate how much chunk size should be adjusted ------------------------------------

Use iostat-x to view the average number of requests per second since startup avgrq-sz
Chunk size = number of requests per second * 512/1024/number of disks, taking an integer that is at least two multiples
Stride = chunk size/block (4 k by default)

Create raid and set chunk sinze
Mdadm-C/dev/md0-l 0-n3-chunk = 8/dev/sdb [0, 123]
Modify raid
Mke2fs-j-B 4096-E stride = 2/dev/md0

12. Number of hard disk blocks retained:
Dumpe2fs/dev/sda1 tune2fs-m 10/dev/sda1 reserve block percentage tune2fs-r reserve the number of blocks is too small, affect performance, retain too much and waste hard disk, default is 5%

After learning the above performance tuning commands and methods, I would like to summarize the following golden statements:

The performance of independent devices is faster than that of integrated devices because they do not occupy the overall resources of hosts.
Engineers generally do not remotely manage computers and need to provide logs and other information.
The larger the disk space, the slower the reading speed. You can consider using multiple hard disks to form a large space.
Partitioning is only marked on the hard disk, but not formatted as a file system, so the speed is fast.
The faster the hard disk depends on the outside. [The smaller the Partition Number is, the more the disk depends on the outside area. Therefore, the larger the data volume, the first partition.]
Program developers focus on the functional requirements of employers, and system administrators focus on program resource overhead.

This is the original article from Linux: http://www.linuxprobe.com/linux-performance-tuning/author: Liu Jun

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.