The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Are Akka actors overkill for doing data crunching?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Paul Vause

Posts: 1
Nickname: elsigma
Registered: Apr, 2019

Are Akka actors overkill for doing data crunching? Posted: Apr 25, 2019 10:26 AM
Reply to this message Reply
Advertisement
I'm quite new to Scala as well as Akka actors. I'm really only reading about their use and implementation now. My background is largely js and python with a bit of C#.

A new service I have to write is going to receive REST requests, then do the following:

Open a socket connection to a message broker Query an external REST service once Make many big, long REST requests to another internal service, do math on the responses, and send the result out. Messages are sent through the socket connection as progress updates. Scalability is the primary concern here, as we may normally receive ~10 small requests per minute, but at unknown times receive several jaw-droppingly enormous and long running requests at once.

Using Scala Futures, the very basic implementation would be something like this:

val smallResponse = smallHttpRequest(args)

smallResponse.onComplete match {
case Success(result) => {
result.data.grouped(10000).toList.forEach(subList => {
val bigResponse = getBigSlowHttpRequest(subList)
bigResponse.onSuccess {
case crunchableStuff => crunchAndDeliver(crunchableStuff)
}
})
}
case Failure(error) => handleError(error)
}


My understanding is that on a machine with many cores, letting the JVM handle all the threading underneath the above futures would allow for them all to run in parallel.

This could definitely be written using Akka actors, but I don't know what, if any, benefits I would realize in doing so. Would it be overkill to turn the above into an actor based process with a bunch of workers taking chunks of crunching?

Topic: Really good book.  It would be even more useful with 'official' source code Previous Topic   Next Topic Topic: Is Scala more complicated than Java?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use