API Gateway
資料來源
What is API gateway? @ ByteByteGo
API gateway 的功能
API gateway 位在 clients 和許多 backend services 的中間,它通常會提供的功能包括:
- authentication and security policy enforcements
- load balancing and circuit breaking
- protocol translation and service discovery
- monitoring, logging, analytics and billing
- caching
- error tacking and circuit-breaking
API Gateway 處理請求的流程
整個流程會像這樣:
- client 發送 request 到 API gateway
- API gateway 驗證 HTTP request(Parameter Validation)
- 透過 client 的 IP address 和 HTTP headers 與 allow-list / deny-list、rate limiter 比對後,決定要不要讓它存取服務
- 進行 authentication 和 authorization
- 這個步驟通常會需要向 Identify Provider 查詢此使用者的使用權限
- Rate Limit Check
- Dynamic Routing:決定要將該請求 route 到那個 service 處理
- Service Discovery:例如 Cart、Billing、User、Notification
- 將請求轉成適當的 protocol,並發送到對應的 service,例如透過 gRPC;同樣的,收到 service 處理好的資料時,也在這裡轉成 client 可以接受的 protocol