Setting up a Microsoft Orleans cluster using AWS Fargate

As technology moves to the cloud setting up virtual machines for a cluster that is manually managed becomes an anti-pattern. This will persuade a lot of people to use a different technology due to operational or architectural guidelines.

Thankfully with AWS you can deploy services using Fargate and have those services host your Microsoft Orleans cluster. In your cluster you can have many silos which will contain your grains. The silos can be run on a single host or span multiple hosts using a data store to communicate cluster membership.

Choosing the right clustering

There are quite a few different types of datastores that are available depending on the needs of the deployment. These range from data stores that should only be used during development to well tested datastores that support very large clusters.

  • Orleans.Clustering.DynamoDB
  • Orleans.Clustering.AdoNet
  • Orleans.Clustering.Consul
  • Orleans.Clustering.AzureStorage
  • Orleans.Clustering.ZooKeeper
  • Orleans.Clustering.Redis
  • In-Memory (for development purposes)

Setting up Security Groups

Given that most implementations will use some form of clustering that spans multiple VMs this will require at least two ports to be allowed to communicate between the instances. The default ports for Microsoft Orleans are 11111 and 30000 these provide silo-to-silo communication and client-to-silo communication respectively.

Determining a persistence layer(s)

The persistence layer can be unique for each type of grain. Some grains do not get persisted at all and are only in memory as long as the grain is activated. Other grains can be persisted using providers or custom implementations.

Out of the box persistence providers

  • ADO.NET
    • SQL Server
    • MySQL or MariaDB
    • PostgreSQL
    • Oracle
  • DynamoDB
  • Azure storage

Implementing Microsoft Orleans on Fargate

The steps we want to accomplish in this example are to create the AWS infrastructure and the C# code. For the infrastructure we will create a security group, ecs cluster, task definition, fargate service. For the code we will create a simple Microsoft Orleans cluster that uses DynamoDB for cluster membership and persistence.

Setting up the AWS infrastructure

The first thing we want to do is to setup a security group for the cluster so that it can be used in the next step.

Creating the Microsoft Orleans cluster/silo

The first step in the code that we want to setup is in the StartUp. Here we will configure our services to use DynamoDB for its membership of the cluster and persistence for our grain.

Leave a Reply