Re: [akka-user] Akka Cluster without Remoting?

2016-03-19 Thread Endre Varga
Hi Curt,

On Fri, Mar 18, 2016 at 5:35 AM, Curt Siffert  wrote:

> Hi, I'm supporting a pre-existing Akka project that is currently set up to
> run 1 Master instance and N Worker instances.
>
> It does not use routing/remoting.
>

What do you mean by not using routing? How does that relate to remoting? I
sense some confusion here.


> We start them in 'Master' or 'Worker' modes via startup flags - each
> instance has its own actor system, and the only information they
> communicate to each other is through Redis Pubsub.  Each of them does
> accept API requests so they are all behind a load balancer.
>
> The Master actor system and the Worker actor system are slightly
> different, in that Master polls some information and publishes to Redis,
> while Worker subscribes to Redis so they all have the same information to
> serve to the API requests.
>
> Now we have a desire to start up N instances without using the startup
> flags, and have the instances just figure out for themselves which is
> Master - and if it goes down, another would be master, etc. We don't want
> more than one Master, since only one should poll the external information.
> We don't need to send application messages across nodes since we'd keep
> Redis.
>
> Looking at the Akka Cluster tutorials, I'm seeing a couple of options on
> how to do this:
>
> 1) Just use leader election, and listen for LeaderChanged messages to make
> Leader always be Master (stopping the Worker actor system and starting the
> Master actor system if necessary). But this seems against the spirit of
> keeping leader election decoupled from application functionality. Plus, in
> experimenting, I'm seeing nodes switch Leader more often than I'd like
> Master to switch (like if I take node #1 down and then bring it back up -
> node #1 seems to end up Leader again even if node #2 was Leader for that
> intervening time).
>

The internal leader election is not to be used for these tasks. It is
rather special, you should use ClusterSingleton.



> 2) Use ClusterSingleton - but if I did this, what would be the way for the
> Worker nodes to realize it is not the Master Singleton and start up the
> different Worker actor system?
>

The cluster singleton can be at a known path in each of the systems. You
can dedicate one actor that pings this path on the local system
periodically (every 1-2 sec) and if it sees that there is a singleton there
it starts up the worker subsystem, and when it no longer sees a singleton
there (because it was migrated) then it starts up the worker subsystem
again.

With no routing/remoting, Master would not be sending messages to them.
>

Clustering works on top of remoting. I sense a confusion here, again.


>
> It seems like this is a bit against the spirit of using Akka Cluster which
> seems to assume routing. Is there a better way?
>
> Thanks,
> Curt
>
> --
> >> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka Cluster without Remoting?

2016-03-19 Thread Curt Siffert
Hi, I'm supporting a pre-existing Akka project that is currently set up to 
run 1 Master instance and N Worker instances.

It does not use routing/remoting. We start them in 'Master' or 'Worker' 
modes via startup flags - each instance has its own actor system, and the 
only information they communicate to each other is through Redis Pubsub. 
 Each of them does accept API requests so they are all behind a load 
balancer.

The Master actor system and the Worker actor system are slightly different, 
in that Master polls some information and publishes to Redis, while Worker 
subscribes to Redis so they all have the same information to serve to the 
API requests.

Now we have a desire to start up N instances without using the startup 
flags, and have the instances just figure out for themselves which is 
Master - and if it goes down, another would be master, etc. We don't want 
more than one Master, since only one should poll the external information. 
We don't need to send application messages across nodes since we'd keep 
Redis.

Looking at the Akka Cluster tutorials, I'm seeing a couple of options on 
how to do this:

1) Just use leader election, and listen for LeaderChanged messages to make 
Leader always be Master (stopping the Worker actor system and starting the 
Master actor system if necessary). But this seems against the spirit of 
keeping leader election decoupled from application functionality. Plus, in 
experimenting, I'm seeing nodes switch Leader more often than I'd like 
Master to switch (like if I take node #1 down and then bring it back up - 
node #1 seems to end up Leader again even if node #2 was Leader for that 
intervening time).

2) Use ClusterSingleton - but if I did this, what would be the way for the 
Worker nodes to realize it is not the Master Singleton and start up the 
different Worker actor system? With no routing/remoting, Master would not 
be sending messages to them.

It seems like this is a bit against the spirit of using Akka Cluster which 
seems to assume routing. Is there a better way?

Thanks,
Curt

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.