Joh*_*etz 7 rest load-balancing http request
我有以下基本架构:
由于我不想深入的原因,我希望允许客户端从任一服务器获取数据(如果他们选择的话)。如果他们不关心,那么负载均衡器将为他们做出决定。
是否有设计 API 请求的最佳实践?
我想出了几个选择:
example.com?server=1
Run Code Online (Sandbox Code Playgroud)
example.com -H "Server-ID: 1"
Run Code Online (Sandbox Code Playgroud)
我最终通过 HTTP 标头实现了这一点:
GET example.com # server 1 or 2 (load balancer decides)
GET example.com -H "Server-ID: 1" # routes to server 1
GET example.com -H "Server-ID: 2" # routes to server 2
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
153 次 |
| 最近记录: |