Summary of the book "Creating Microservices"

I don’t understand anything in microservice architecture, so I decided to read and outline Sam Newman’s book, Creating Microservices. In my opinion, it turned out to be a good introduction for people who are starting to dive into this topic.


Microservices


The idea of ​​microservice architecture is based on several concepts: subject-oriented design, continuous delivery, on-demand virtualization, infrastructure automation, small stand-alone teams, and scalable systems. Microservice is a small (can be completely rewritten in two weeks), autonomous service that performs only one task. At the same time, the boundaries of microservices are formed on the basis of business boundaries.


Advantages of the approach:


  • technological heterogeneity is possible;
  • elegant degradation is easily achieved;
  • individual parts of the system independently scale;
  • independent deployment of services;
  • simple sharing of responsibilities between teams.

It would seem that it is possible to replace the microservice architecture by simply putting the code into libraries. But this solves only a part of the problems - technical heterogeneity, simple scaling, independent deployment are impossible. Plus, the problem of uncontrolled connectivity remains.


In some languages ​​(for example, Erlang), individual parts of the program (modules) can be scaled and deployed independently. But this is rather an exception to the rule.


Microservices are not a silver bullet. They are subject to all the problems of distributed systems. It is important to learn how to deploy, test and monitor such a system in a quality manner. Microservice architecture is not suitable for all companies.


Development Architect


When developing a system consisting of many services, the role of the architect increases.


. . , , . — . , , , .


— , , .


:


  • ;
  • ;
  • .


( ) .


— , . , , .


. , . .


( DDD) — .


, , . . , , — .


« », -.


. : , , - . , -.



:


  • - ;
  • ();
  • .

-, , — . , . — . , — .


, «» , , . , - . . , .



, . . «-», .


— . . , ( ). ( ).


, — RPC REST. RPC — , , . REST — , ( REST-).


. - ( ATOM) . , , .



. : , — . -, .



.


— ( 1.5.3 2.0.0) . URI (, /v1/createUser/, /v2/createUser/), , HTTP, .


( 1.5.3 2.0.0), — , . , .



, . .


— . , , .


— API-, . , ( ).


— backend-for-frontend (BFF). (, ) API- .


, API-.



(, CMS CRM). . — , API.



. , , .


. — . , , . : ; .


, . — . . , (, , ).


. . :


  • ;
  • ;
  • , ;
  • ( Netflix).


. , (, ) . (-).


( , , ). . . .


, . , Chef, Puppet Ansible. — , . — , deb-. . , . — .


LXC- — . . Docker — , , Kubernetes.



- , , . , , -. E2e , .


- - — (), (). . — Mountebank.


(e2e) . CI, , . CDC ( ).


- . ( ).


. .


-, .


- : — . . -.


( - ) — . (, , - -). , . , . , .



.


-, , . , .


-, . , (, logstash) (, Kibana) .


( , ) -. , - .


: - .


. , .



. — , , . — , . . , .


, :


  1. . , - - . , — , .
  2. HTTP(S) Basic Auth. -, HTTPS, SSL-. -, ( Basic Auth).
  3. . , — , , .
  4. . , .
  5. - (HMAC). , , . ( JWT) . — , .
  6. API-. , , API-. , , .

. , .


. , IP- . .


. , .



«, , ­, »


, , , .




— , , - . , .


: , , . . , , .


— (graceful degradation).


— . , - .


— . , , , . , , - .


— , . , , ( ), . . «», , .


, .

— . . .



— . . .


— . . - , .


— , (), . . .


. , .



, -, :


  • , , ;
  • - , , , , ;
  • , , , .

, , .


HTTP . cache-control expires ETag . HTTP, , .


. , . , , - . , .


— . ( , , ) . , .


CAP


: , . .



The easiest way is to use DNS. If its capabilities are not enough, you can use things like Zookeeper, Consul or Eureka.


Documentation


API services need to be documented. It is highly desirable that the code and the documentation be connected and that it is impossible to change one thing. For example, you can take Swagger or HAL.


Summary


Microservice architecture is based on several principles:


  • modeling around business concepts;
  • culture of automation;
  • hidden details of internal implementation;
  • comprehensive decentralization;
  • independent deployment;
  • isolated failures;
  • comprehensive observation.

All Articles