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