title: What is the cost of creating actors in Akka?
body: <p>Consider a scenario in which I am implementing a system that processes incoming tasks using Akka. I have a primary actor that receives tasks and dispatches them to some worker actors that process the tasks.</p>
  
  <p>My first instinct is to implement this by having the dispatcher create an actor for each incoming task. After the worker actor processes the task it is stopped.</p>
  
  <p>This seems to be the cleanest solution for me since it adheres to the principle of "one task, one actor". The other solution would be to reuse actors - but this involves the extra-complexity of cleanup and some pool management.</p>
  
  <p>I know that actors in Akka are cheap. But I am wondering if there is an inherent cost associated with repeated creation and deletion of actors. Is there any hidden cost associated with the data structures Akka uses for the bookkeeping of actors ?</p>
  
  <p>The load should be of the order of tens or hundreds of tasks per second - think of it as a production webserver that creates one actor per request.</p>
  
  <p>Of course, the right answer lies in the profiling and fine tuning of the system based on the type of the incoming load.
  But I wondered if anyone could tell me something from their own experience ?</p>
  
  <p><strong>LATER EDIT:</strong></p>
  
  <p>I should given more details about the task at hand:</p>
  
  <ul>
  <li>Only N active tasks can run at some point. As @drexin pointed out - this would be easily solvable using routers. However, the execution of tasks isn't a simple run and be done type of thing.</li>
  <li>Tasks may require information from other actors or services and thus may have to wait and become asleep. By doing so they release an execution slot. The slot can be taken by another waiting actor which now has the opportunity to run. You could make an analogy with the way processes are scheduled on one CPU.</li>
  <li>Each worker actor needs to keep some state regarding the execution of the task.</li>
  </ul>
  
  <p><em><strong>Note:</em></strong> I appreciate alternative solutions to my problem, and I will certainly take them into consideration. However, I would also like an answer to the main question regarding the intensive creation and deletion of actors in Akka.</p>