微服務遵循前提:數據庫
- 業務獨立性:推薦書籍 Eric Evans《領域驅動模型》
- 團隊自主性:
特色
- 單一職責:推薦書籍 Robert C.Martin《敏捷軟件開發:原則、模式和實現》
- 輕量級通訊:語言無關、平臺無關的交互方式
![](http://static.javashuo.com/static/loading.gif)
- 獨立性:交付過程當中,開發(功能)、測試、部署的獨立性;服務與服務的獨立、隔離;
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
背景
![](http://static.javashuo.com/static/loading.gif)
互聯網時代的產品特色:網絡
價值觀、方法論=》可遵循、可參考、可實施的交付體系架構
- 精益創業Lean Startup=》最小可實行產品Minimum Viable Product
- 敏捷方法
- 持續交付
- 雲、虛擬化、基礎設施自動化Infrastructure as Code:
- DevOps文化的推行
容器虛擬化技術
Docker的優點 》一個節點運行成百上千的Docker容器 》解決微服務的環境搭建、部署、運維成本高的問題運維
- 更快速的交付、部署:鏡像
- 更輕鬆的遷移、擴展:能夠在任意平臺遷移(物理機、虛擬機、公有云、私有云……)
- 更簡單的管理:鏡像修改以增量方式分發、更新
SOA面向服務架構 vs 微服務
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
微服務的本質:
- 服務做爲組件Component:組件能夠被獨立部署
- 定義了清晰的、語言無關、平臺無關的接口
- 分佈式調用比進程調用更消耗時間
- 嚴重依賴網絡的可靠性、穩定性
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- 業務數據獨立
- 業務數據接口繼承,而非以數據庫的方式同其餘服務繼承
- 隨業務發張,選擇更合適的工具管理、遷移業務數據
![](http://static.javashuo.com/static/loading.gif)
- 基礎設施自動化
- 部署、運維的成本隨服務的增多呈指數級增加
- 雲技術、持續繼承、持續交付
- 演進式架構
微服務的優點
實施須要考慮的因素:異步
- 分佈式系統的複雜度
- 分佈式系統的複雜度
- 性能:網絡延遲、帶寬;多服務相互協做時,響應時間、性能
- 可靠性:網絡、帶寬、節點自身的可靠性=》組件間遠程調用;單點故障
- 異步:異步通訊的定位問題、調試問題難度更大
- 數據一致性:跨多個節點來保證數據的瞬時一致性||數據的最終一致性
- 工具:開發、調試工具沒有足夠支持
運維成本:每一個服務獨立配置、部署、監控、日誌收集=》成本呈指數級增加
- 部署自動化:構建自動化部署流水線
- DevOps與組織架構
- 服務間依賴測試
- 服務間依賴管理