Michal Paszkiewicz

review: Microservices in .NET Core

For a Domain Driven Design (DDD) practitioner, one of the main things that have to be considered when developing a new project or new features is how to split apart bounded contexts. A bounded context is a group of functionalities that can be developed independently from the rest of the project. If you have an e-shopping application and you are working on the users section of your program, you shouldn't be worried about potentially making breaking changes to the stock items section of the program. So it is a developer's duty to figure out how they can split their project into multiple sections that can be developed independently of each other.

When splitting apart bounded contexts, there is always the question of how far apart to split them technically. Should they be seperate aggregates? Should they be split into seperate projects? Should they be entirely seperate services?

Truly "micro" services are an architectural pattern that delegate the behaviour of a bounded context to a single service. Some DDD evangelists state that a microservice should be so small that you could bin it and rewrite it in a week. So, assuming that you are an excellent engineer who can split up bounded contexts, to work at this velocity with microservices, you will need to be confident with a toolset that will help you do the job efficiently. I would like to present you with Microservices in .NET Core - possible the best book I have read for learning how to work with microservices in .NET.

The book starts with an overview of what a microservice architecture looks like and what the advantages and disadvantages of using them are. Already in section 1.4 there is a very interesting study of how to differ the approach depending on whether you are writing an entirely new project, or potentially adding new features to a monolithic legacy project. The author really cuts to the chase and is already providing code examples as early as chapter 1.8, to show the minimum amount of work you need to have a microservice. Chapter 2 builds on this and teaches you to implement a simple shopping cart microservices, already with a retry policy. At this point, the reader may not have a full understanding yet of the concepts the book is presenting, but the author has definitely proved that creating a microservice can be very simple and that the libraries presented are effective.

Chapter 3 goes on to explain some more theory on how to identify and scope microservices, while Chapters 4 and 5 introduce patterns that can be used to integrate microservices together and methods of dividing data ownership between the microservices. Chapter 6 began with methods of dealing with failures and then moved on to implementing robustness patterns with Polly, such as a circuit breaker or a fast or slow-paced retry strategy. The second section of the book then finishes off with a fairly comprehensive section on how to test your microservices.

Following this, the author takes the reader through some more advanced topics, introducing OWIN middleware, monitoring, security and reusability via NuGet. The 4th and final part of the book involves an example-heavy chapter on how to create an application that may be using one or many microservices, and different approaches to structuring the architecture of such a project.

The two main libraries that this book is presenting are Nancy and Polly. I had already used Nancy before writing the book, but any retry logic was usually hand-written. Polly is a very simple but elegant solution and the book has covered all the main features I would expect from a retry library. I will definitely be using Polly in future projects.

I am very impressed with the way the author has managed to capture almost everything that a developer needs to know when moving into enterprise level software without the reader needing to break into a sweat. The book was very readable but didn't sacrifice any details that I expected to read about in a book on microservices. I hope I can persuade all my colleagues to read this book and with that hope, I award it:

*****

published: Fri May 05 2017

Michal Paszkiewicz's face
Michal Paszkiewicz reads books, solves equations and plays instruments whenever he isn't developing software for Transport For London. All views on this site are the author's views only and do not necessarily represent the views of TfL.