Linux Internals
io_uring Explained: Fast Asynchronous I/O on Linux
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيFor decades, Linux applications did I/O with blocking system calls like read() and write(), or juggled readiness notifications through epoll. Each operation meant at least one trip into the kernel, and true asynchronous file I/O was awkward. io_uring, added in Linux 5.1 in 2019, changed that by letting applications queue many I/O requests in shared memory and collect results without a system call per operation. This article explains how it works, where it helps, and what to watch for on a VPS.
The problem io_uring solves
Every system call has a cost: switching from user mode to kernel mode, checking arguments, and switching back. Security mitigations for CPU vulnerabilities made those transitions more expensive. A server doing hundreds of thousands of small reads per second spends a real share of its CPU just crossing that boundary.
Older options had limits:
- Blocking calls need one thread per in-flight operation, which wastes memory and causes context switches.
- epoll tells you when a socket is ready, but you still issue a separate
read()orwrite(), and it does not work for regular files. See our epoll guide. - Linux AIO (`io_submit`) worked well mainly with
O_DIRECTfiles and could block in surprising cases.
How io_uring works
io_uring is built around two ring buffers shared between your process and the kernel:
| Ring | Written by | Contains |
|---|---|---|
| Submission Queue (SQ) | Application | Submission Queue Entries (SQEs): "read 4 KB from fd 7 at offset X into this buffer" |
| Completion Queue (CQ) | Kernel | Completion Queue Entries (CQEs): result code plus your user data tag |
The flow:
- The application calls
io_uring_setup()once and maps the rings into memory. - It writes one or many SQEs into the submission ring.
- It calls
io_uring_enter()to tell the kernel there is work. One call can submit a whole batch. - The kernel performs the operations and posts CQEs.
- The application reads completions from the CQ ring, often without any system call.
Because the rings are shared memory, batching dozens of operations costs about as much as one system call. With the optional SQPOLL mode, a kernel thread polls the submission ring so the application may not need to enter the kernel at all, at the price of a CPU core spinning.
Other features include registered (fixed) files and buffers that avoid repeated setup costs, linked operations that run in order, and support for far more than disk I/O: network accept, send, recv, connect, timeouts, openat, statx and more.
Who uses io_uring
- Databases and storage engines. PostgreSQL 18 added an
io_methodsetting with anio_uringoption for asynchronous reads on Linux. Several storage engines and newer databases use it directly. - Virtualization. QEMU can use io_uring as a disk backend (
aio=io_uring). - Runtimes and libraries.
liburing(C),tokio-uringandglommio(Rust), and others wrap the interface. - Benchmarking.
fioships anio_uringengine.
Most application developers will not call io_uring directly. You benefit when your database, proxy or runtime supports it.
Checking support on your server
uname -r # kernel version
cat /proc/sys/kernel/io_uring_disabled # exists on 6.6+: 0 allowed, 1 restricted, 2 disabled
grep -c io_uring /proc/kallsyms # non-zero if built into the kernelModern LTS distributions such as Ubuntu 24.04 and Debian 12 ship kernels with io_uring enabled. Features keep being added, so newer kernels support more operation types.
Trying it with fio
fio lets you compare engines on your own disk. Run this in a test directory, never against a raw device that holds data:
sudo apt install fio
fio --name=uring --ioengine=io_uring --rw=randread --bs=4k \
--size=1G --iodepth=32 --numjobs=1 --direct=1 \
--runtime=30 --time_based --group_reporting
fio --name=psync --ioengine=psync --rw=randread --bs=4k \
--size=1G --numjobs=1 --direct=1 \
--runtime=30 --time_based --group_reportingCompare IOPS, latency percentiles and CPU usage (usr/sys). Results depend heavily on the storage behind your VPS and on queue depth, so treat them as a measurement of your environment rather than a general verdict.
Security considerations
io_uring is a large, fast-moving kernel interface, and it has had a number of serious vulnerabilities. Some large organizations restrict or disable it on sensitive systems, and Docker's default seccomp profile blocks the io_uring system calls inside containers.
Practical advice:
- Keep your kernel updated; most fixes arrive through normal distribution updates.
- If nothing on the server needs io_uring, you can restrict it on kernels 6.6 and newer:
echo 'kernel.io_uring_disabled = 2' | sudo tee /etc/sysctl.d/90-io-uring.conf
sudo sysctl --system Value 1 limits it to processes in the group set by kernel.io_uring_group or with CAP_SYS_ADMIN.
- Before disabling, check that your database or runtime does not depend on it, and confirm that it falls back cleanly.
When io_uring matters for you
io_uring shines with high I/O rates and many small operations: busy databases, storage services, proxies handling many connections. For a typical website, the bottleneck is usually elsewhere, such as slow queries or missing caching. If you are planning an I/O-heavy workload, fast NVMe storage matters as much as the interface; you can deploy a server and run the fio tests above in minutes.
FAQ
Is io_uring always faster than epoll or normal read and write?
No. It reduces system call overhead and enables real asynchronous file I/O, which helps at high operation rates. For light workloads the difference is often too small to notice, and a poorly designed program can be slower with any interface.
Do I need to change my application to use io_uring?
Only if you write low-level I/O code. Most people benefit indirectly by running software that already supports it and enabling the relevant option, such as io_method = io_uring in PostgreSQL 18.
Should I disable io_uring for security?
If no service on the server uses it and you want to reduce kernel attack surface, restricting it with kernel.io_uring_disabled is reasonable. If your database relies on it, keep it enabled and keep the kernel patched instead.