Skip to content

MicroService Components & Integration

Wim van Gool edited this page Jul 19, 2019 · 2 revisions

Introduction

The last fews years, the MicroService-Oriented Architecture has become very popular among business application developers. However, it seems that, although there is a lot of overlap in how people design and build these services, there are still a lot of flavors and variations floating around. This causes system that effectively apply the same reference architecture to being build slightly differently from project to project. To a certain extent this is understandable, since each project has its own requirements and challenges, but what I am often most surprised about is how certain basic principles and patterns are being applied differently. Shouldn't we all agree to at least a common set of design, test & implementation guidelines?

Apart from the fun of it, this has been my main driver for implementing the Kingo framework: not just to put yet another framework out there, but to package it with specific principals, patterns and design guidelines, and to align the Kingo framework with these principals, so that no matter what type of system or application you are going to build, you can always pick the same basic approach, both in development process and in implementation. This is, of course, not to say that I have invented the best or the only true way of implementing systems, but what I have tried to do is convert all my knowledge and experience with building Service-Oriented Systems into a set of consistent guidelines that have worked out pretty well for me and may hopefully help you build great systems as well.

In this introduction series, we will first look at how MicroServices are designed, how they behave and how they interact with each other through messaging patterns. On this page, we will introduce the main components of a MicroService and explain how MicroServices are connected and integrated with each other. On the next page, we will zoom in on a MicroService as a logical processing unit: what type of messages are exchanged between services, and how are they processed? On the third page, we shift our focus to the internal architecture of a MicroService and discuss how messages are processed internally. We will end this series with a short overview of all common messaging patterns between services.

Main Components of a Service

As discussed earlier, each MicroService is a single, logical processing unit that interacts with other services by exchanging messages over a network. To integrate with each other, each service defines its own contract. These contracts basically describe the functionality a service has to offer in the form of messages and interfaces and may also contain components that allow other services to connect to the service (e.g. by providing configurable proxies that can be used to connect to endpoints of a service). In addition, contracts are public components, which means that they are a meant to be shared for other services to reference.

The actual implementation of a service, which is the part where all processing logic is implemented, is decoupled from the contract. The implementation of a service is a private component, which means that other services are not allowed to reference the implementation directly; i.e., other services may be run-time dependent on the features of another service, but never compile-time dependent on its implementation.

This design allows developers to make and deploy updates to the implementation of a service without needing to make modifications to other services or components, which is the type of service autonomy that is required in a modern, distributed services architecture. In UML, this design would look as follows:

Service Components - Contract & Implementation

Services may reference each other's contracts, but not each other's implementations

Another problem solved by this design is that it prevents circular dependencies between services. More often than not, two or more services are interdependent, meaning that the implementations of these services depend on each other's contracts to compile and rely on each other's features to function properly. If we were to allow services to reference each other's implementations, we would quickly find ourselves with circular references and unable to compile as a result.

Together, the contract and implementation of a service are commonly referred to as the back-end of a service. In addition to the back-end, however, a service may also contain some front-end components, which we will refer to as clients. Clients come in two flavors: standalone clients and shared clients. A standalone client is a user interface that is self-hosted and/or bootable, like a fully functional website or native WPF application. A shared client is a user interface component that is meant to be included in another standalone client, such as a WPF component.

Since standalone clients are never shared nor referenced by other services, these types of clients are private components. As such, standalone clients are allowed, but not necessarily required, to reference the implementation of its own service directly. This can be beneficial, especially for native applications, to run and host the application in a single process instead of having to host the implementation/back-end in a separate process. Shared clients, on the other hand, are public components, because other services may include them in their clients. As such, shared clients are only allowed to reference the contract of its own service back-end:

Service Components - Clients

Clients come in two flavors: standalone (public) and shared (private). The public components may be referenced by other services directly; private components are invisible to other services.

Versioning

Because service implementations evolve constantly over time and are interdependent, each service is versioned. This basically means that all the components of a service are assigned a specific version number. A common approach is to use semantic versioning, where the specific parts of a version number have a specific significance, so that consumers/clients of your service can determine whether or not newer versions of your service (contract) contain breaking changes, for example.

How to version a service exactly is beyond the scope of this chapter, but for now it's useful to know that applying NuGet's semantic versioning model works quite well to version (the components of) a service. The final picture of a MicroService and its components now looks as follows:

Service Components - Version Number

Each service has its own version number, which is used to communicate updates to the public components of a service.

Next up: description of the contract and behavior of a service.

Clone this wiki locally