aio interface incurs excessive system call overhead in high-concurrency scenarios, making it difficult to meet low-latency requirements.mq-deadline scheduler for NVMe, fully supports cgroup v2 IO bandwidth/IOPS limits, and provides the io_uring asynchronous IO interface. By properly adjusting the IO scheduler, file system mount options, and cgroup IO limits, you can ensure stable QoS for critical workloads on shared storage.none scheduler is recommended to achieve optimal latency. For HDDs, the bfq scheduler is recommended to achieve fair scheduling.ext4 data=writeback mode may lose recently written data in the event of a system crash. For databases and other strongly consistent workloads, use the default ordered mode.io.max limit takes effect only when the device is busy. Setting it to max means no limit is applied to the corresponding dimension./sys is read-only.Scheduler | Scenario | Description |
mq-deadline | NVMe / SSD | Deadline-based multi-queue scheduling, the default option |
none | NVMe (high performance) | Pass-through mode, no scheduling, suitable for low-latency devices. |
bfq | HDD / hybrid | Fair queue scheduling, suitable for interactive scenarios. |
kyber | NVMe | Adaptive scheduling, suitable for high concurrency. |
Interface File | Value Range | Default Value | Read/Write Description |
io.max | MAJ:MIN rbps=<N> wbps=<N> riops=<N> wiops=<N> | Unlimited ( max) | Read/write: set the upper limit for device read/write bandwidth and IOPS. |
io.weight | default 1-10000 | default 100 | Read/write: set the IO weight, which takes effect only when the device is busy. |
io.stat | Read-Only | - | Read: view current IO statistics (bytes/IOPS). |
Parameter | Value | Default Value | Description |
noatime | Mount Option | Not enabled | Do not update access time, reducing writes. |
data=writeback | ordered/writeback/journal | ordered | Writeback mode, performance first. Attention: A system crash may cause data loss. This mode is only suitable for scenarios where data loss is tolerable. |
discard | Mount Option | Not enabled | Enable TRIM (SSD/NVMe). |
sysctl -a to view the parameters available on the current system.Parameter | Recommended Value | Default Value | Description |
vm.dirty_ratio | 10-20 | 20 | Dirty page ratio threshold that triggers synchronous writeback |
vm.dirty_background_ratio | 5-10 | 10 | Dirty page ratio threshold that triggers asynchronous writeback |
vm.dirty_expire_centisecs | 3000 | 3000 | Dirty page expiration time (unit: 1/100 second, 3000 = 30 seconds) |
vm.swappiness | 10-20 | 60 | swap tendency. A lower value indicates a stronger tendency to reclaim memory pages. |
vm.dirty_writeback_centisecs | 500 | 500 | Dirty page writeback interval (unit: 1/100 second, 500 = 5 seconds) |
none scheduler is recommended for low latency, or keep mq-deadline for balanced performance by default. For HDDs, the bfq scheduler is recommended for fair scheduling.lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSvda 253:0 0 50G 0 disk└─vda1 253:1 0 50G 0 part /
# View the current scheduler (replace <device_name> with the actual device name obtained in the previous step)# The scheduler enclosed in square brackets [ ] in the output is the active one, and the rest are available schedulers supported by the system.# The list of supported schedulers may vary depending on the device and kernel version.cat /sys/block/<device_name>/queue/scheduler
none [mq-deadline] kyber bfq
none scheduler is recommended to achieve optimal latency. For HDDs, the bfq scheduler is recommended to achieve fair scheduling.echo none > /sys/block/<device_name>/queue/scheduler
cat /sys/block/<device_name>/queue/scheduler
none [none] kyber bfq
echo 'ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", ATTR{queue/scheduler}="none"' > /etc/udev/rules.d/60-io-scheduler.rules
udevadm trigger --type=devices --action=change
lsblk -o NAME,MAJ:MIN
NAME MAJ:MINnvme0n1 259:0
259:0 with the actual device number obtained in the previous step. No output is returned when the write operations succeed:io.max limit takes effect only when the device is busy. Setting it to max means no limit is applied to the corresponding dimension.mkdir /sys/fs/cgroup/io_limitedecho "259:0 rbps=10485760 wbps=10485760 riops=500 wiops=500" > /sys/fs/cgroup/io_limited/io.maxecho $PID > /sys/fs/cgroup/io_limited/cgroup.procs
cat /sys/fs/cgroup/io_limited/io.max
259:0 rbps=10485760 wbps=10485760 riops=500 wiops=500
noatime disables access time recording. Applications that rely on atime, such as tmpwatch, some backup tools, and monitoring tools, may be affected.mount -o remount,noatime,nodiratime /
mkfs.ext4 format operation erases all data on the target device. Before proceeding, use lsblk to confirm that the device name is correct to avoid formatting the system disk by mistake. Performing a remount operation on the root filesystem may affect applications that rely on access time (atime).data=writeback mode may cause data loss in the event of a system crash and is only suitable for scenarios where data loss is tolerable. Before proceeding, confirm that your workloads have no atime dependency and no strong consistency requirements.mkfs.ext4 -O has_journal /dev/vdb1mount -o noatime,data=writeback,discard /dev/vdb1 /data
mount | grep /data
/dev/vdb1 on /data type ext4 (rw,noatime,data=writeback,discard)
grep CONFIG_IO_URING=y /boot/config-$(uname -r)
CONFIG_IO_URING=y
kernel.io_uring_disabled controls io_uring availability: 0=fully enabled, 1=available only to privileged users, 2=completely disabled:sysctl -a | grep io_uring
kernel.io_uring_disabled = 0
kernel.io_uring_disabled takes effect immediately after modification:1, ordinary user processes will be unable to use io_uring;2 completely disables io_uring, causing applications that depend on io_uring, such as databases and network services, to fail to work properly.sysctl -w kernel.io_uring_disabled=1
kernel.io_uring_disabled = 1
echo "kernel.io_uring_disabled = 1" > /etc/sysctl.d/99-io-uring.confsysctl --system
sysctl --system lists the loaded configuration files and parameter values):* Applying /etc/sysctl.d/99-io-uring.conf ...kernel.io_uring_disabled = 1
# Install fiodnf install -y fio
--size and --numjobs parameters should be adjusted according to actual hardware specifications. Excessively large values may consume too much memory.rm -f seqread.* randrw_*).fio --name=seqread --rw=read --bs=1M --size=1G --numjobs=1 --time_based --runtime=60 --group_reporting
seqread: (g=0): rw=read, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, io=60.0GiB...read: IOPS=18.2k, BW=18.2GiB/s (19.6GB/s)(60.0GiB/60001msec)
fio --name=randrw --rw=randrw --bs=4k --size=1G --numjobs=4 --time_based --runtime=60 --group_reporting --rwmixread=70
randrw: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, io=3364MiB...read: IOPS=71.8k, BW=280MiB/s (294MB/s)(42.0GiB/60001msec)write: IOPS=30.7k, BW=120MiB/s (126MB/s)(18.0GiB/60001msec)
read: IOPS=xxx and write: IOPS=xxx lines in the output are key metric lines. You can use them to compare the results before and after tuning.# 1. Confirm root privilegessudo -i# 2. View the schedulers supported by the devicecat /sys/block/<device_name>/queue/scheduler# 3. If the target scheduler is not in the list, the kernel does not have this scheduler compiled.
# View the device queue depthcat /sys/block/<device_name>/device/queue_depth# Check file system mount parametersmount | grep <device_name>
# 1. Confirm that cgroup v2 is enabled.mount | grep cgroup2# 2. Confirm that the io controller is available.cat /sys/fs/cgroup/cgroup.controllers | grep io# 3. Confirm that the limit values have been written.cat /sys/fs/cgroup/<cgroup_name>/io.max
ordered mode and avoid switching to writeback mode./sys directory is typically mounted read-only, and processes inside the container do not have permission to modify kernel parameters such as block device scheduling policies.--privileged) to obtain write access to /sys.Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan