dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.07k stars 2.03k forks source link

Grain activation #4600

Closed srinathgnath closed 6 years ago

srinathgnath commented 6 years ago

Hello, Few queries on grain activation:

1) Lets assume we have an application deployed in a cluster of three silos. Client connected to a silo and have grain activation with it. And now if that silo goes down for some reason, does orleans framework create entirely new grain activation in other silo? Will grain have new primary key? 2) I have been experimenting explict stream subscription with RabbitMQ.

And my application looke likes this:
**SILOHOST** 

        1.  CommandBusGrain     
                         1.  OnactivateAsync creates a stream (stream id: GUID.Empty)
                         2.  Register method does subscription to the stream
                         3.  Send method publish message to stream (that is _stream.OnNextAsync(msg))
        2.  On silo startup
                         1.  calls CommandBusGrain register method to initiate subscription

**SILO Client**

        1.  Create CommandBusGrain reference (Graind id: GUID.Empty)
        2.  Triggers "Send" method to publish message.

 This works fine, but I need some suggestion on whether to call grain method to publish message to 
 the stream or create stream reference in the client and publish message directly to stream instead of 
 calling grain.
 Which one would be a better implementation?
sergeybykov commented 6 years ago

Sorry about delayed response.

if that silo goes down for some reason, does orleans framework create entirely new grain activation in other silo? Will grain have new primary key?

Yes, after the cluster learns that the silo went down, a new request to the grain will trigger a new activation of it on one of the remaining silos. The primary keys will stay the same - it's the key that the request was sent for.

  1. OnactivateAsync creates a stream

What is this exactly. Streams are virtual, just like grains. They always exist, and don't need to be created.

This works fine, but I need some suggestion on whether to call grain method to publish message to the stream or create stream reference in the client and publish message directly to stream instead of calling grain.

Publishing directly from client is more efficient - the message will get written directly to the queue. No need to send it to the grain to be written to the queue from there I think.

srinathgnath commented 6 years ago

Thanks