我最近一直在阅读有关 OpenOnload 的文章,它在某些网络操作期间绕过 Linux 内核以提高性能。这让我很好奇同一台服务器上的 LXC 容器之间的网络数据是如何处理的。如果我将数据从一个发送到另一个,它会多次通过内核 TCP 堆栈吗?如果是这样,与共享内存(如果我不使用 LXC 时我可能会使用)之类的东西相比,这会增加多少延迟?某种内核旁路对于 LXC-LXC 通信是否可行?
最佳答案
如你所知:
The Linux kernel comprises cgroups for resource isolation (CPU, memory, block I/O, network, etc.) that does not require starting any virtual machines. Cgroups also provides namespace isolation to completely isolate applications' view of the operating environment, including process trees, network, user ids and mounted file systems.
LXC combines cgroups and namespace support to provide an isolated environment for applications. You asked: This made me curious about how network data between LXC containers on the same server is handled.
这就像 linux mashine 上的一个进程与同一 mashine 上的另一个/相同进程通信,但如果他使用一个或两个 linux 网桥(容器内的 LXC 网络)+ 不同 cgroups/命名空间内的那些网桥。
If I send data from one to another, does it go all the way through the kernel TCP stack multiple times? If so, how much latency does this add compared to something like shared memory (which I might use if I wasn't using LXC)? Is some sort of kernel bypass feasible for LXC-LXC communication?
延迟不是很大,但是当我使用 php-fpm 作为监听 127.0.0.1:8888 的守护进程并将其更改为监听 unix 套接字时,rps(每秒页数)有所增加。 Performance of unix sockets vs TCP ports
附言: 您可以在 LXC 容器上使用 unix 套接字。例如,我用来在所有容器之间创建共享目录(例如:/tmp/mysql.sock):
mount --bind /lxc/shared /lxc/shared
mount --make-unbindable /lxc/shared
关于linux - 网络数据在同一物理主机上的两个 LXC 容器之间走什么路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27661184/