title: Handling (queuing) requests to a web service which calls rate limited external API
body: <p>I have a web service exposed using the Flask framework.</p>
  
  <p>This service uses as external API, which has a limitation on the number of times it should be called per second.</p>
  
  <p>In a normal scenario, multiple calls to my API leads to multiple threads getting generated and the external API getting called without any control on the number of requests per second.</p>
  
  <p>Is there a way in which I can queue requests to my web service and then call the external API in a throttled way.</p>
  
  <p>Any other ideas are also welcomed.</p>
  
  <hr>
  
  <p>Edit: </p>
  
  <ol>
  <li><p>I already know the rate to the external API ( 1 request per second)</p></li>
  <li><p>I am ok if the client requesting my API has to wait a little long (few seconds / minutes depending on the load I have) before they get the results.</p></li>
  <li><p>I don't want my API clients to get failed results. i.e. I don't want them to call again and again. If the external API is already being accessed by me at the max rate possible, the requests to my API should get queued and processed when the rate comes down.</p></li>
  <li><p>I read about <a href="http://flask.pocoo.org/docs/0.10/patterns/celery/" rel="noreferrer">Celery</a> and <a href="http://flask.pocoo.org/snippets/73/" rel="noreferrer">Redis</a>. Will I be able to queue the web service calls in to these queues and process them later ?</p></li>
  </ol>