Long processing inside Actor - mailbox full?


(Ali A) #1

I have a system which takes in a piece of input data, processes it (think a machine learning pipeline), then returns some output.

I’m thinking of putting this system in a separate module, and made accessible as an Akka actor. It will be run on its own node, with 100% of cpu / ram, etc.

It will have an akka actor which takes the input data, processes it (blocking), and sends back the result.

Then another module will run a http webserver which will take incoming reqs. Each req will result in input data being sent to the processing module, and when the output is received, it will be sent back. I’m thinking of using a non-blocking framework like vert.x for this.

My question is, will this architecture work? Since incoming reqs could be coming in faster than they get processed, could i run into a ‘mailbox full’ issue, and if so, is there a work around?

Thanks.


(Ali A) #2

Bump, anyone?


(Patrik Nordwall) #3

If you can’t slow down the incoming requests and you reach your buffering capacity your options are to either drop them or store them to some kind of durable queue for later processing (given that you have infinite disk space).

I would recommend looking at Akka Streams and use end-to-end backpressure. Toghether with Akka HTTP you can get backpressure all the way to the clients that generate the requests.


(Ali A) #4

Hey Patrik,

Ideally I’d like to store the messages in memory, given that they need to be handled and the response returned within the span of a single http request.

Is it possible to use Akka HTTP and streams to:

  • Wait on a response from a stream / actor while processing a http request
  • Add additional incoming messages into a queue so they get processed in a FIFO manner?

Thanks.


(Patrik Nordwall) #5

Yes, that is possible. Give the Akka HTTP Quickstart a try and you will learn some of the basic concepts such as how requests can be completed via CompletionStage.