Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Scala's Actor framework handle 10.000 actors without stack problems?

I want to do a multi-agent simulation containing about 10.000 agents (machine and product agents) using the Scala Actor framework.

As I understand, if there are lots of actors passing messages around, can it run out of stack due the recursion?

If so, how can I increase the stack sizes for the underlying worker threads?

like image 665
akarnokd Avatar asked Jun 23 '09 07:06

akarnokd


People also ask

When would you not use an Actor Model?

We've already covered some instances where the Actor Model isn't ideal. Such as when you need a sequential order of things to happen. If you find yourself sending multiple messages and then needing to rollback those processes if one fails, you might want to reconsider using the Actor Model.

What is actor based concurrency?

The fundamental idea of the actor model is to use actors as concurrent primitives that can act upon receiving messages in different ways: Send a finite number of messages to other actors. Spawn a finite number of new actors. Change its own internal behavior, taking effect when the next incoming message is handled.

What is framework actor Labview?

The Actor Framework is a software library that supports the writing of applications in which multiple VIs run independently while communicating with each other.

What is Scala actor?

The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems.


1 Answers

The actor framework has been designed to handle this - in fact, it can handle this with only one thread, assuming you use the loop-react pattern as follows:

import actors._
import actors.Actor._

val a = actor {
  loop {
    react {
      case ABC => //Handle here

    }
  }
}

On pp 590-593 of Programming in Scala this is discussed in more detail: basically the react method never returns normally (it terminates with an exception) and therefore its call stack does not need to be preserved. You can think of it as looping forever.

like image 135
oxbow_lakes Avatar answered Sep 20 '22 22:09

oxbow_lakes