rootless-containers / slirp4netns

User-mode networking for unprivileged network namespaces
GNU General Public License v2.0
729 stars 82 forks source link

CPU usage? #288

Open jmpolom opened 2 years ago

jmpolom commented 2 years ago

What is a normal amount of CPU usage/overhead to see with slirp4netns? I have a rootless container running with podman that uses a very small amount of network bandwidth (<100Mb/s) on a low power system and I'm seeing 17% CPU usage for the slirp4netns thread. The actual workload process consumes 13% CPU or less per thread. Is this normal?

AkihiroSuda commented 2 years ago

Seems quite normal. bypass4netns can save the CPU usage significantly (experimental): https://github.com/rootless-containers/bypass4netns

Szwendacz99 commented 1 year ago

I have whole stack of rootless podman containers on a raspberry pi 4, and since I switched from directly opening port for front container to using Rathole as a reverse proxy for NAT traversal, I started to see that slirp4netns is not only using much more cpu, but also the cpu usage is increasing over time (matter of days), and since I host it on rpi, and slirp4netns seem to work mainly with one thread, it is highly bottlenecking the transfer speed as it quickly reach near 100% of 1 cpu thread usage, even tho podman stats shows that no container is currently working hard. My versions are the newest for today on Fedora 37: podman-4.3.1, slirp4netns-1.2.0

My stack currently have two networks, but I tried using one, and it behaved the same way. Also I struggle to set network parameters through docker-compose.yml, but that is topic for different issue I guess.

slirp4netns is configured by podman-compose to run like this: /usr/bin/slirp4netns --disable-host-loopback --mtu=65520 --enable-sandbox --enable-seccomp --enable-ipv6 -c -r 3 --netns-type=path /run/user/1000/netns/rootless-netns-c5b94360335bbba9c9a4 tap0