作為proxy具備的功能
downstream連接管理
upstream hosts管理
load balance
轉(zhuǎn)發(fā)
熔斷限流
過載保護(hù)
plugin式的動態(tài)加載機制棠隐,在envoy中為filter
hot reload
downstream連接管理
在server InstaceImpl構(gòu)建函數(shù)中initialize時,創(chuàng)建listener_manager_檐嚣,由listener_manager_負(fù)責(zé)addOrUpdateListener
助泽。
ListenerImpl創(chuàng)建時會進(jìn)行相關(guān)filter的構(gòu)造,如果worker已經(jīng)started會調(diào)用onListenerWarmed將自己添加到woker中嚎京。
worker 持有的ConnectionHandlerImpl addListener
--> ActiveListener::onAccept
--> ActiveListener::newConnection
--> createNetworkFilterChain
進(jìn)行相應(yīng)協(xié)議filter的處理過程
// Network::ConnectionCallbacks in ActiveConnection
void onEvent(Network::ConnectionEvent event) override {
// Any event leads to destruction of the connection.
if (event == Network::ConnectionEvent::LocalClose ||
event == Network::ConnectionEvent::RemoteClose) {
listener_.removeConnection(*this);
}
}
upstream hosts管理
cluster manager負(fù)責(zé)管理upstream hosts及相關(guān)策略嗡贺。
load順序static non-EDS
--> ADS
--> static EDS
--> ThreadLocalClusterManagerImpl
--> CDS
worker真正使用的是cluster manager的thread local的版本,cluster manager通過在TLS上注冊的thread dispatcher list使用dispatcher的post方法進(jìn)行更新鞍帝。
load balance
enum class LoadBalancerType { RoundRobin, LeastRequest, Random, RingHash, OriginalDst, Maglev };
熔斷限流
實現(xiàn)在source/common/upstream/outlier_detection_impl.*
中诫睬。
plugin式的動態(tài)加載機制,在envoy中為filter
使用靜態(tài)變量注冊Factory帕涌,根據(jù)配置動態(tài)加載
hot reload
使用shared memory保持統(tǒng)計信息和進(jìn)程間共享的鎖摄凡,用unix domain socket傳遞fd续徽。
SCM_RIGHTS - Send or receive a set of
open file descriptors from another
process. The data portion contains an
integer array of the file descriptors.
The passed file descriptors behave as
though they have been created with
dup(2).
SCM_RIGHTS使用參考 know-your-scm_rights