關于我們
書單推薦
新書推薦
|
萬億級流量轉(zhuǎn)發(fā):BFE核心技術(shù)與實現(xiàn) 讀者對象:本書面向的讀者包括計算機網(wǎng)絡方向的研究者、網(wǎng)絡相關技術(shù)的開發(fā)者、一般后臺程序的開發(fā)者和負載均衡系統(tǒng)的使用者等。
本書圍繞BFE 開源項目,介紹網(wǎng)絡前端接入和網(wǎng)絡負載均衡的相關技術(shù)原理,說明BFE開源軟件的設計思想和實現(xiàn)機制,講解如何基于BFE開源軟件搭建網(wǎng)絡接入平臺。本書共17 章,分為四個部分。第一部分為原理篇,介紹BFE 開源項目的概貌,并對網(wǎng)絡前端接入技術(shù)和網(wǎng)絡負載均衡技術(shù)做簡要介紹;第二部分為設計篇,介紹BFE 開源項目的設計細節(jié),包括BFE 的設計思想、BFE 的轉(zhuǎn)發(fā)模型、BFE 的關鍵機制和HTTPS 的優(yōu)化等;第三部分為操作篇,說明如何安裝和部署B(yǎng)FE、如何在各種使用場景下配置BFE;第四部分為實現(xiàn)篇,從處理流程、插件機制、協(xié)議實現(xiàn)等方面說明BFE的實現(xiàn)機制。
章淼,百度智能云智能負載均衡架構(gòu)師、百度代碼規(guī)范委員會主席(兼)
原 理 篇
第1 章 BFE 簡介·····························································································3 1.1 什么是BFE·························································································3 1.2 BFE平臺介紹·····················································································4 1.2.1 為什么需要構(gòu)建BFE 平臺·····················································4 1.2.2 BFE平臺的主要功能·····························································6 1.3 BFE開源項目介紹·············································································7 1.3.1 BFE平臺的模塊組成·····························································7 1.3.2 BFE開源項目中的內(nèi)容··························································9 第2 章 網(wǎng)絡前端接入技術(shù)簡介·····································································10 2.1 什么是網(wǎng)絡前端接入········································································10 2.2 網(wǎng)絡前端接入面臨的挑戰(zhàn)································································11 2.3 百度的網(wǎng)絡前端接入方案································································13 2.4 網(wǎng)絡前端接入技術(shù)的發(fā)展趨勢························································15 第3 章 網(wǎng)絡負載均衡技術(shù)簡介·····································································24 3.1 負載均衡的概念···············································································24 3.2 網(wǎng)絡負載均衡功能的實現(xiàn)································································25 深入理解BFE ·VI· 3.2.1 機制說明···············································································25 3.2.2 兩種方式對比········································································27 3.3 四層負載均衡和七層負載均衡························································28 設 計 篇 第4 章 BFE 的設計思想················································································33 4.1 BFE轉(zhuǎn)發(fā)引擎重構(gòu)的緣起································································33 4.2 BFE為什么要基于Go 語言·····························································34 4.3 BFE轉(zhuǎn)發(fā)引擎的主要設計思想························································37 4.4 BFE和相關開源項目的對比····························································38 第5 章 BFE 的轉(zhuǎn)發(fā)模型················································································42 5.1 轉(zhuǎn)發(fā)模型概述···················································································42 5.1.1 基本概念···············································································42 5.1.2 轉(zhuǎn)發(fā)過程···············································································43 5.1.3 對多租戶實現(xiàn)機制的討論····················································46 5.2 BFE的路由轉(zhuǎn)發(fā)機制·······································································47 5.3 條件表達式·······················································································49 5.3.1 設計思想···············································································49 5.3.2 基本概念···············································································50 5.3.3 語法介紹···············································································51 5.3.4 條件原語匹配的內(nèi)容····························································52 5.3.5 條件原語名稱的規(guī)范····························································54 5.4 內(nèi)網(wǎng)流量調(diào)度機制············································································55 5.4.1 內(nèi)網(wǎng)流量調(diào)度背景介紹························································55 5.4.2 內(nèi)網(wǎng)流量調(diào)度工作機制························································60 目 錄 ·VII· 5.4.3 內(nèi)網(wǎng)轉(zhuǎn)發(fā)的其他機制····························································65 第6 章 與轉(zhuǎn)發(fā)相關的關鍵機制·····································································68 6.1 健康檢查機制···················································································68 6.1.1 健康檢查的原理····································································69 6.1.2 主動健康檢查和被動健康檢查············································69 6.1.3 分布式健康檢查和集中式健康檢查····································73 6.1.4 BFE的健康檢查···································································77 6.2 超時設置···························································································77 6.2.1 BFE和客戶端間通信的超時················································78 6.2.2 BFE和后端實例間通信的超時············································81 6.3 BFE信息透傳···················································································84 6.3.1 客戶端IP地址的透傳··························································84 6.3.2 其他信息的透傳····································································85 6.4 限流機制···························································································89 6.4.1 限流的概念···········································································89 6.4.2 限流的配置···········································································91 6.4.3 分布式限流···········································································91 6.4.4 入口限流和目的限流····························································94 6.4.5 限流和內(nèi)網(wǎng)流量調(diào)度····························································95 第7 章 運維相關機制····················································································97 7.1 監(jiān)控機制···························································································97 7.1.1 日志監(jiān)控及其問題································································98 7.1.2 BFE的內(nèi)部狀態(tài)輸出···························································99 7.1.3 統(tǒng)計狀態(tài)和日志的配合使用··············································101 深入理解BFE ·VIII· 7.2 Web Monitor基礎庫·······································································101 7.2.1 Web Monitor概述·······························································102 7.2.2 狀態(tài)變量維護······································································102 7.2.3 延遲統(tǒng)計變量維護······························································104 7.2.4 建立專用的Web服務器·····················································106 7.2.5 注冊回調(diào)函數(shù)······································································107 7.3 日志機制·························································································108 7.3.1 日志類型·············································································108 7.3.2 日志打印的注意事項··························································109 7.3.3 BFE的訪問日志·································································110 7.4 配置管理························································································.111 7.4.1 BFE配置文件的分布·························································.111 7.4.2 常規(guī)配置和動態(tài)配置··························································112 7.4.3 動態(tài)配置的實現(xiàn)機制··························································113 第8 章 HTTPS 的優(yōu)化················································································116 8.1 HTTPS優(yōu)化背景及必要性·····························································116 8.2 HTTPS優(yōu)化的挑戰(zhàn)········································································117 8.3 HTTPS中的優(yōu)化機制·····································································118 8.4 BFE中HTTPS 相關增強機制························································120 操 作 篇 第9 章 BFE 服務的安裝部署······································································129 9.1 軟件安裝包下載安裝······································································129 9.2 源代碼編譯方式安裝······································································132 9.3 Docker方式安裝·············································································133 目 錄 ·IX· 9.4 BFE命令行參數(shù)·············································································134 9.5 查看BFE 服務的運行狀態(tài)·····························································135 第10 章 BFE 服務的基礎配置····································································136 10.1 場景說明·······················································································136 10.2 修改基礎配置文件········································································137 10.3 轉(zhuǎn)發(fā)的配置···················································································138 10.3.1 轉(zhuǎn)發(fā)配置流程····································································138 10.3.2 具體案例···········································································139 10.3.3 服務訪問驗證····································································146 10.3.4 配置的重新加載································································146 第11 章 配置負載均衡算法及會話保持·····················································147 11.1 子集群間的負載均衡····································································147 11.2 子集群級別的會話保持································································149 11.2.1 配置實例···········································································149 11.2.2 參數(shù)的具體含義································································150 11.3 實例間的負載均衡········································································151 11.3.1 加權(quán)輪詢配置示例····························································151 11.3.2 最小連接數(shù)的配置示例····················································153 11.4 實例級別的會話保持····································································154 第12 章 配置HTTPS 和更多協(xié)議·····························································155 12.1 設置HTTPS 基礎配置··································································155 12.1.1 配置HTTPS 端口·····························································156 12.1.2 配置加密套件····································································156 12.1.3 配置服務端證書································································156 深入理解BFE ·X· 12.1.4 配置TLS 規(guī)則···································································157 12.2 配置TLS 會話重用·······································································158 12.2.1 配置會話緩存····································································159 12.2.2 配置會話票證····································································160 12.3 配置TLS 雙向認證·······································································161 12.4 對不同安全等級的區(qū)分································································163 12.5 支持更多協(xié)議···············································································164 12.5.1 HTTP/2配置·····································································165 12.5.2 SPDY 配置········································································166 12.5.3 WebSocket配置·································································167 12.5.4 連接后端服務的協(xié)議························································169 第13 章 其他常用配置················································································171 13.1 配置重寫·······················································································171 13.1.1 開啟重寫···········································································171 13.1.2 模塊配置···········································································171 13.1.3 重寫動作詳細描述····························································173 13.2 配置重定向···················································································177 13.2.1 開啟重定向········································································177 13.2.2 模塊配置···········································································177 13.2.3 重定向動作詳細描述························································178 13.3 配置限流功能···············································································180 13.3.1 開啟限流模塊····································································180 13.3.2 模塊配置···········································································181 13.3.3 限制特定維度的流量························································182 13.3.4 設置限流門限····································································183 13.3.5 設置限流動作····································································184 目 錄 ·XI· 實 現(xiàn) 篇 第14 章 其他常用配置················································································187 14.1 BFE的代碼組織···········································································187 14.2 BFE的進程模型···········································································190 14.2.1 協(xié)程的分類·······································································190 14.2.2 并發(fā)模型···········································································191 14.2.3 并發(fā)能力···········································································192 14.2.4 異;謴蜋C制····································································192 14.3 請求處理流程···············································································193 14.3.1 連接的建立·······································································193 14.3.2 連接的處理·······································································194 14.3.3 請求的處理·······································································196 14.3.4 請求的結(jié)束·······································································198 14.3.5 連接的結(jié)束·······································································199 14.4 請求路由實現(xiàn)···············································································199 14.4.1 關鍵數(shù)據(jù)結(jié)構(gòu)····································································200 14.4.2 目的租戶路由····································································203 14.4.3 目的集群路由····································································204 14.5 負載均衡實現(xiàn)···············································································206 14.5.1 全局負載均衡····································································207 14.5.2 分布式負載均衡································································210 第15 章 模塊插件機制················································································214 15.1 BFE的回調(diào)點設置·······································································214 15.2 BFE內(nèi)置的擴展模塊···································································216 15.3 模塊框架的實現(xiàn)機制····································································217 深入理解BFE ·XII· 15.3.1 模塊基礎類型····································································217 15.3.2 連接/請求處理及回調(diào)函數(shù)的調(diào)用···································223 15.4 如何開發(fā)BFE擴展模塊·······························································224 15.4.1 配置加載···········································································225 15.4.2 回調(diào)函數(shù)的編寫和注冊····················································226 15.4.3 模塊狀態(tài)的展示································································228 第16 章 核心協(xié)議實現(xiàn)················································································231 16.1 HTTP的實現(xiàn)················································································231 16.1.1 HTTP 代碼的組織·····························································231 16.1.2 從用戶讀取HTTP 請求····················································233 16.1.3 向后端轉(zhuǎn)發(fā)請求并獲取響應············································236 16.1.4 向用戶回復HTTP 響應····················································239 16.2 HTTP2的實現(xiàn)··············································································240 16.2.1 HTTP2 代碼的組織···························································240 16.2.2 HTTP2 連接處理模塊·······················································241 16.2.3 HTTP2 連接相關協(xié)程及關系···········································243 第17 章 BFE 的多進程GC 機制································································249 17.1 模型設計·······················································································249 17.1.1 多進程輪轉(zhuǎn)機制································································250 17.1.2 子進程狀態(tài)定義································································252 17.2 相關參數(shù)的確定············································································253 17.2.1 切換時間參數(shù)的選擇························································253 17.2.2 子進程數(shù)量的計算····························································255 17.2.3 內(nèi)存消耗的計算································································256
你還可能感興趣
我要評論
|