[英]Request prioritization when an API is down
Imagine an API with an endpoint called /valuableData.想象一个带有名为 /valueableData 的端点的 API。 The server clearly states that the limits for the API are 500 requests/s in total and 20 requests/s per person.服务器明确指出 API 的限制是总共 500 个请求/秒和每人 20 个请求/秒。 This server does not check your IP so I could make 500 request/s with 500 good working proxies without the API going offline.该服务器不会检查您的 IP,因此我可以使用 500 个正常工作的代理发出 500 个请求/秒,而 API 不会脱机。 Now imagine that person A sends 1000 requests/s and person B sends 20 requests/s which causes the 500 limit to be hit and the API goes offline.现在假设 A 发送 1000 个请求/秒,B 发送 20 个请求/秒,这会导致达到 500 个限制并且 API 离线。 As soon as the API comes back online, how many valid answers does person A get back per second and how many person B? API 重新上线后,A 每秒返回多少个有效答案,B 返回多少个有效答案? How does the server/API handle this?服务器/API 如何处理这个问题? Does person A get back 480 valid answers per second and person B 20?人 A 每秒能得到 480 个有效答案,而人 B 每秒能得到 20 个有效答案吗? Or does person A get all the max of 500 answers/s?或者 A 是否能得到最多 500 个答案/秒?
This depends on the protocol.这取决于协议。
HTTP which normally is used for REST is in itself stateless and client-initiated and therefore falls short of the requirements.通常用于 REST 的 HTTP 本身是无状态的和客户端启动的,因此不符合要求。
Your scenario would require a protocol which:您的方案需要一个协议,该协议:
I imagine such a protocol exists or could be implemented using WebSocket and storing state in a database.我想这样的协议存在或可以使用WebSocket实现并将状态存储在数据库中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.