Cloud computing talents must master how to learn Linux performance optimization

  What must cloud computing talents have to master? How to learn Linux performance optimization? Linux is a multi-user, multi-tasking, multi-threading and multi-CPU operating system based on POSIX and Unix, with the characteristics of free use and free propagation. With the development of open source software and the innovation of cloud computing technology, Linux has become one of the skills that cloud computing talents must master. In the following sharing, Qian Feng Xiaobian will briefly introduce the IO subsystem of Linux performance optimization.

  Many students have heard of IO streaming, that is, input and output in the form of streaming, where streaming is an abstract concept, which represents the unstructured transfer of data. IO system, English is called "Input output system", Chinese is called "input output system", it is composed of input and output control system and peripheral equipment, it is an important part of computer system.

image/20200213/79e199d5a772d0be777899479b4f6bb3.jpeg

  As a Linux server, the two largest IO types are disk IO and network IO. A complete IO system process is as follows:

  1) A user process initiates a write request through the write () system call;

  2) The kernel updates the corresponding page cache;

  3) The pdflush kernel thread writes the page cache to disk;

  4) The file system layer stores each block buffer as a bio structure and submits a write request to the block device layer;

  5) The block device layer receives the request from the upper layer, performs the IO scheduling operation, and places the request in the IO request queue;

  6) The device driver (such as SCSI or other device driver) completes the write operation;

  7) The disk device firmware performs corresponding hardware operations, such as disk rotation, seek, etc., and data is written to disk sectors.

  The block layer processes bio requests and links these requests into a queue, called an IO request queue. The operation of this connection is called IO scheduling (also called IO elevator or elevator algorithm). The bio structure is the interface from file system layer to block layer.

  The overall goal of the IO scheduler is to reduce disk seek time (hence the scheduler is optimized for mechanical hard drives). The IO scheduler reduces disk seeks in two ways: merge and sort.

  Merging means that when two or more IO requests are adjacent disk sectors, through merging requests, multiple IO requests only need to send a request command to the disk, reducing the disk overhead.

  Sorting is to sort IO requests that cannot be merged, and sort them in the request queue according to the order of the requested disk sectors, so that the magnetic head can complete the IO operation according to the rotation order of the disk, which can reduce the number of disk seeks.

  To optimize IO system performance, we can use the following methods:

  1) Adjust the buffer and improve performance, that is, adjust the number of queues and increase the pre-reading.

  Increase the queue length: / sys / block / vda (specific device) / queue / nr_requests

  Increase the pre-reading: / sys / block / vda (specific device) / queue / read_ahead_kb

  2) Modify the CFQ to adjust its performance, involving the parameter file: / sys / block / vda / queue / iosched /.

  For example, for CFQ, the following values ​​can be adjusted:

  back_seek_max

  Reverse seek may have a negative effect. It can be enabled when the load is small, otherwise do not use too many reverse seek values.

  back_seek_penal

  Reverse seek seeks punishment. If you have to use reverse seek, you must punish it. Once the punishment is done, you must seek forward more times.

  fifo_expire_async

  It is used to control the length of the asynchronous request waiting time. The default is 250 milliseconds. The asynchronous requests that cannot be met after the expiration will be moved to the scheduling queue, which means that they must be rescheduled. Usually these values ​​do not need to be adjusted.

  In addition to the above methods, there are many IO optimization methods. The general idea is that it is best to change the SSD, adjust the raid level, select the IO scheduler, select the appropriate file system according to the scenario, configure the parameters of the selected scheduler, and use tools to analyze and optimize. Whether the result is ideal is written in the startup item.

  If you want to learn more Linux performance optimization tips or get started with cloud computing quickly, you can choose to study professionally. Make yourself a higher starting point for job search and faster employment!


Guess you like

Origin blog.51cto.com/14551723/2486871