API Rate-Limiting
Sraban Pahadasingh April 14, 2020 06:17 PMImplementing API Rate-Limiting
-
Request Queues:
- Ex. ASQS(Amazon Simple Queue Service) is a readymade request queue library maintianed regularly.
- Some library take 2 request per second from the queue and remaining kept in the queue for processing.
- Many custom "request-rate-limiter" library are avaialbe in package manager
-
Throttling
- API is used by setting up a temporary state, allowing the API to assess each request. When the throttle is triggered, a user may either be disconnected or simply have their bandwidth reduced.
- Possible at the application, API, or user level, throttling is a popular method to rate-limit APIs
- Rate-limiting Algorithms
- "Leaky Bucket" is a algorithim which translate requests into FIFO format and processing the items on the queue on a regular rate.
- "Sliding Log" is time stampped algorithim, the sum of the logs are calculated to determine the request rate. if the request exceeds the limit threshold, they are simply queued.