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的时候要注意。

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

    2.修改配置值

    1. $ echo 512 > /sys/block/sda/queue/nr_requests IO调度队列大小
    2. $ 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

    1. nr_requests
    2. Specifies the maximum number of read and write requests that can be queued at one time.
    3. 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.
    4. 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.

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

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

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

    9. 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.
    10. 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.

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

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

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

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

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

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

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

    24.  

    4.iostat 的avgqu-sz

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

    5.lsscsi -l 的队列大小

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

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

    6.iostat

    1. The default value is 1 (enabled).
    2. 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.
    3. Setting iostats to 0 might slightly improve performance for very high performance devices, such as certain NVMe solid-state storage devices.
    4. It is recommended to leave iostats enabled unless otherwise specified for the given storage model by the vendor.
    5. If you disable iostats, the I/O statistics for the device are no longer present within the /proc/diskstats file.

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

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

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

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

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

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

    15. /sys/diskstats的内容是用于监视I/O工具(如sariostats)的I/O信息的来源。

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

    17.  

    [转帖]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 (158)-- 算法导论12.3 5题

      五.用go语言,假设为每个结点换一种设计,属性 x.p 指向 x 的双亲,属性 x.succ 指向 x 的后继.试给出使用这种表示法的二叉搜索树 T 上 SEARCH.INSERT 和DELETE 操 ...

    2. .NET Web应用配置本地IIS(实现Visual Studio离线运行与调试)

      前言: 因为项目程序需要频繁的修改,然后每次修改以后都要重新编译才能查看到修改的效果.而且有时候前端也需要及时的对接我们的接口,导致每次修改一点东西都要发布一次,这样子对于开发者而言是十分的浪费时间, ...

    3. Unreal学习笔记1-打印输出

      1. 概述 相比各种打断点调试的办法,还是更习惯使用打印输出来进行调试. 2. 详论 2.1. 代码 这里写了三个函数:分别是输出到屏幕,输出到警告日志,输出错误日志. Output.h: #prag ...

    4. 全域Serverless化,华为云引领下一代云计算新范式

      本文分享自华为云社区<全域Serverless化,华为云引领下一代云计算新范式>,作者: 华为云PaaS服务小智 . 近日,华为开发者大会2023(Cloud)在东莞成功举办,期间&quo ...

    5. 性能提升1400+倍,快来看MySQL Volcano模型迭代器的谓词位置优化详解

      摘要:性能提升1400+倍,快来看MySQL Volcano模型迭代器的谓词位置优化详解. 本文分享自华为云社区<华为云数据库内核专家为您揭秘MySQL Volcano模型迭代器性能提升千倍的秘 ...

    6. 什么是 A/B 实验,为什么要开 A/B 实验?

      更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 1.什么是 A/B 实验 A/B 实验也被称为 A/B 测试,实验的基本思路是在线上流量中取出一小部分(较低风险) ...

    7. 朋友们,就在今天,JDK 21,它终于带着重磅新特性正式发布了!

      你好呀,我是歪歪. 朋友们,好消息,好消息,重磅好消息. 从今年年初就一直在喊的具有革命性.未来性.开创新纪元的 JDK 21 按照官方的时间计划表,今天终于是要正式 GA 了: https://op ...

    8. Python pdf 转 图片

      安装依赖 D:\OpenSource\Python>pip install pdf2image pillow -i https://pypi.tuna.tsinghua.edu.cn/simpl ...

    9. module 'numpy' has no attribute 'int'.

      原因:np.int 在 NumPy 1.20 中已弃用,在 NumPy 1.24 中已删除 AttributeError: module 'numpy' has no attribute 'int'. ...

    10. TypeError: this.libOptions.parse is not a function

      安装完node.js运行项目后,报错: TypeError: this.libOptions.parse is not a function at ESLint8Plugin.<anonymou ...