title: What's a good way to enforce a single rate limit on multiple machines?
body: <p>I have a web service with a load balancer that maps requests to multiple machines. Each of these requests end up sending a http call to an external API, and for that reason I would like to rate limit the number of requests I send to the external API.</p>
  
  <p>My current design:</p>
  
  <ul>
  <li>Service has a queue in memory that stores all received requests</li>
  <li>I rate limit how often we can grab a request from the queue and process it.</li>
  </ul>
  
  <p>This doesn't work when I'm using multiple machines, because each machine has its own queue and  rate limiter. For example: when I set my rate limiter to 10,000 requests/day, and I use 10 machines, I will end up processing 100,000 requests/day at full load because each machine processes 10,000 requests/day. I would like to rate limit so that only 10,000 requests get processed/day, while still load balancing those 10,000 requests.</p>
  
  <p>I'm using Java and MYSQL.</p>