











envoy 是异步事件驱动的。使用了libevent库来实现。
libevent开启了多线程支持,evthread_use_pthreads(),这个API会打开线程锁。允许跨线程的事件操作。
envoy 有一个master线程,多个worker线程。每个线程有自己的event_fd。
在各线程,event_fd,由 dispatcher 封装。 master 和 worker 之间会相互调用对方的 dispatcher, 所以,libevent需要线程锁。
envoy代码实现在目录: envoy/source/common/event/
libevent代码实现在:https://github.com/libevent/libevent/blob/release-2.1.12-stable/event.c#L1923


envoy 1.34 之后就支持了 io_uring, 可以将主要网络IO模型中的 libevent去掉,也就同时去掉了锁。
不过现在还在迭代中,不是个稳定功能
https://www.envoyproxy.io/docs/envoy/latest/configuration/other_features/io_uring.html
https://arthurchiao.art/blog/intro-to-io-uring-zh/
内核需要5.11版本。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。