-1

I have an API that limit 10 calls/second from an IP - Lets call this API-1

I have a webapp that consumes API-1. Lets call this WebApp-1

If I my Web App have more traffic and needs to make more calls per second than allowed, how do I design WebApp-1 call to API-1?

1 Answers1

1

Some ideas of how to approach a rate limited API that come to mind:

  • Raise the API limits for your client key. Probably not your case but may be an option in some cases.
  • Create/purchase more client accounts (access keys) to the API to raise the overall rate limit. Split traffic among the keys evenly.
  • Cache results on the querying side (WebApp in your case). It depends on the application, but if WebApp is a browser-based application caching may not be effective as there's no shared cache between clients.
  • Introduce caching proxy. WebApp makes requests to the proxy which forwards them to the rate limited API. This will help with maintaining the shared cache. Some options to implement the proxy: Nginx, Varnish, AWS API Gateway, etc.
  • Introduce a query queue (synchronous). Again if WebApp is a browser application, you may need to put a backend service as a proxy between the WebApp and the API. Proxy would keep a steady flow of requests to the API. If there's a burst in incoming requests it would delay processing to respect API's rate limit (WebApp may have to wait longer to get an answer from the proxy). Not really scalable.
  • Introduce a query queue (asynchronous). WebApp sends requests to the proxy. Proxy acknowledges the receipt and returns a receipt ID. Then either the proxy makes a callback request to the WebApp when response from the API is ready or WebApp is polling the proxy to know if there's any data for a given receipt ID.
  • Another (obviously shady) solution is making requests from different machines and IPs. Probably not something API owner wants to see!
Max Ivanov
  • 5,695
  • 38
  • 52