Linux scheduling algorithm RHCA

Source: Internet
Author: User
Linux scheduling algorithm RHCAUNIT6CompensatingforPhysicalDiskCharacteristicswww.2cto.com objective:. understand the physical factors that affect disk io B. application queue technology to adjust IO scheduling 6.1physicalfactorsaffect..linux scheduling algorithm rhca unit 6 Compensating for Physical Disk Characteristics www.2cto.com objective:. understand the physical factors that affect disk io B. application queue technology adjusted IO scheduling 6.1 Physical factors affect disk IO Physical factors affecting disk io. storage density: the principle of regional constant velocity (ZCAV): modern hard drives use Equi-density storage, so the number of sectors on each track has more outer rings than the inner ring, it is divided into several areas from the inner ring to the outer ring. the angular velocity in each area remains certain, that is, ZCAV mode. external The ring track has more linear storage areas than the inner ring B. When the rotation speed is certain, the data read in the outer ring of each second is more than that in the inner ring. C. the partition number of the outer ring is lower than that of the inner ring (because the partition starts from the outer ring and has 0 channels and 0 sectors) B. bus connection. the processing bandwidth of Linux kernel is 10Gib/SC. electronic-mechanical positioning. speed delay B. seek time PS: www.2cto.com hard disk structure. physical composition of a disk: it is usually composed of one or more circular disks, each of which is stored on both sides. data can be read and written through the head on the mechanical arm, it is mainly composed of disc, mechanical arm, head and spindle motor. B. logical structure of the disk: Head (header) cylinder (track) sector (sector) head: The head is fixed on a removable mechanical arm for reading and writing data. Modern hard disks can be read and written on both sides, so the number of heads is equal to twice the number of disks. The maximum number of magnetic heads is 255 (8 binary digits ). Track: Each disc is composed of n concentric circles. Each concentric circle is called a track. It is divided into 0 to n channels in the outward direction. Cylinder: the same track (with the same position) of n disks form a cylinder. The maximum number of cylinders is 1023 (10 binary digits ). Sector: draws a straight line from the center of the disk to divide the track into several arcs. An arc segment on each track is called a sector. The sector is the smallest unit of the hard disk, usually 512 bytes. The maximum number of sectors on the track is 63 (6 binary digits ). Formula of hard disk storage capacity: storage capacity = number of magnetic heads × number of tracks (cylinder) × number of sectors × number of bytes per sector 3D addressing parameters: ×track (cylinder ), ×× head, ×× sector Track = sector * nLinux partitions are divided by cylinder. Boot zone information: the first Sector of the hard disk is called Boot Sector. It consists of three parts: MBR (MasterBoot Record), DPT (Disk Partition Table), and Boot Record ID. • MBR, also known as the master Boot record, occupies the first 446 bytes (0 ~ 0x1BD ). Stores the System main boot program and is responsible for loading and running the system boot program from the active partition. • DPT is the primary partition table, which occupies 64 bytes (0x1BE ~ 0x1FD), which records the basic partition information of the disk. The primary partition table is divided into four partition items, each of which is 16 bytes. The information of each primary partition is recorded respectively (therefore, a maximum of four primary partitions can be created ). After dividing three primary partitions, all the remaining disk space is allocated to the extended partition, and then partitioned in the extended partition (IDE: 5 ~ 59 partition, SATA: 5 ~ 15 partitions). If this is not the case, the remaining space cannot be used after four partitions are divided. • Boot Record ID is the Boot zone identifier, which occupies two bytes (0x1FE ~ 0x1FF ). For a valid boot area, it is equal to 0xAA55, which indicates whether the boot area is valid. 6.2 Disk storage density A uses bonnie ++ to test Disk and file system performance. yum-y install bonnie ++ rpm-qd bonnie ++ useradd zcav; usermod-aG disk zcav for drive in sdb sdc sdd sde; do su-c "zcav-c1/dev/$ drive" zcav>/tmp/zcavdata. $ drive done Gnuplot command: set term png size 600,300 notransparent 1 w 2 set output'/tmp/rh442_zcav.png 'set xlabel 'block'; set xrange [0:] set ylabel 'disk thronghput (KiB/s) '; set yr Ange [0:] set border 3; set xtics nomirror; set ytics nomirror set label 'zcav steppings 'at, plot'/tmp/ZCAV. sdd 'U t' 80 GB hdd' with lines, \ '/tmp/zcav. sdb 'U t' 16 GiB SSD 'with lines, \'/tmp/zcav. sde 'U t' 64 gb usb flash 'with lines, \'/tmp/zcav. sdc 'U t' 8 GiB SD card 'with lines B. bonnie ++ is a benchmark performance testing tool for hard disks and file systems. it uses a series of simple tests to generate performance parameters for hard disks and file systems. The main program provides two types of tests: Database-style access tests for a single file and creation and deletion of a large number of small files to simulate such as Squid, INN, or test the access style of Email in Maildir format. This tool provides useful help information when selecting the RAID setting method, file system creation parameters, and NFS access mode. Bonnie ++ benchmark three aspects: data reading and writing speed, the number of disk seek operations that can be completed per second, and the number of file metadata operations that can be completed per second. The performance of metadata is closely related to running squid or Maildir-format email servers to save emails because they are all metadata-intensive applications. The latest version of Bonnie ++ is 1.03e. Project address: http://www.coker.com.au/bonnie++/ . B. after installation and installation, two executable files will be generated in the/usr/local/sbin/directory, bonnie ++ (main test program) and zcav (bare disk throughput test program). two executable files are also generated in the/usr/local/bin directory to generate a readable test report, they are bon_csv2html and bon_csv2txt. C. -d DIR is the directory used for testing, that is, the location of the test target.-s SIZE (MiB) is the SIZE of the file used to test IO performance; if the specified file size is greater than 1 GB, bonnie ++ divides it into multiple files with a size of 1 GB.-m indicates the host name of the target host, only the host ID used to display the test results;-r specifies the memory size used for the Test degree; bonnie ++ generally requires that the size of the specified test file be at least twice the size of the physical memory; if the specified file is too small during the test, you can specify the size of the physical memory used to lag this condition;-x is used to specify the number of simultaneous tests; -u indicates the uid associated with the test program. if the test is performed as the root user, this item must be specified explicitly. The-g option is used to specify the gid;-q silent mode;-f fast mode. this mode does not perform IO testing;-D direct IO testing is used to test the performance of large-scale IO requests; example: # bonnie ++-d/data-u root-s 4096-m mail description: 1. the "++" symbol explicitly displayed in the test result indicates that the test time is less than 500 ms, so the result is not displayed as inaccurate; 2. two results are displayed for each test. % CP indicates the CPU usage of this test. d. zcav is short for "Zoned Constant Angular Velocity". it is used to test the throughput of bare disks. Common options are as follows:-B refers to the size of the data block for read/write operations, in MB. the default value is 100 MB.-c refers to the number of reads/writes to the entire disk; -f indicates the file used for data reading;-u indicates the uid used for testing;-g indicates the gid used;-w indicates the test by filling "0" into the disk, will destroy the original file. Example: # zcav-B 2048/dev/sda3 6.3 Choosing a peripheral interconnect select external connection A. is the bottleneck of resources and systems lies in the bus? B. common Bus interfaces Bus Type Bus Width Clock speed Burst bandwidth Sustainable bandwith Bus Type Bus size Clock frequency peak bandwidth support bandwidth PCI 32 bits 33 MHz 133 MiB/s 115 MB/s PCI 32 bits 66 MHz 266 miB/s 230 MB/s PCI 64 bits 33 MHz 266 MiB/s 230 MB/s PCI 64 bits 66 MHz 533 MiB/s 490 MB/s PCI-X 64 bits 133 MHz 1066 MiB/s 980 MB/s PCIe x1 1 bits 2.5 GHz 250 MiB/s 200 MB/s 6.4 SCSI bus considerations precautions for using the SCSI bus interface. physical considerations. in the same bus Be especially careful when using hybrid devices with different speeds (Wide and Narrow devices), because the location where the narrow termination occurs on the bus may be different from that of the wide device. B. active termination VS passive termination c. differential signaling difference signal: a numerical value is used to represent the difference between two physical quantities. B. sg3_utils toolkit: view information about the SCSI interface and set parameters. related commands: for DRIVE in $ (sginfo-r); do sginfo-a $ DRIVE; done 6.5 Electro-mechanical positioning electronic mechanical positioning. the abrupt transfer rate is irrelevant to the actual throughput. B. internal transmission rate is very important. the internal transmission rate is the number of bits per read or write by the disk. rotation speed C. using the queue technology to reduce the Average seek time. use the elevator algorithm to re-sort the request queue B. the metadata of the system is usually stored in the buffer cache. file data is usually stored in the page cache. d. most devices have their own internal cache. e. allows you to read and write IO devices directly through the Kernel Cache (for example, accessing the bare Backup) File = 1 inode + N blocks File = metadata + data Data rate = (sectors_per_track * 512 * rpm)/60 Disk speed = (Average sectors_per_track * rpm * 512) /60)/1000000 6.6 Block IO requests and cache effect (omitted) 6.7 Tuning sequential read access. the kernel automatically reads and writes forward in order. Blockdev-getra/dev/sda view blockdev-setra 512/dev/sda set the number of kb read/write at a time. you can view B in/sys/block/sda/queue/read_ahead_kb. the maximum window size can be adjusted. c. the initial value of the read/write window is half of the adjustable value d. set writable/etc/rc. local B. summary. this reduces the seek time, but increases the service time for each read/write. B. reduces the number of operations that the disk controller is notified to read/write data. c. it is not suitable for reading and writing random files. Application: suitable for large file read/write (Web Server) 6.8 Tuning the disk queue adjustment disk queue. adjust the queue length/sys/block/sda/queue/nr_requests to increase the queue length, which can increase disk throughput but consume memory. B. scheduling algorithm/sys/block/sda/queue/scheduler C. lengthen the queue... A. merge multiple read requests to write data at a time. B. merge more valid read requests but increase the latency. The default kernel I/O scheduling algorithm is cfq. For more information, see the command Grep-I cfq/boot/config-*. For more information about the scheduling algorithm, see: /usr/share/doc/kernel-doc-*/Documentation/block/* 6.9 Tuning the deadline scheduler deadline scheduling. purpose: to adjust the waiting time (W) echo deadline>/sys/block/sda/queue/scheduler B. the main adjustment is in/sys/block/sda/queue/iosched/. max queue time maximum queue time parameter: read _ expire: the number of Hao read requests per second expires after write_expire: How many Hao seconds each IO write request expires B. merging consecutive request parameters: front_merges: IO requests are usually merged at the end of the request queue. The value of this parameter can be set The first IO request in the request queue can be merged to process more requests. 0 indicates that the request is disabled, and 1 indicates that the request is enabled. Application: ensures the response speed. it is suitable for reading and writing small files by 6.10 Tuning the anticipatory schedory conjecture and scheduling. objective: to optimize the completion rate of read data echo anticipatory>/sys/block/sda/queue/scheduler the default value is 6 seconds. it is assumed that the next data will appear nearby to avoid frequent back-and-forth movement of the head. B. the main adjustment is in/sys/block/sda/queue/iosched/. duration of waiting for the next read/write request: antic_expire B. max queue time (W) read_expire write_expire: /usr/share/doc/kernel-doc-*/Documentation/block/as-iosched.txt application: for batch sequential read/write, for large files (e.g., web server) 6.10 Tuning the noop scheduler does not serve as scheduling .. objective: to save CPU clock frequency echo noop>/sys/block/sda/queue/scheduler. no need to adjust settings B. CPU clock usage is expensive. C. the host CPU clock frequency is usually lower than the san cpu clock frequency B. some disk controllers execute the elevator algorithm. identify command queue B. valid C. for iSCSI and GNBD, sorting is very useful. 6.11 Tuning the (default) cfq scheduler fair scheduling algorithm (default). objective: to provide different IO services for each application echo cfq>/sys/block/sda/queue/scheduler. IO-based priority B. use a 64-bit internal queue c. use the round robin method to fill the internal queue d. call up request e from non-empty queue. the dispatch queue can be sorted. B. the main adjustment is in/sys/block/sda/queue/iosched/. maximum number of requests in each internal queue: queued B. the number of requests distributed each time. Quantum Application: Applicable to random discrete read/write. 6.12 Fine-tuning the cfq scheduler cfq scheduling algorithm advanced adjustment. based on priority queue. class 1 (real-time) real-time queue: the highest priority for disk access. if this type of real-time queue is changed, it may starve other class priority 0 (the most important )~ 7 (least important) B. class 2 (best-effor): Round Robin access, default. Priority 0 (most important )~ 7 (least important) c. class 3 (idle) idle: disk I/O Example: ionice-p1 ionice-p1-n7-c2 process number is 1, round robin access 2, level 7 least important ionice-p1 adjusts IO for processes: -p pid process number-n priority-c priority class www.2cto.com 6.12 Physical block devce interfaces Physical block device interface type. IDE: 133 Mbit/s or above B. SATA: 300 MB/s C. SCSI: 320 MB/s D. USB: 480 Mbps (60 MB/s) E. iSCSI + GigE: 1 Gb/s (125 MB/s) F. FC: 4.25 Gb/s (531 MB/s)

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.