Question

Can Akka provide web request throttling for a distributed application (Java/JEE)?

My application consumes a number of web services each of which allows a maximum number of concurrent requests. I've looked at

  • TimerBasedThrottle - suitable for single node application, but not possible to manage the number or requests sent in distributed setting.
  • Balancing dispatcher - shares a single mailbox between Actors sending messages to idle Actors, but it does not enforce a limit per second/minute, etc.

What is the best way to achieve this with Akka?

Was it helpful?

Solution

If you want to control and limit the number of certain actions performed by a distributed system, then your distributed nodes will have to communicate to make that happen. The easiest is to have one central actor which keeps track of all requests made to a certain target web service and handing out tickets allowing them to happen (delaying or dropping requests when going over the configured limit). If you do not want to incur the overhead of inter-node communication, then you will have to partition your quota such as to guarantee that by throttling all nodes individually their sum cannot exceed the limit, but this is obviously wasteful unless the request originators are perfectly balanced.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top