[转帖]Optimizing Block Device Parameter Settings of Linux

optimizing,block,device,parameter,settings,of,linux · 浏览次数 : 0

小编点评

**Block Device Parameter Settings** **Optimal Queue Depth:** - The queue depth determines the maximum number of concurrent I/Os written to the block device. - The default value is 128. - Increasing the queue depth can increase I/O write pressure but may impact performance. **Prefetch Volume:** - The prefetch volume determines the number of sectors prefetched from the storage array. - The default value is 512. - Increasing the prefetch volume can improve performance for sequential reads but may reduce performance for other operations. **I/O Alignment:** - MBR partitions have a reserved 63 sectors for the master boot record and partition table. - Misalignment between data blocks can slow down I/O operations. - The system can resolve I/O misalignment by changing the start location of a partition or using GPT partitions. **Other Optimization Tips:** - Use the `cat.linux-ob3a` command to query and adjust block device settings. - Experiment with different queue depth, prefetch volume, and I/O alignment values to find the optimal settings for your system. - Consider using tools like `iotune` for advanced performance profiling and optimization.

正文

https://support.huawei.com/enterprise/en/doc/EDOC1000181485/ddbc0e8b/optimizing-block-device-parameter-settings-of-linux#:~:text=The%20queue%20depth%20determines%20the%20maximum%20number%20of,block%20device%2C%20run%20cat.%20linux-ob3a%3A~%20%23%20cat%20%2Fsys%2Fblock%2Fsdc%2Fqueue%2Fnr_requests

 

Operating block devices will greatly affect host performance. Correct configuration of the queue depth scheduling algorithm, prefetch volume, and I/O alignment for block devices helps improve the system performance.

Queue Depth

The queue depth determines the maximum number of concurrent I/Os written to the block device. In Linux, the default value is 128. Do not change the value unless absolutely necessary. To query the queue depth of the block device, run cat.

linux-ob3a:~ # cat /sys/block/sdc/queue/nr_requests 
128

In the event of testing the highest system performance, you can set the queue depth to a larger value to increase the I/O write pressure and the probability of combining I/Os in the queue. To temporarily change the queue depth of a block device, use the following method:

echo 256 > /sys/block/sdc/queue/nr_requests

You can tune the performance by temporarily changing the queue depth of a block device. After the application server is restarted, the queue depth is restored to the default value.

Scheduling Algorithm

Linux 2.6 kernel supports four types of block device scheduling algorithms: noop, anticipatory, deadline, and cfq. The default scheduling algorithm is cfq. To query the block device scheduling algorithm in use, run cat.

linux-ob3a:~ # cat /sys/block/sdc/queue/scheduler 
noop deadline [cfq] 

Inappropriate configuration of the scheduling algorithm affects system performance, such as I/O concurrency. You can use the following method to temporarily change the scheduling algorithm of the block device:

echo noop > /sys/block/sdc/queue/scheduler

You can tune the performance by temporarily changing the scheduling algorithm. After the application server is restarted, the scheduling algorithm is restored to the default value.

Prefetch Volume

Similar to the prefetch algorithm of a storage array, the prefetch function of Linux is only available for sequential read, sequential streams identification, and reading of data in the read_ahead_kb length (in units of sectors) in advance. For example, the default prefetch volume in SUSE 11 is 512 sectors, namely, 256 KB. To query the prefetch volume of the block device, run cat.

linux-ob3a:~ # cat /sys/block/sdc/queue/read_ahead_kb 
512

If an application needs to read a large number of large-sized files, you can raise the system performance by setting the prefetch volume to a larger value. To do this, use the following method:

echo 1024 > /sys/block/sdc/queue/read_ahead_kb

I/O Alignment

If MBR partitions are created in Linux or Windows (pre Windows Server 2003 versions), the first 63 sectors of a disk are reserved for the master boot record and partition table. The first partition starts from the 64th sector by default. As a result, misalignment occurs between data blocks (database or file system) delivered by hosts and data blocks stored in the storage array, causing poor I/O processing efficiency.

In Linux, you can resolve I/O misalignment in either of the following ways:

  • Method 1: Change the start location of a partition.

    When creating MBR partitions in Linux, it is recommended that you enter the expert mode of the fdisk command and set the start location of the first partition to that of the second extent on a LUN. The default extent size is 4 MB. The following is a quick command used to create an MBR partition in /dev/sdb. The partition uses all space of /dev/sdb. The start sector is set to 8192, namely, 4 MB.

    printf "n\np\n1\n\n\nx\nb\n1\n 8192\nw\n" | fdisk /dev/sdb
  • Method 2: Create GPT partitions.

    The following is a quick command used to create a GPT partition in /dev/sdb. The partition uses all space of /dev/sdb. The start sector is set to 8192, namely, 4 MB.

    parted -s -- /dev/sdb "mklabel gpt" "unit s" "mkpart primary 8192 -1" "print"

To create MBR partitions in Windows (pre Windows Server 2003 versions), it is recommended that you run diskpart to set partition alignment.

diskpart> select disk 1 
diskpart> create partition primary align=4096

与[转帖]Optimizing Block Device Parameter Settings of Linux相似的内容:

[转帖]Optimizing Block Device Parameter Settings of Linux

https://support.huawei.com/enterprise/en/doc/EDOC1000181485/ddbc0e8b/optimizing-block-device-parameter-settings-of-linux#:~:text=The%20queue%20depth%2

[转帖]Memory optimization

https://redis.io/docs/management/optimization/memory-optimization/ Strategies for optimizing memory usage in Redis Special encoding of small aggregate

[转帖]

Linux ubuntu20.04 网络配置(图文教程) 因为我是刚装好的最小系统,所以很多东西都没有,在开始配置之前需要做下准备 环境准备 系统:ubuntu20.04网卡:双网卡 网卡一:供连接互联网使用网卡二:供连接内网使用(看情况,如果一张网卡足够,没必要做第二张网卡) 工具: net-to

[转帖]

https://cloud.tencent.com/developer/article/2168105?areaSource=104001.13&traceId=zcVNsKTUApF9rNJSkcCbB 前言 Redis作为高性能的内存数据库,在大数据量的情况下也会遇到性能瓶颈,日常开发中只有时刻

[转帖]ISV 、OSV、 SIG 概念

ISV 、OSV、 SIG 概念 2022-10-14 12:29530原创大杂烩 本文链接:https://www.cndba.cn/dave/article/108699 1. ISV: Independent Software Vendors “独立软件开发商”,特指专门从事软件的开发、生产、

[转帖]Redis 7 参数 修改 说明

2022-06-16 14:491800原创Redis 本文链接:https://www.cndba.cn/dave/article/108066 在之前的博客我们介绍了Redis 7 的安装和配置,如下: Linux 7.8 平台 Redis 7 安装并配置开机自启动 操作手册https://ww

[转帖]HTTPS中间人攻击原理

https://www.zhihu.com/people/bei-ji-85/posts 背景 前一段时间,公司北京地区上线了一个HTTPS防火墙,用来监听HTTPS流量。防火墙上线之前,邮件通知给管理层,我从我老大那里听说这个事情的时候,说这个有风险,然后意外地发现,很多人原来都不知道HTTPS防

[转帖]关于字节序(大小端)的一点想法

https://www.zhihu.com/people/bei-ji-85/posts 今天在一个技术群里有人问起来了,当时有一些讨论(不完全都是我个人的观点),整理一下: 为什么网络字节序(多数情况下)是大端? 早年设备的缓存很小,先接收高字节能快速的判断报文信息:包长度(需要准备多大缓存)、地

[转帖]awk提取某一行某一列的数据

https://www.jianshu.com/p/dbcb7fe2da56 1、提取文件中第1列数据 awk '{print $1}' filename > out.txt 2、提取前2列的文件 awk `{print $1,$2}' filename > out.txt 3、打印完第一列,然后打

[转帖]awk 中 FS的用法

https://www.cnblogs.com/rohens-hbg/p/5510890.html 在openwrt文件 ar71xx.sh中 查询设备类型时,有这么一句, machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /