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. 文心一言 VS 讯飞星火 VS chatgpt (50)-- 算法导论6.2 2题

      二.参考过程 MAX-HEAPIFY,写出能够维护相应最小堆的 MIN-HEAPIFY(A,i)的伪代码,并比较 MIN-HEAPIFY 与 MAX-HEAPIFY 的运行时间. 文心一言: MIN- ...

    2. Java 获取PDF中的数字签名信息

      一.概述及程序环境要求 本文以Java代码演示如何获取PDF文档中的数字签名信息,包括签名人.签名位置.日期.原因.联系方式.签名在文档中的坐标等等. 程序环境包括: Spire.Pdf.jar(ja ...

    3. 3天上手Ascend C编程丨带你认识Ascend C基本概念及常用接口

      本文分享自<[2023 · CANN训练营第一季]--Ascend C算子开发入门--第一次课(核函数的定义及实现)>,作者:dayao. Ascend C是CANN针对算子开发场景推出的 ...

    4. 六步带你完成博流wifi模组对接华为云流程

      摘要:本文主要采用基于博流wifi模组以及我们的SDK移植实现华为云的对接,上报数据以及命令下发等,希望对您有所帮助. 1 简介 首先需要研究透彻博流项目的编译运行流程,首先看其根目录中包括compo ...

    5. MySQL数据库事务隔离性的实现

      摘要:事实上在数据库引擎的实现中并不能实现完全的事务隔离,比如串行化. 本文分享自华为云社区<[数据库事务与锁机制]- 事务隔离的实现>,原文作者:技术火炬手 . 事实上在数据库引擎的实现 ...

    6. Vue组件间的传值五大场景,你造吗?

      摘要:组件是 vue.js最强大的功能之一,这五个组件间传值场景你了解吗? 本文分享自华为云社区<你了解Vue组件间传值五大场景吗?>,作者:北极光之夜. . 父组件向子组件传值: 比如有 ...

    7. storybook组件属性详解:组件props到strorybook Args

      首先我们查看官方文档:https://storybook.js.org/docs/vue/writing-docs/doc-block-argstable#customizing 官方的例子么有看到v ...

    8. 【已解决】Uiautomatorviewer报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationT...

      报错 使用Uiautomatorviewer连接真机报错Unexpected error while obtaining UI hierarchy (获取UI层次结构时出现意外错误) android8 ...

    9. 从 Rancher 学习 K8s - Rancher 的基础使用

      舞台环境 Rancher v2.6.9 K8s v1.24.16 如果你不具备该环境,可以移步 使用 Rancher 安装 K8s 集群 查看.本文适合已经了解了 k8s 基础概念,想使用 ranch ...

    10. 【短道速滑二】古老的基于亮度平均值的自动Gamma校正算法。

      在github上搜索代码Auto Gamma Correction,找到一个比较古老的代码,详见:https://github.com/PedramBabakhani/Automatic-Gamma- ...