~/codewithstu

Clustering Microsoft Orleans with DynamoDB

Transcript

Hello, my name is Stu. If you're new here, this channel is all about breaking down different technologies into easily digestible chunks. In this video, we're going to be taking a look at clustering Microsoft Orleans with DynamoDB.

To recap from previous videos, we've been using the localhost clustering system which is built in out of the box. We need to change this over to DynamoDB so that when we deploy it to the remote environment, our services can talk to each other and form a cluster.

So to get started with this, I'm going to right click on the project and click Manage NuGet Packages. Next, I'm going to search for "orleans dynamo" and I'm going to select Microsoft.Orleans.Clustering.DynamoDB. I'm going to install that package now.

Go back to my Program.cs and change UseLocalhostClustering to UseDynamoDBClustering. This takes a set of options that we can go and configure, and we need to configure the Service property. I'm just going to copy and paste that. This tells the clustering system to use the local DynamoDB instance that we have running on our machine.

Next, we need to configure two different options. The first is the endpoint options. So we're going to type `builder.

Configure` and pass in EndpointOptions. Don't worry if it doesn't exist straight away, because we can press Ctrl+. and select the Microsoft Orleans Configuration namespace. Then we can pass in the options.

On these options, we need to first configure the AdvertisedIPAddress. For this example, I'm just going to be using IPAddress, just make sure I bring in the namespace. I'm just going to use the loopback. Normally, this would come from a DNS name or a static IP address that you assign to each silo.

Next, we need to configure two more properties. The first is the GatewayListeningEndpoint and the second one is the SiloEndpoint. First, let's configure the GatewayListeningEndpoint by calling options.GatewayListeningEndpoint = new IPEndPoint and we are going to allow it to listen to any host IP address on the port. For the EndpointOptions, we're just going to listen to the default port for now.

Now we need to repeat the same process for the SiloListeningEndpoint, which we are going to configure in the exact same way, but this time we're going to use the default silo port.

Now this is done, we need to assign the cluster a name. To do this, we configure the ClusterOptions. On the options, we need to set the ClusterId equal to "my-first-cluster". This could be whatever name you want it to be. The ServiceId, it can be the same. I'm just going to call it "my-first-service".

All being well, we can now start our Hello Orleans service. We still have the same grain implementation as we have in our previous videos. So now I'm going to close this down, which will close the service down. Now we can check what Orleans has done to DynamoDB in the background using the Amazon NoSQL Workbench.

I'm going to go to my Operation Builder and I'm going to click Open on my LocalStack configuration that I had from last time. Now you can see that we have two different tables. We have the OrleansGrainState, which we configured in the previous video, and we have this new one called OrleansSilos. The OrleansSilos table tells us about the different running instances, which address and port they are running on, and whether or not that is active.

The next video in our series with Microsoft Orleans and DynamoDB, we're going to be taking a look at call filters to add some observability to our cluster.

If you enjoyed this video, consider subscribing to the YouTube channel for more content like this.

// share_this