Hi Khoa, it is great that you find Akka exciting. Let me help you with your questions.
On Fri, Oct 3, 2014 at 10:07 PM, Khoa Nguyen <[email protected]> wrote: > I am supposed to design and implement a distributed solution for a client. > I look at Akka and the Actor's model and immediately fall in love :-) But > can this love last? > > Here is the brief description of the application, say MyApp: > > MyApp reads and immediately acks requests from HTTPS client(s): HTTP POST > --> 201 created. > Each request has a unique tracsaction ID and contains multiple sub-requests > MyApp extracts sub-requests from a request > MyApp posts each sub-request on a JMS queue for external backend system > External system consumes and processes each sub-request and post > sub-response on another JMS queue or topic > MyApp consumes sub-responses and correlates them by transaction ID into a > single response > Send the response back to client > > MyApp is going to be deployed on 4 or more nodes to support geo-redundancy. > > I am thinking of Akka cluster and trying to come up with a design but > still have difficulties: > > 1) Request*Reader*Actor: read and ack requests > Question: client should be able to connect to any node. Do I need 4 of > this, one per node, or a clustered actor is ok, or there's a better way? > It is always hard to answer such questions directly. Client will have to use Akka Cluster Client <http://doc.akka.io/docs/akka/2.3.6/contrib/cluster-client.html> to send messages to the cluster. There you can use Cluster Sharding <http://doc.akka.io/docs/akka/2.3.6/contrib/cluster-sharding.html> to distribute request handling actors throughout the cluster. 2) RequestReaderActor on receiving a request message: > > 2a) Sends the request to Request*Handler*Actor: split the request > into multiple sub-requests and put them on JMS queue > Question: Should I instead make RequestReaderActor a router to spawn a set > of RequestHandlerActors to handle potentially large load? > Moving from simple ActorRef to router is just a configuration change. So you can start small and then change to Cluster Router <http://doc.akka.io/docs/akka/2.3.6/scala/cluster-usage.html#Cluster_Aware_Routers> if your benchmarks say that you need to. 2b) Creates a ResponseAggregatorActor to wait with timeout and > correlate sub-responses from external system > > 3) SubResponseReaderActor: a JMS client to consume sub-responses from > external system > Question: similar to 1), do I need 4 of this, one per node? > Question: on receiving sub-response, how do I tell this actor to > forward the sub-response to the matching (by request ID) > ResponseAggregatorActor? > If there is no actor handling a particular request ID, you can just create one with request ID in its name and then use ActorSelection to send sub-responses there. > 4) What is the cost of creating actors on the fly? In general, when should > I prefer dynamic actors vs pre-created ones? > Actor creation is very cheap. When in doubt - create a new actor, which should only do one thing, and do it well. > Thanks in advance for your comments, which certainly guide me to a better > design. > > Khoa > > -- > >>>>>>>>>> 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. > -- Martynas Mickevičius Typesafe <http://typesafe.com/> – Reactive <http://www.reactivemanifesto.org/> Apps on the JVM -- >>>>>>>>>> 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.
