6

I am working on a pricing platform on wich I have to implement a distributed rate limiting algorithm. I have k gateways that provide x services. Any gateway can provide any service (via a load balancer). A customer buy a number of call per second to a service, its call could be routed through any gateway. So, is somebody knowing a good algorithm to update call counters on all gateways in order to limit customer calls?

Two important indicators, regarding this algorithm, are the network overhead and the deviation between the number of accepted calls and the rate limit.

Thanks!

Edit I just want to know if there is a "well-known" algorithm.

mhvelplund
  • 2,099
  • 3
  • 22
  • 38
Lambdacrash
  • 201
  • 2
  • 10
  • 1
    what algorithms have you tried that the answer wasn't within your bounds? – Woot4Moo Nov 16 '12 at 20:47
  • 1
    I am studying the problem, I did not implement any algorithm for the moment because I don't know existing algorithm. We can easily imagine a naive algorithm that sends its counter after each call to inform other gateways that it received a call and then decrease all other counters but if the rate limit is around 10 000 calls per second, the network overhead is terrible. Another case could be the reate limit < the number of gateway and then imply counter broadcast after any call. – Lambdacrash Nov 16 '12 at 20:53
  • If you know distributed rate limiting algorithms, give me their names :p – Lambdacrash Nov 16 '12 at 20:58
  • 1
    You have put no effort into your research. Do not expect others to care about something that you yourself are not passionate about. – Woot4Moo Nov 16 '12 at 21:01
  • Okay, I don't know exactly why you are answering my question in this way but I can give you numerous research articles dealing with this topic (http://goo.gl/L5tqf, http://goo.gl/wnGjw, http://goo.gl/PUA4r, etc.). My problem is nobody cares about network overhead. I just asked this question because I wanted to know if somebody had ever consider my metrics or if somebody had an experience return regarding my problem. And thanks for your link but I know Google and I know how to use it ;-) – Lambdacrash Nov 16 '12 at 21:11
  • @Lambdacrash: why do you say that "nobody cares about network overhead?" The Raghavan et al paper shows the result of a simulation, included in the abstract even, which estimates overhead at 3%. It might not be state-of-the-art (but, then, state-of-the-art in this sort of problem is probably not publicly available), but the outline is surely the best approach: a token bucket algorithm with a gossip protocol to distribute global information. – rici Nov 17 '12 at 00:57
  • @rici Thanks for your comment, I will study the approach you have proposed. – Lambdacrash Nov 17 '12 at 12:37

1 Answers1

4

I've implemented a solution based on this article (archive.org). I think the algorithm is called Leaky Bucket but it works fine. It's not perfect since it allows the entire quota to be used in a burst, but overall it's very fast with node.js and Redis. The difference between accepted requests and rate can be quite high and depend on the ratio between sample window and bucket size.

Community
  • 1
  • 1
mhvelplund
  • 2,099
  • 3
  • 22
  • 38