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. Vue接入谷歌广告(Google Adsense)

      1.注册账户 首先你要拥有一个google账号,点击注册谷歌账号,点击个人账号根据提示一步一步来即可注册成功.(当然你需要魔法才可以正常访问谷歌服务) 2.补充账户信息,申请广告授权 点击进入Goog ...

    2. 微信小程序卡片

      1.1 效果 左右滑动 1.2 代码 <view class="container"> <swiper autoplay interval="4000& ...

    3. vue常用函数

       this.$router.back();  //回退上一页面

    4. 过亿云资源运维管控难?华为云CloudMap带你喝着咖啡做运维

      摘要:华为云站点数字化平台CloudMap携手华为云图引擎GES打造云服务全栈拓扑,网络流量路径和云服务动态依赖等空间关系数据,支撑现网运行态风险识别和分钟级定位定界,构建业界领先的数字化能力. 本文 ...

    5. css过去及未来展望—分析css演进及排版布局的考量

      读初二的时候,学校有了计算机,也简单地介绍了下网页,不过那是的html 都是table,也没有去细看.到了高中,qq空间有个html模式,为了让文章好看点.也浅尝辄止地学了下css css简介 在HT ...

    6. 火山引擎 DataTester 首推 A/B 实验经验库,帮助企业高效优化实验设计能力

        更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 近日,火山引擎 DataTester 推出了重要功能--A/B 实验经验库. 基于在字节跳动已完成 150 万 ...

    7. 用 Java?试试国产轻量的 Solon v1.10.1

      相对于 Spring Boot 和 Spring Cloud 的项目: 启动快 5 - 10 倍. (更快) qps 高 2- 3 倍. (更高) 运行时内存节省 1/3 ~ 1/2. (更少) 打包 ...

    8. 微软的一些公开课,Python、机器学习、SQL、AI,全部免费

      大家好,我是老章,刷X看到一位博主Alif Hossain@alifcoder总结了微软的一些公开课,全部免费,蛮不错的.感兴趣可以学一波,还能领徽章. 1. 机器学习简介 本课程是学习机器学习基础知 ...

    9. CodeFormer一款既能人脸修复、还能视频去码的AI软件,附下载使用教程

      CodeFormer是一款强大的人工智能工具,主要用于图像和视频的修复和增强.它基于深度学习技术,特别是人脸复原模型,可以轻松修复和增强面部图像,提升照片和视频的质量和视觉效果 工作原理 1.通过自动 ...

    10. java jar 注册成 windows 服务

      1.去github上下载winsw https://github.com/winsw/winsw/releases 2.WinSW.NET4.xml <service> <id> ...