Microservices architecture has become increasingly popular over the past few years due to its scalability, flexibility, and the ability to deploy individual services independently. However, this architecture has its own set of challenges, including high development overhead, the need for extensive infrastructure management, and complex deployment pipelines.

Orleans.Multiservice is a solution to these challenges, providing a modular monolith approach to microservices. It is an automated code structuring pattern that separates logical services within a Microsoft Orleans 7 (micro)service. Developed to avoid significant development overhead and friction common in microservices applications, this pattern allows development teams to postpone the development of microservices until it is actually needed, while also avoiding rewrites.

It is not uncommon to find single development teams that maintain multiple microservices, ignoring Conway’s Law. Conway’s Law states that the structure of a software system reflects the communication structure of the organization that developed it. Orleans.Multiservice suggests that a single team that has a single deployment rhythm usually deploys their services together anyway, so they could use a single service containing a modular monolith instead. This approach helps to avoid the pain of managing too many microservices before they are needed (if ever), and also avoids the pain of rewrite when the time has come to move part of the application into a separate microservice.

Microsoft Orleans is a framework that allows building distributed applications using grains, which have grain contracts, i.e., C# interfaces. These grains can be considered a kind of ‘nano services’. By grouping grains and their contracts into logical services within an Orleans (micro)service, teams can avoid and postpone the development friction that microservice separation brings until the moment that physical separation is actually needed.

Orleans.Multiservice consists of an example application that demonstrates the pattern in two stages of the application’s life cycle, a dotnet new mcs-orleans-multiservice template to set up a new multiservice, and a Roslyn code analyzer and/or unit tests to ensure that the pattern is preserved during development. The code analyzer/unit tests are not yet available, but the multiservice pattern can be used today by following the code structure of the template and the pattern rules.

Using the Orleans.Multiservice template is straightforward; it only takes 2 commands on the CLI.

The example in the repository illustrates how logical services within a microservice have very low development friction, and how little code needs to be changed when moving logical services to a separate microservice.

This is the code structure before and after the move:

Example Vs Solutions Single Team And Two Teams

With the modular monolith approach to microservices, Orleans.Multiservice leverages Microsoft Orleans 7 and Conway’s Law to make life better for developers building distributed (microservices) applications.

About the Author
Vincent Hoogendoorn is a Microsoft MVP Developer Technologies with over 20 years of experience as hands-on .NET innovator / architect / engineer. He is currently focused on full stack C#: Microsoft Orleans backends and browser/native frontends with C# Markup 2 for Windows App SDK, Uno Platform and Xamarin/Maui. Xamarin cross-platform mobile veteran, passionate about developer productivity. Principal Software Engineer at InnoWvate.NET, Technical Director at Applicita.

Leave a Reply


captcha *