On Tue, Aug 19, 2014 at 4:51 AM, Fej <[email protected]> wrote: > I'm trying to learn akka and need a clarification how to design an > application. Lets imagine simple HTTP CRUD app, which handles some > documents stored in mongodb. For each of this operations I'd need at least > one actor processing request, fetching db record and formatting the output? > When do I create actors? Is the idea to create a new actor for each new > http request? Actors can be started, stopped, but when to do so in context > of this simple app? >
As so often in programming, there's no one-size-fits-all answer, and many ways this could be done. But yes, if I was going to do something this simple, I'd likely to do it with one Actor per request, possibly with different Actor classes for different request types. Basically, if you think of an Actor as your unit of concurrency / parallelism, you're often not too far off. As for when to start and stop them, that depends on how concerned you are with the fine details of efficiency. You *could* maintain a pool of Actors and assign them to requests, and save a few cycles that way, but I'd usually say that's overkill -- simply spinning up an Actor for each request as it comes in isn't horribly expensive, and lets you be very confident that each one is nice and clean when the request begins... -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
