linux 磁盘队列深度nr_requests 和 queue_depth

  • nr_requests 和 queue_depth
  • 修改配置值
  • nr_requests 和 queue_depth 区别
  • iostat 的avgqu-sz
  • lsscsi -l 的队列大小
  • iostat
  • nr_requests 和 queue_depth

    本文主要介绍Linux 操作系统中 nr_requests 和 queue_depth的参数意义和工作原理。以及结合iostat 的avgqu-sz 之间关系分析。

    1.nr_requests 和 queue_depth

    操作系统中nr_requests参数,可以提高系统的吞吐量,似乎越大越好,但是该请求队列的也不能过大,因为这样会消耗大量的内存空间。该值的调整需要综合多处因素,

    比如: 文件系统、sheduler类型、io的特点。

    命令: echo xxx > /sys/block//queue/nr_requests,nr_requests的大小设置至少是/sys/block//device/queue_depth的两倍,所以,修改nr_requtests的时候要注意。

    [root@node-1 ~]# cat /sys/block/sdj/queue/nr_requests
    256
    [root@node-1 ~]# cat /sys/block/sdj/device/queue_depth
    64

    2.修改配置值

    $ echo “512” > /sys/block/sda/queue/nr_requests     IO调度队列大小
    $ echo “512” > /sys/block/sda/device/queue_depth 磁盘队列深度

    3.nr_requests 和 queue_depth 区别

    • nr_requests:请求的IO调度队列大小
    • queue_depth:请求在磁盘设备上的队列深度
    • I/O调度器中的最大I/O操作数是nr_requests * 2。读和写是分开的。
    • 已经分配到底层设备的I/O操作是queue_depth。
    • 一个磁盘设备的I/O操作的最大未完成限制为(nr_requests * 2)+(queue_depth) 。对应iostat 的avgqu-sz。

    英文解释

     https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-storage_and_file_systems-configuration_tools

    nr_requests
    Specifies the maximum number of read and write requests that can be queued at one time.
    The default value is 128, which means that 128 read requests and 128 write requests can be queued before the next process to request a read or write is put to sleep. For latency-sensitive applications, lower the value of this parameter and limit the command queue depth on the storage so that write-back I/O cannot fill the device queue with write requests.

    When the device queue fills, other processes attempting to perform I/O operations are put to sleep until queue space becomes available.

    Requests are then allocated in a round-robin manner, which prevents one process from continuously consuming all spots in the queue. The maximum number of I/O operations within the I/O scheduler is nr_requests*2.

    As stated, nr_requests is applied separately for reads and writes.

    Note that nr_requests only applies to the I/O operations within the I/O scheduler and not to I/O operations already dispatched to the underlying device. Therefore, the maximum outstanding limit of I/O operations against a device is (nr_requests*2)+(queue_depth) where queue_depth is /sys/block/sdN/device/queue_depth, sometimes also referred to as the LUN queue depth.

    You can see this total outstanding number of I/O operations in, for example, the output of iostat in the avgqu-sz column. 指定一次可以排队的读请求和写请求的最大数目。

    默认值是128,这意味着128个读请求和128个写请求可以在请求读或写的下一个进程进入睡眠状态之前排队。 对于对延迟敏感的应用程序,可以降低该参数的值,并限制存储上的命令队列深度,以防止回写I/O用写请求填满设备队列。

    当设备队列满时,其他试图执行I/O操作的进程将进入休眠状态,直到队列空间可用。

    然后以循环的方式分配请求,这可以防止一个进程持续地消耗队列中的所有位置。 I/O调度器中的最大I/O操作数是nr_requests*2。

    如前所述,对于读和写,分别应用nr_requests。

    注意,nr_requests仅适用于I/O调度器中的I/O操作,而不适用已经分配到底层设备的I/O操作。
    因此,对一个设备的I/O操作的最大未完成限制为(nr_requests*2)+(queue_depth),其中queue_depth为/sys/block/sdN/device/queue_depth,有时也称为LUN队列深度。

    例如,您可以在avgqu-sz列中的iostat输出中看到这个未完成的I/O操作总数。

    4.iostat 的avgqu-sz

    该值大小为:(nr_requests*2)+(queue_depth)

    5.lsscsi -l 的队列大小

    Lun queue depth值来自 /sys/block/sdj/device/queue_depth

    [root@node-1 ~]# echo "128" >/sys/block/sdj/device/queue_depth
    [root@node-1 ~]# lsscsi -l | grep -A 1 sdj
    [0:0:16:0] disk SEAGATE ST1000NX0453 NS02 /dev/sdj
    state=running queue_depth=128 scsi_level=7 type=0 device_blocked=0 timeout=90
    [root@node-1 ~]# echo "256" >/sys/block/sdj/device/queue_depth
    [root@node-1 ~]# lsscsi -l | grep -A 1 sdj
    [0:0:16:0] disk SEAGATE ST1000NX0453 NS02 /dev/sdj
    state=running queue_depth=256 scsi_level=7 type=0 device_blocked=0 timeout=90

    6.iostat

    The default value is 1 (enabled).
    Setting iostats to 0 disables the gathering of I/O statistics for the device, which removes a small amount of overhead with the I/O path.
    Setting iostats to 0 might slightly improve performance for very high performance devices, such as certain NVMe solid-state storage devices.
    It is recommended to leave iostats enabled unless otherwise specified for the given storage model by the vendor. If you disable iostats, the I/O statistics for the device are no longer present within the /proc/diskstats file.

    The content of /sys/diskstats is the source of I/O information for monitoring I/O tools, such as sar or iostats.

    Therefore, if you disable the iostats parameter for a device, the device is no longer present in the output of I/O monitoring tools.
    缺省值为1(启用)。

    将iostats设置为0将禁用收集设备的I/O统计信息,这将减少I/O路径的少量开销。

    将iostats设置为0可能会略微提高非常高性能设备的性能,比如某些NVMe固态存储设备。

    除非供应商为给定的存储模型特别指定,否则建议保持启用iostats。

    如果禁用iostats,设备的I/O统计信息将不再存在于/proc/diskstats文件中。

    /sys/diskstats的内容是用于监视I/O工具(如sar或iostats)的I/O信息的来源。

    因此,如果对某个设备禁用iostats参数,该设备将不再出现在I/O监控工具的输出中。

    [转帖]linux 磁盘队列深度nr_requests 和 queue_depth的更多相关文章

    1. IO队列深度max_queue_depth对系统性能的影响

      前段时间,发生了一个问题引起了我对IO队列深度的研究. 存储服务器中linux kernel的mpt2sas驱动模块,将max_queue_depth设置为1024时,引起系统加载驱动时卡死,而调整为 ...

    2. Linux磁盘IO监控[zz]

      磁盘 I/O 监控是 Unix/Linux 系统管理中一个非常重要的组成部分.它可以监控吞吐量.每秒 I/O 数.磁盘利用率.服务时间等信息,并且在发现异常时,发送告警信息给系统管理员,便于系统管理员 ...

    3. MySQL 调优基础(四) Linux 磁盘IO

      1. IO处理过程 磁盘IO经常会成为系统的一个瓶颈,特别是对于运行数据库的系统而言.数据从磁盘读取到内存,在到CPU缓存和寄存器,然后进行处理,最后写回磁盘,中间要经过很多的过程,下图是一个以wri ...

    4. 条带深度 队列深度 NCQ IOPS

      http://blog.csdn.net/striping/article/details/17449653 IOPS 即I/O per second,即每秒进行读写(I/O)操作的次数,多用于数据库 ...

    5. linux磁盘及分区详解

      1.Linux 分区简介 1.1 主分区 vs 扩展分区 硬盘分区表中最多能存储四个分区,但我们实际使用时一般只分为两个分区,一个是主分区(Primary Partion)一个是扩展分区(extend ...

    6. Linux - 磁盘操作

      Linux 磁盘常见操作 : df -Ph # 查看硬盘容量 df -T # 查看磁盘分区格式 df -i # 查看inode节点 如果inode用满后无法创建文件 du -h 目录 # 检测目录下所 ...

    7. Linux磁盘分区和挂载

      Linux磁盘分区和挂载 分区 分区的方式: mbr分区 最多支持4个主分区 系统只能安装到主分区上 扩展分区要占用一个主分区 MBR最大支持2TB,但拥有最好的兼容性 gtp分区 支持无线多个主分区 ...

    8. linux磁盘I/O的性能评估

      linux磁盘I/O的性能评估 参考自:自学it网,http://www.zixue.it/. (1)使用iostat命令. [test@localhost /]$ iostat -d Linux - ...

    9. Linux crond任务调度(定时任务),Linux磁盘分区/挂载

      一.crond任务调度 1.基本语法 crontab [选项] -e : 编辑 crontab定时任务 -l : 查询crontab -r : 删除当前用户所有的crontab任务 例子: 每分钟执行 ...

    10. Linux 实用指令(7)--Linux 磁盘分区、挂载

      目录 Linux 磁盘分区.挂载 1 分区基础知识 1.1 分区的方式: 1.2 windows 下的磁盘分区 2 Linux分区 2.1 原理分析 2.2 磁盘说明 2.3 使用lsblk指令查看当 ...

    随机推荐

    1. Blazor技术入门

      曾写过点儿前后端分离的项目(Vue+.NET Core Web API).WPF和WinForm.因为Blazor不支持小程序的原因(相对于uniapp),所以只是大概知道Blazor可以写Web.P ...

    2. 支持60+数据传输链路,华为云DRS链路商用大盘点

      如今,业务上云已是时代潮流,技术的迅猛发展也使得上云变得愈发轻松起来.但在实际迁移过程中,客户仍会担心以下问题:不同数据库之间能迁吗?迁移前后数据不一致怎么办?可以不停机迁移吗-- 迁移毕竟是项大工程 ...

    3. 华为云数据库内核专家为您揭秘:GaussDB(for MySQL)并行查询有多快?

      摘要:GaussDB(for MySQL)并行查询为何快人一步?华为云数据库内核专家这样说 本文分享自华为云社区<华为云数据库内核专家为您揭秘:GaussDB(for MySQL)并行查询有多快 ...

    4. 使用阿里云镜像安装 Docker 服务

      Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE.社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施.容器. ...

    5. App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法

      iOS 备案查看信息 iOS平台Bundle ID 公钥 证书SHA-1指纹 IOS平台服务器域名 获取 Bundle ID: 或者 https://developer.apple.com/accou ...

    6. MySQL 数据分组后取第一条数据

      SQL SERVER数据分组后取第一条数据--PARTITION BY -- 不加 distinct(a.id) order by 会有问题 导致获取出来的数据不对 SELECT id,title,d ...

    7. Nacos 1.2.1 集群搭建(二)MySQL、cluster 配置

      三台虚机的IP地址被DHCP重分了一下1.MySQL 配置 先建一个 nacos_config 数据库 将SQL执行(方法很多,选自己喜欢的就行) 2.修改 application.propertie ...

    8. 在 SDXL 上用 T2I-Adapter 实现高效可控的文生图

      T2I-Adapter 是一种高效的即插即用模型,其能对冻结的预训练大型文生图模型提供额外引导.T2I-Adapter 将 T2I 模型中的内部知识与外部控制信号结合起来.我们可以根据不同的情况训练各 ...

    9. 机器学习周刊 第4期:动手实战人工智能、计算机科学热门论文、免费的基于ChatGPT API的安卓端语音助手、每日数学、检索增强 (RAG) 生成技术综述

      LLM开发者必读论文:检索增强(RAG)生成技术综述! 目录: 1.动手实战人工智能 Hands-on Al 2.huggingface的NLP.深度强化学习.语音课 3.Awesome Jupyte ...

    10. VA41 销售合同创建BAPI

      一.事务代码VA41 合同创建的过程和销售订单几乎一致 二.调用BAPI 调用BAPI为BAPI_CONTRACT_CREATEFROMDATA 传参和销售订单BAPI:BAPI_SALESORDER ...