Running in containers
Why OrbitMQ runs on epoll in Docker and Kubernetes by default, how to opt in to io_uring with a seccomp profile, and how to check which backend is active.
OrbitMQ's data plane runs one event loop per core. On Linux each loop uses io_uring when the kernel allows it and falls back to epoll otherwise. macOS uses kqueue. Both Linux backends are fully supported and behave the same for clients; they differ only in how efficiently the broker talks to the kernel.
The default in containers: epoll
Docker's and containerd's default seccomp profiles (Docker, Podman, and Kubernetes pods with
seccompProfile: RuntimeDefault) block the io_uring system calls: io_uring_setup fails with EPERM. OrbitMQ
detects this at startup and runs on epoll. This is the expected, supported configuration. You do not need to
change anything, and you should not disable seccomp to "fix" it.
The startup log says so:
INFO orbitmq_server: I/O backend: epoll (io_uring unavailable: io_uring_setup returned EPERM: blocked by seccomp (container default profile))Trade-off
| epoll (default) | io_uring (opt-in) | |
|---|---|---|
| Container runtime default profile | works | blocked; needs a custom profile |
| System calls per I/O | one per read or write | batched through shared rings, fewer calls |
| CPU per message | higher | usually lower at high message rates |
| Kernel attack surface | small, long-established | larger; io_uring has had several privilege-escalation bugs |
The last row is why container runtimes block io_uring by default, and why some distributions also turn it off
with the kernel.io_uring_disabled sysctl. Opt in only if the CPU saving matters to you and you keep the host
kernel patched.
Opting in to io_uring
Use a seccomp profile that is the runtime's default plus the three io_uring calls (io_uring_setup,
io_uring_enter, io_uring_register), so every other system call keeps the default decision. The deploy
repository ships one: docker/seccomp/orbitmq-io-uring.json, Docker's default profile with that single
addition. Its README records which Docker release it was taken from and the upstream Apache-2.0 licence.
Never use seccomp=unconfined
--security-opt seccomp=unconfined removes the whole system-call filter, not just the io_uring block. Use the
profile above instead.
Docker
docker run -d --name orbitmq -p 1883:1883 \
--security-opt seccomp=/path/to/orbitmq-io-uring.json \
<orbitmq image>With Compose, add the profile under security_opt:
services:
orbitmq:
image: <orbitmq image>
security_opt:
- seccomp=./orbitmq-io-uring.jsonKubernetes
Kubernetes loads Localhost seccomp profiles from each node's kubelet seccomp directory
(/var/lib/kubelet/seccomp/ by default). Copy the profile to every node that may run OrbitMQ, for example to
/var/lib/kubelet/seccomp/profiles/orbitmq-io-uring.json, then reference it in the pod:
spec:
securityContext:
seccompProfile:
type: Localhost
localhostProfile: profiles/orbitmq-io-uring.jsonA pod whose profile file is missing on its node does not start, so put the file in place first (node image or
cloud-init, a DaemonSet that copies it from a ConfigMap, or the Security Profiles Operator), and use a
nodeSelector if only some nodes have it. Managed clusters that do not allow files on nodes cannot use Localhost
profiles; OrbitMQ runs on epoll there. A Helm chart option for this is planned with the chart.
Checking the active backend
Three places report the same value:
- the startup log line
I/O backend: io_uring(orepoll (io_uring unavailable: <reason>)); GET /api/v1/status, fieldsio_backendandio_uring_unavailable(see the admin API);- the metric
orbitmq_runtime_info{backend="io_uring"} 1(see Observability).
curl -s -H "Authorization: Bearer $ORBITMQ_TOKEN" http://127.0.0.1:18083/api/v1/status
# { ..., "io_backend": "io_uring", "io_uring_unavailable": null }If you applied the profile and still see epoll, io_uring_unavailable gives the reason:
| Reason | Cause |
|---|---|
EPERM: blocked by seccomp | The container still runs with the default profile: check the --security-opt or seccompProfile. |
EPERM: disabled by sysctl kernel.io_uring_disabled=2 | The host disables io_uring for everyone. |
EPERM: restricted by sysctl kernel.io_uring_disabled=1 | Only members of kernel.io_uring_group may use io_uring. |
ENOSYS | The kernel has no io_uring, or a sandbox (such as gVisor) does not implement it. |
kernel lacks opcodes the runtime needs | The kernel is too old for the operations the broker uses. |
CPU limits and pinning
With pin_threads = true (the default) each core thread is pinned to a CPU of the process's affinity mask. A CPU
quota alone (docker run --cpus, a Kubernetes CPU limit) does not narrow that mask, so every such container would pin
to the same first CPUs of the host and contend there while others idle. The broker therefore does not pin under a CPU
quota without a cpuset, leaves placement to the scheduler and logs this once at start-up. It reads the quota from
cgroup v1 or v2.
It still pins when a cpuset limits the CPUs (docker run --cpuset-cpus, the Kubernetes static CPU manager), because
those CPUs are the container's own, and when there is no quota. The number of data-plane cores is not affected: by
default it still follows the quota.
Memory limits
The broker reads the container's memory limit (cgroup v2, else cgroup v1) and, by default, lets queued messages use at most half of it; without a cgroup limit it uses the machine's physical memory instead. A broker in a 256 MiB container therefore queues at most 128 MiB of messages before it starts dropping the oldest messages of the longest queues. Raising the container limit raises the budget with it. See Session queues to change the share or set a fixed budget.