Posts

Showing posts with the label Microsoft Orleans

Custom Minio Grain Storage for Microsoft Orleans

Image
Custom Minio Grain Storage for Microsoft Orleans Grains states in Orleans are stored in a grain storage. Orleans ships with multiple highly available storage implementation like Azure blob storage or AWS Dynamodb. Today we will see how we can implement our own grain storage which will store grains on Minio , an open source free private cloud storage. Implement a simple blob storage abstraction and implementation with Minio Implement grain storage interface Register the grain storage 1. Implement a simple blob storage abstraction and implementation with Minio internal interface IMinioStorage { Task<bool> ContainerExits(string blobContainer); Task CreateContainerAsync(string blobContainer); Task<Stream> ReadBlob(string blobContainer, string blobName, string blobPrefix = null); Task UploadBlob(string blobContainer, string blobName, Stream blob, string blobPrefix = null, string contentType = null); Task DeleteBlob(string blobContainer, string blobNam...

Microsoft Project Orleans ClientBuilder and SiloBuilder

Microsoft Project Orleans ClientBuilder and SiloBuilder Prior 2.0.0 stable, we used to configure client and silo using ClientConfiguration and ClusterConfiguration . I was hard to understand how to configure those as many options were available. Moving forward to 2.0.0 stable, ClientConfiguration and ClusterConfiguration no longer exist! It has now been replaced by a ClientBuilder and a SiloBuilder (notice there is no cluster builder). The shift toward builders makes life easier to us to configure client and silo. Today I want to take the time to explain how the migration between beta 3 and stable can be done in three parts: Configure ClientBuilder Configure SiloBuilder 1. Configure the ClientBuilder A client needs to connect to a cluster. The only configuration needed for the client is therefore: the id of the cluster the id of the service where to find the cluster During beta this used to be configured in ClientConfiguration , it is now done using the ClientBuilder :...

Microsoft Orleans logs warnings and errors

Microsoft Orleans logs warnings and errors Microsoft Orleans is a framework which helps building distributed system by implementing the actor model together with the concept of virtual actors, taking care of availability and concurrency. If you are unfamiliar with Microsoft Orleans, you can look at my previous blog post explaining the benefits of Microsoft Orleans . Even though Orleans promises to abstract the distributed system problems, there are instances where errors arise without us being able to understand what is going on. Lucky us, the logs are well documented… but only for those who can decrypt them. Today I will go through some of the errors and warnings which can be seen from silo and client so that you too can undestand what is going on. Enjoy! The code used to produce those errors can be found on my GitHub https://github.com/Kimserey/orleans-cluster-consul . 1. Client logs Logs on client appears with address {ip}:0 . 1.1. Can’t find implementation of interface An un...

Silo configuration and Cluster management in Microsoft Orleans

Silo configuration and Cluster management in Microsoft Orleans Few weeks ago we saw how to create a Silo and how to implement grains. We also saw how we could create an ASP NET Core web app to talk to the Silo. We discovered the benefits of the single threaded model in grains. Today we will see one of the other major feature of Orleans, cluster management. This post will be composed by 3 parts: 1. Build a silo 2. Form a cluster with multiple silos 3. Cluster management with membership All the source code can be found on my GitHub. https://github.com/Kimserey/orleans-sample 1. Build a silo Let’s start first by implementing a Silo. We will be using the example we used in the past post. public class Program { public static void Main(string[] args) { var silo = new SiloHost("main"); silo.InitializeOrleansSilo(); var success = silo.StartOrleansSilo(); if (!success) { throw new Exception("Failed to start silo...

Microsoft Orleans Grains Concurrency Handling

Microsoft Orleans Grains Concurrency Handling Few weeks ago I explained the benefits of using Microsoft Orleans . One of them was the implementation of the actor pattern. Today I will dig deeper into it by revisiting a common scenario present in today systems and how it can be solved with Orleans grains. This post will be composed by 3 parts: 1 - Traditional system 2 - The problems 3 - Grain solution 1. Traditional system In a traditional system, we can often see a N-tier architecture (usually 3-tier) composed by the following: Front end -> Service tier -> Database The front end being the webserver like ASP NET. The service tier being a set of stateless services containing business logic. They ensure the consistency of the system by extracting the latest state of business object from the database, validate business rules and write back to database ~ the last tier. In this sort of architecture, the database is the source of truth. This can be illustrated with the following...

Create a simple Microsoft Orleans application

Create a simple Microsoft Orleans application Last week I presented an overview of Microsoft Orleans . Gave an explanation on the concepts and keywords which can be found in the framework. Today I will explain how we can implement a simple Orleans application with a cluster composed by a localhost Silo and with a client within an ASP Net Core Mvc application. This post will be composed by 3 parts: 1. Implement the grains 2. Create the silo 3. ASP Net Core Mvc client 1. Implement the grains The grains are the unit of work in an Orleans application. They contain the business logic and ensure that the state is consistent. In our example we will be implementing a Bank account grain with a withdraw and deposit functionality. There will be a single business rule being that the balance of any account cannot be lower than 0. We start first by creating the grain interface in a project where we reference Orleans.Core . public interface IBankAccount: IGrainWithStringKey { Task Deposi...

A first look at Microsoft Orleans

A first look at Microsoft Orleans Microsoft Orleans is a framework used to build scalable distributed systems. It reduces the complexity of distributed system by abstracting away concurrency issues together with state management. Processes can then be run on multiple instances and form a cluster, they can be hosted on different environment and be scaled up and down on demand. Today I will give a broad overview of the concepts utilized and developed by the team behind Orleans. This post will be compose by 3 parts: 1. Motivations 2. Definitions 3. How does it work? 1. Motivations The two main benefits of Orleans is that it: reduces the complexity of coding applications by providing a simpler model to maintain object oriented codebase. Orleans moves away from the N-tier type of architecture where business logic is held in stateless services and state is persisted in database by providing its own implementation of the actor pattern where the actor is a stateful unit of work where co...