Hi,

On Tue, Oct 21, 2014 at 5:38 PM, 汤雪华 <[email protected]> wrote:

> I have a question about actor when it is in the cluster environment.
> Suppose we have four machines in the cluster now. And each machine have
> many alive actors.
> But now, we added a new machine into the cluster, so some message will be
> handled on the new machine. And the target actor which handle the messages
> will be created first on that machine. But you know this actor is already
> exist and alive on the original machine. In this case, we know that the
> actor has two instances at that time. The original actor may has some
> messages have not been processed yet, and the new created actor will start
> to process the new received messages.
>
> So i think that this will cause the concurrent problem. After viewed some
> ppts, i know that the original actor will receive a notification that there
> is a new instance of the current actor instance is created on another
> machine,
>

I don't know where you got that. Perhaps some old presentation describing
ideas that were never implemented. There is no automatic notification for
new actor instances. You are responsible for starting the actors on the
cluster nodes in the way that makes sense for your application.


> then any left messages of the current should not be processed again, all
> the left message should be send to the new actor instance. This can solve
> the concurrent problem i talked above.
>

This is a very hard problem to solve, if you have to preserve the original
message order. We had some ideas about this in the early days of Akka
Cluster <http://doc.akka.io/docs/akka/2.0.5/cluster/cluster.html#Handoff>,
but that was abandoned and never implemented. It is too complicated and can
be solved in other ways.


>
> I think, one actor can only exist on one machine when in the cluster
> environment. If this point can be ensure, then we can asynchronously
> persist the event which is generate by the actor. Because "the latest state
> of actor is in memory", and the storage just like relational db or nsoql db
> is only used to persist the event, these events are used to recover the
> actor when it crashes. The reason why we can asynchronously persist event
> is that the concurrent problem is controlled by the in-memory actor(any
> actor only has a single thread to process all the mailbox message).
>

Using akka-persistence is a great way to migrate actor state in a
cluster. Cluster
Sharding <http://doc.akka.io/docs/akka/2.3.6/contrib/cluster-sharding.html>
is useful for this.


>
> But the thing is not good as we expect:
>
> 1) When the new actor created successfully, it can immediately process
> incoming messages, but the notification to the original actor may take many
> seconds. that means, in these seconds, the original actor may still
> processing its mailbox message itself. So that the concurrent problem will
> still exist;
> 2) Due to some network problems, the original actor cannot know there is a
> new actor is created. In this case, it will also caused the concurrent
> problem.
>
> So, how do you think about this issue?
>

Messages can be lost, and you have to deal with it anyway. Cluster Sharding
helps you with stateful actors in a cluster.

Regards,
Patrik

>  --
> >>>>>>>>>> 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.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      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.

Reply via email to