Micro service

What are microservices and microservices architectures?

Here’s Martin Fowler, principal scientist at ThoughtWorks:

Currently, there is no specific definition of microservices. But generally speaking, the service architecture is an architectural pattern, or a kind of architectural style, it advocates the will of a single application is divided into a set of smaller services, each service is running in its own process of independence, mutual coordination between services, configuration, each other to provide ultimate value to the user, using lightweight communication mechanism between service (HTTP) communicate with each other, Each service is built around a specific business and can be independently deployed to the production environment. In addition, the unified and centralized service management mechanism should be avoided as far as possible. For a specific service, the appropriate language and tool (Maven) should be selected to build it according to the business context. There can be a very lightweight centralized administration to coordinate these services, services can be written in different languages, and different data stores can be used.

In my opinion:

Microservices are single services. For example, in a hospital, there are many departments: dentistry, brain, cardiology, etc. These departments are responsible for different conditions: dentistry is responsible for dental diseases, brain is responsible for brain diseases, and cardiology is responsible for heart diseases. These departments are different microservices; Hospitals act as registries to manage these microservices; Patients are consumers.

Further understanding:

Microservice emphasizes the size of service and focuses on a certain point, a service application that specifically solves a certain problem or provides corresponding services. In a narrow sense, it can be regarded as a microservice project in IDEA or a Moudel, a Moudel is a microservice.

The core of the micro service is the application of the “one-stop” work style of traditional, according to the business into a service, a coupling, thoroughly to each service function of a single business service, a service to do one thing, from a technical point of view is a small, independent processing, the concept of the similar process, can start alone or destroyed by oneself, have their own independent of the database.

Microservices infrastructure

Features of microservices

advantages

  • Single responsibility principle;
  • Each service is cohesive enough, small enough, and easy to understand to focus on a specific business function or requirement;
  • Development is simple, development efficiency is high, a service may be dedicated to do only one thing;
  • Microservices can be developed individually by small teams of 2-5 developers;
  • Microservices are loosely coupled, functional services that are independent in both development and deployment phases.
  • Microservices can be developed in different languages;
  • Easy integration with third parties, microservices allow easy and flexible integration of automatic deployment through continuous integration tools such as Jenkins, Hudson, Bamboo;
  • Microservices can be easily understood, modified, and maintained by a single developer, so that small teams can focus on their own work, without the need to collaborate to achieve value;
  • Microservices allow the use and integration of the latest technologies;
  • Microservices are just code for business logic, not mixed with HTML, CSS, or other interfaces;
  • Each microservice has its own storage capacity, which can be its own database or a unified database.

disadvantages

  • Developers deal with the complexity of distributed systems;
  • Multi-service operation and maintenance is difficult. With the increase of services, the pressure of operation and maintenance is also increasing.
  • System deployment dependency;
  • Communication cost between services;
  • Data consistency problem;
  • System integration testing problem;
  • Performance and monitoring issues;

Microservices technology stack

A picture:

A table:

One explanation: the microservices technology stack

Microservices Framework

SpringCloud

As a microservice development framework, Spring Cloud includes many components. In addition, Spring Boot provides a simplified Spring-based development environment for Spring Cloud, which can adapt to Spring Boot to quickly develop a single microservice.

Dubbo

Dubbo is an open source distributed service framework developed by Alibaba, which is committed to providing high-performance and transparent RPC remote service invocation solutions and SOA service governance solutions. Its core parts include:

  • Remote communication: Provides an abstract encapsulation of a variety of long-connection-based NIO frameworks, including multiple threading models, serialization, and request-response mode of information exchange.
  • Cluster fault tolerance: Provides transparent remote procedure calls based on interface methods, including multi-protocol support, and cluster support for soft load balancing, failure tolerance, address routing, and dynamic configuration.
  • Automatic discovery: Based on registry directory services, service consumers can dynamically find service providers, address transparency, and service providers can smoothly add or subtract machines.

Spring Cloud VS Dubbo

  • Service invocation dubbo is the RPC SpringCloud Rest Api
  • Registries, Dubbo is Zookeeper and SpringCloud is Eureka, which can also be ZooKeeper
  • Springcloud has Zuul routing gateway, which acts as a routing server for consumer request distribution. Springcloud supports circuit breakers, perfect integration with Git configuration files to support version control. The transaction bus implements a series of microservice architecture elements such as configuration file update and automatic service assembly.

An interesting analogy between Spring Cloud and Dubbo is that building a microservice architecture using Dubbo is like building a computer, with a lot of freedom of choice in each step, but the end result is likely to be broken because of a poor memory quality, but if you are an expert, this is fine. Spring Cloud is like a brand machine. Under the integration of Spring Source, a lot of compatibility tests have been done to ensure a higher stability of the machine. However, if you want to use accessories other than the original components, you need to know enough about the accessories.