Some notes on Microservices

Hello everybody,

today I want to write a few words about microservices and why they

become so popular in our days. 

First of all, take a look at the following picture,

it shows how monlitic service look like:

At this picture we have following elements: customer, which uses web site.

Web site in turn has two parts: UI for customers and for company support.

And inside of the web site quite often you will see interconnections between

Accounts, orders, promotions, discounts, inventory, products and so on.

And on separate computer as usually lives database.

Now imagine that you need to modify part related to promotions. What will happen in case of upgrade? You'll need not just use promotions, but also most probably modification of promotions will affect other services. Another question mark: imagine that you'll get a lot of customers searching for some particular product, and you'd like somehow to add performance to Products BL. Will you be able to achieve this functionality? Unfortunately not. First of all you'll need to add perfromance to whole web site, to all modules, not just to single part of it. 

Take a look at microservices architecture:

As you can see, for end customer situation looks absolutely the same. He navigates to the web site, but internally we have different services running with their own storages. If for some reason a lot of peopel will become interested in some kind of promotion, then all what will be needed, just increase power of promotions service computer. And in case of bug, it will be easier to modify single service instead of modificaiton of all services.

What are the main features of microservice? In other words what makes microservice a microservice? As usually common features are considered as key features:

  1. High cohesion
  2. Autonomous
  3. Business Doman Centric
  4. Resilience
  5. Observable
  6. Automation

High cohesion

High cohesion basically is almost the same as Single responsibility principle, but in scale of service. Just instead of word class put word service. 

Autonomous

Autonomosity means that changes inside of the services can be independent from other services that use it. That is achived over usage of interfaces. Also it is good idea to make service stateless, otherwise you can't scale it easily.

Business Doman Centric

This statment declares that microservice should represent some business unit function. For example delivery, or Account management.

Resilence

In other words that principle means stability of microservice in case if other microservices fail. As usually it is achieved via some kind of defaulting or degrading functionality and of course with multiple instances of microservice.

Observable

This part is pretty self explanatory. If you have 10 services, and one of them crashes, you need a way to know it. Also you need to have a way to monitor condition of your microservices, how loaded they are, maybe you need to add more instances and so on. So while develop microservices consider adding logging features. 

Automation

That feature says that we need to automate everything that is possible to automate: deployment, regression testing, environment setup, etc. Without automation microservice becomes something, that is really hard to manage.

No Comments

Add a Comment