简体   繁体   中英

Request prioritization when an API is down

Imagine an API with an endpoint called /valuableData. The server clearly states that the limits for the API are 500 requests/s in total and 20 requests/s per person. This server does not check your IP so I could make 500 request/s with 500 good working proxies without the API going offline. 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. As soon as the API comes back online, how many valid answers does person A get back per second and how many person B? How does the server/API handle this? Does person A get back 480 valid answers per second and person B 20? Or does person A get all the max of 500 answers/s?

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.

Your scenario would require a protocol which:

  1. Knows who the clients are/were
  2. Can push responses after coming online again without client involvement
  3. Can prioritize responses to client requests

I imagine such a protocol exists or could be implemented using WebSocket and storing state in a database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM