BoCloud博雲:ESB老舊力不能支,微服務獨立自治強勢替代

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"在微服務化建設中,應該考慮到 ESB ,也必須考慮到 ESB 。","attrs":{}},{"type":"text","text":"那麼同樣是面向服務的架構, ESB 與微服務相比差別在哪兒?微服務化的建設應該如何安置 ESB ?在新型架構終將取代腐化傳統架構的背景下,如何遷移、替代,保證業務的可用性?接下來的內容裏,將給大家做一個詳細的分析。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"SOA與ESB","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"技術架構的發展有其規律可循,從單體到垂直拆分、再到面向服務、最後到分佈式微服務,從技術架構上來看是化整爲零的,從服務管理角度來看是從單一的管理到集中式的管理。在服務化以後,也就是提出面向服務的架構以後,除了微服務以外,SOA 和 ESB 也是大家熟知的架構:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"SOA架構:其實是一種設計理念,沒有架構和技術的依賴,只是多個服務以獨立的形式部署運行,服務間通過網絡調用,最終提供一系列完整的功能。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/87/8709b62c255445c3bc48366a6e39d012.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"ESB:企業服務總線,用來連接各個服務節點,服務間通信都通過 ESB 做路由和轉發。最主要的是,不同應用可能有不同的協議和報文,ESB 最大的功能是解決不同的服務間互聯互通。","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"所以,ESB 其實也算是 SOA 的一種實現形式","attrs":{}},{"type":"text","text":"。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/24/24848ed91acfb645dd2f6ba638f5d762.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"微服務的特點","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"看着上面 SOA 的描述,是不是感覺跟微服務架構也差不多?或者說微服務是 SOA 的昇華。那麼微服務與 SOA、ESB 有什麼不同呢?","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們先來看看微服務優勢介紹:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"1、 獨立、專注、自治","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以獨立的部署、獨立的運行,使用單獨的數據庫,甚至使用單獨的前端。這樣可以將故障影響面降低,不會出現牽一髮動全身的事情。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"專注於自身的業務,比如報表服務,只關注於報表,也就能聚焦於報表業務,不需要考慮監控、告警和日誌,只需要輸入數據,生成報表。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"研發團隊自治,可以拉起一個三五人的小團隊,只做報表相關功能和業務,效率高、專業程度高、產生質量和價值高。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"2、 分佈式,高可用,擴縮容,資源分配","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"微服務框架,支持分佈式的部署和運行方式,解決了服務的高可用問題。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過註冊中心的服務發現,實現服務的動態擴縮容,可根據業務併發量,自動調整橫向的擴縮容量。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"根據不同的業務模塊,調整服務的資源配比。例如在財務系統中,用戶管理模塊(用戶增刪改)使用頻率較低,可以部署一個資源少、單副本的用戶服務;但是賬務模塊使用極其頻繁,每天達到上百單,可能分配一個資源多、多副本的賬務服務。但是如果非微服務架構的話,就需要做系統的整體擴容,以滿足最大業務量的模塊,會造成其他模塊的資源浪費。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"3、 服務解耦、服務化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"拆分了微服務以後,服務間的依賴都會通過網絡傳輸的方式提供。也就是說一個服務只需要提供所需的功能接口,就可以滿足整體的業務實現。因此,微服務使用什麼編程語言,如何實現業務邏輯都可以不用考慮,只需要提供該有的功能接口(只關注於結果)。這樣服務在開發、管理、使用的時候,可以實現真正的解耦,不會受到開發框架、開發模式的制約。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"微服務化以後,服務的業務能力,不只是該系統可以使用,其他有需要的部門或者系統也可以通過接口調用該微服務,提供給其業務處理能力。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ESB對比微服務","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1、 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"獨立而不自由。","attrs":{}},{"type":"text","text":"相對於微服務,SOA架構可以獨立部署業務服務,但是不夠自由,不能像微服務那樣自由互通,只能通過 ESB 做服務通信,所有服務通信都需要 ESB 轉發,在 ESB 處集中管理,配置權限、配置策略。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2、 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"非分佈式解決方案","attrs":{}},{"type":"text","text":",服務的高可用無法通過框架整體解決,只能通過傳統方式解決。所以,更無法實現橫向動態的擴縮容。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3、 ESB 儘管也是面向服務的框架,但是卻無法真正的實現服務化。","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"服務化,應該是自消費的模式","attrs":{}},{"type":"text","text":",微服務的服務能力提供以後,使用者可以實現訂閱使用。但是 ESB 中,服務能力提供出來只是給特定場景的某幾個服務使用,其他服務如果想使用,需要通過定製化的增加。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4、 與自消費的道理相同,服務提供者不能實現自動化的服務提供,ESB中需要增加對應的接口以便於服務提供相應的業務能力。所以在ESB建設中,","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"會提前制定好需要暴露的指定接口","attrs":{}},{"type":"text","text":",如果有新增的需求,需要針對性的定製化。而微服務提供的則是一個微服務平臺,只要遵循特定的協議,無論是服務的提供還是使用,都可以自由的上下線和增減。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5、 微服務架構是新型的服務化架構,而 ESB 架構很容易腐化,且維護困難,技術核心非開源,受廠商綁定。微服務基本上都是基於開源的新型的技術,","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"不存在腐化,且可以自主掌握核心技術","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"6、 ESB 是集中化的服務管理模式,","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ESB 的性能將決定集團整體的通信性能","attrs":{}},{"type":"text","text":",且由於過於“集中”導致一旦總線出現問題,整個集團的信息化系統將面臨“癱瘓”的風險。而微服務則不同,微服務採用去中心化方案,","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"任何一個組件出現問題都不會影響全局的業務","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ESB終將被替代","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"業務持續增長,所以需要技術不斷革新,促進技術框架也不斷進步。一切變化的源頭都在業務的變化,業務消費量成幾何倍增長,所以要求服務可以自由的擴縮容;新型業務的不斷增加,要求服務支持動態的運營和管理。而 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ESB 的架構過於死板,已經完全不適合雲原生理念下的服務治理","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"老舊的系統架構逐漸力不能支,新型的微服務架構應運而生","attrs":{}},{"type":"text","text":",在這個趨勢的指引下,我們開始做微服務化的建設,但是在微服務化建設期間 ESB 如何安置,是一個比較大的問題。企業中多數系統的互聯互通都依賴於 ESB 的服務總線,但同時改造所有 ESB 接入的系統,工程量會很巨大,容錯率會很低,危險性也極高。因此 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"ESB 的替代儘管勢在必行,卻也需要慎重的規劃","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通常 ESB 的改造需要採用逐步改造加逐步遷移的方式,根據不同的系統現狀,做相應的方式處理:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"接受深度改造的系統","attrs":{}},{"type":"text","text":",通過拆分改造成微服務系統,那麼之前的調用方式可以直接修改成微服務的調用方式,這部分在我們的微服務化建設當中,需根據實際情況做好相應的建設規劃;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"支持輕度改造的系統","attrs":{}},{"type":"text","text":",不做微服務化拆分,但是可以改造調用或訪問的方式和地址。這部分系統可以將調用地址直接換成 API 網關的地址,通過 API 網關提供原 ESB 的如協議轉換、路由轉發、認證控制等功能,替換掉 ESB 的代理;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"完全不接受改造的系統","attrs":{}},{"type":"text","text":",或者對 ESB 依賴極強的系統,在做深度改造之前,ESB 不能被取代,那麼仍需要保留 ESB 。但是需要考慮新改造的,或者增量的微服務系統,與 ESB、與老舊系統之間的通信,因此需要對運行中的 ESB 做兼容和納管。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"在微服務建設的初期,ESB 因在企業中起到的關鍵作用,並不能完全替換或取代,因此需要有個過渡期","attrs":{}},{"type":"text","text":":通過微服務管理臺,兼容納管 ESB 的服務;通過API 網關轉換報文,路由轉發 ESB 的接口,以保證存量的系統與增量或改造的系統兼容管理、互聯互通。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其實 ESB 的功能,路由、轉發,與 API 網關的功能極其相似。接下來,我們將會重點分析 API 網關在微服務中的作用與 ESB 的區別和優劣,敬請期待。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章