10 微服務架構學習與思考:微服務網關和開源 API 網關01-以 Nginx 為基礎的 API 網關詳細介紹( 三 )


10 微服務架構學習與思考:微服務網關和開源 API 網關01-以 Nginx 為基礎的 API 網關詳細介紹

文章插圖
?(from:https://apisix.apache.org/zh/docs/apisix/getting-started/)
從圖上可以看出 , APISIX 底層基座也是基于 Nginx 和 OpenResty 。運行在基座之上的是 APISIX 軟件 。
  • 底層技術基座:Nginx 和 OpenResty
  • APISIX軟件:看上面架構圖,
    第一部分:APISIX Core,apisix 核心,包括 Lua 插件、多語言插件運行時(Plugin Runner)、Wasm 插件運行時等
    第二部分:各種內置插件 , 包括可觀測性、安全、流量控制等插件 。
APISIX 多語言插件運行時提供多種開發語言的支持,比如 Golang、Java、Python、JS 等 。
技術架構圖:
從另外一個角度來看看apisix架構,分為數據面和控制面:
10 微服務架構學習與思考:微服務網關和開源 API 網關01-以 Nginx 為基礎的 API 網關詳細介紹

文章插圖
?(from:https://github.com/apache/apisix)
  • apisix 使用 etcd 作為配置中心來進行數據信息保存和同步配置 。
特性功能可以到 github 上看它的 Features,列舉了很多功能特性 。
  • 擴展能力-插件功能
a)apisix 內置了很多插件,可以看文檔 Plugins 。
b)它也有一個插件市場,plugin hub 。
c)當然你也可以自定義插件 。這些看起來與 kong 開源版本擁有擴展功能差不多 。
  • 高可用集群
  1. Apache APISIX 的數據平面是無狀態的,可以進行隨意的彈性伸縮,前面加一層負載均衡即可
  2. Apache APISIX 的控制平面是依賴于 etcd cluster 的高可用實現的,不需要任何關系型數據庫的依賴
與 kong 區別:
這第二點與 Kong 集群有區別 , Kong 集群依賴的是 Postgre 和 Cassandra 。
Web UI通過RESTful API 來管理 apisix,通過 Admin API 來管理 apisix 節點 。通過 Control API 控制單個 apisix 數據平面行為 。
官方還提供了一個 Dashboard,通過 UI 管理 apisix 。
與 kong 區別:
kong 開源版本沒有這個 Dashboard 功能,企業版本有 。
3.1.4 Orange 網關這個 orange 也是一 OpenResty 為基礎開發的網關 , 
orange 官網: orange 地址
github 地址:orange github
orange 的功能相對于前面的 kong 和 apisix,比較少 。所以它的架構肯定比他們簡單,可以作為學習之用 。
如果你不需要那么多功能,可以試用下這款 API 網關 。
四、API 網關缺點
  1. 讓系統復雜度變高
在整個系統架構中,多一個了 API 網關,就多了一份維護工作,多了一處發生“危險”的地方 。
  1. API 網關可能成為性能瓶頸
因為所有的流量都要經過 API 網關,可以通過擴展集群來解決 。前面在加一組負載均衡設備等方法 。
五、參考
  • https://openresty.org/openresty 官網
  • https://github.com/openresty openresty github
  • https://github.com/openresty/lua-nginx-module lua 模塊
  • https://openresty.com.cn/cn/edge/ openresty edge 企業級產品
  • https://github.com/openresty/lua-nginx-module#nginx-api-for-lua nginx api for lua
  • https://konghq.com/ kong 官網
  • https://github.com/kong/kongkong github
  • https://docs.konghq.com/gateway/3.0.x/ Kong 3.0.x 文檔
  • https://docs.konghq.com/gateway/3.0.x/plugin-development/kong 插件文檔
  • https://docs.konghq.com/gateway/3.0.x/production/clustering/ Kong 3.0.x 的集群文檔
  • https://docs.konghq.com/hub/kong 插件 hub
  • https://github.com/Kong/kong-plugin 插件模板
  • https://github.com/pantsel/kongakong web ui
  • https://apisix.apache.org/zh/docs/apisix/getting-started/ apisix 文檔
  • https://apisix.apache.org/zh/docs/apisix/plugins/batch-requests 內置插件
  • https://apisix.apache.org/zh/plugins/插件市場
  • https://apisix.apache.org/zh/docs/apisix/control-api/
  • http://orange.sumory.com/docs/orange 地址

推薦閱讀