Gökhan GÖKALP
30.05.2017
Trendyol Tech Talk
Everything's message-focused and one actor is no actor.
Orleans is a framework that provides a straightforward approach to building distributed high-scale computing applications.
Orleans is to simplify distributed computing and allow non-experts to write efficient, scalable and reliable distributed services.
Design Grain Interface
Grains interact with each other by invoking methods declared as part of the respective grain interfaces.
public interface IMyGrain : IGrainWithStringKey
{
Task<string> SayHello(string name);
}
Implement Grain Interface
public class MyGrain : IMyGrain
{
public Task<string> SayHello(string name)
{
return Task.FromResult($"Hello {name}");
}
}
Grain Method Invocation
var grain = GrainClient.GrainFactory.GetGrain<IMyGrain>("grain1");
await grain.SayHello("World");
Create a proxy object, and calling the methods:
Grain Persistance
[StorageProvider(ProviderName="store1")]
public class MyGrain<MyGrainState> ...
{
...
}
<StorageProviders>
<Provider Type="Orleans.Storage.MemoryStorage" Name="DevStore" />
<Provider Type="Orleans.Storage.AzureTableStorage" Name="store1"
DataConnectionString="DefaultEndpointsProtocol=https;AccountName=data1;AccountKey=SOMETHING1" />
<Provider Type="Orleans.Storage.AzureBlobStorage" Name="store2"
DataConnectionString="DefaultEndpointsProtocol=https;AccountName=data2;AccountKey=SOMETHING2" />
</StorageProviders>
Some Grain Features
Stateless Worker Grain
Can be scaled out automatically at runtime.
Immutable Messages
For better serialization performance.
Reentrant Grain
In Orleans, concurrent processing can be provided with the “[Reentrant]” attribute.
Observer Grain
Can observe events
Using X-Large VMs (8 CPU Cores / 14 GB RAM) on Microsoft Azure, with one silo per VM: