SpringCloud (1) -Microservice

SpringCloud (1) -Microservice

Four core issues of microservice architecture

  1. There are many services, how to access the client?
  2. With so many services, how do services communicate?
  3. How to manage so many services?
  4. What if the service hangs?

solution

SpringCloud 生态

	1. Spring Cloud Netflix :一站式解决方案。

API网关:zuul组件

通信:Feign---HttpClient---Http通信方式(同步,阻塞)

服务注册与发现:Eureka

熔断机制:Hystrix
    
    
	2. Apache Dubbo Zookeeper :半自动,需要整合别人的。

API网关:无

通信:Dubbo

服务注册与发现:Zookeeper

熔断机制:无


	3. Spring Cloud Alibaba :一站式解决方案。
--------------------------------------------------------------------------------   
万变不离其宗:
1. API
2. HTTP,RPC
3. 服务注册与发现
4. 熔断机制
--------------------------------------------------------------------------------
为什么要解决这四个问题?
网络不可靠!

What is a microservice architecture

Microservice architecture is an architectural pattern, or an architectural style, which advocates the division of a single application into a set of small services (divide the whole into individual services, modular), each service in its own In its own process (each service is a process), the processes coordinate with each other and configure each other to provide users with ultimate value. The services use a lightweight communication mechanism (Http) to communicate with each other. Each service is built around specific businesses and can be independently deployed into the production environment. In addition, unified and centralized service management should be avoided as much as possible. Mechanism (service registration and discovery mechanism), for a service, it is necessary to select the appropriate language according to the business context, the tool to build it (Maven), there can be a very lightweight centralized management to coordinate these services, Services can be written in different languages, or different data stores can be used.

The core of the microservice architecture is to split the traditional all-in-one application (All In One) into one-by-one services according to the business, completely decoupling, each microservice provides a single business function, and one service does one thing , Similar to the concept of a process, can be started or destroyed separately, with its own independent database.

Martin Fowler's original text about microservices: https://martinfowler.com/articles/microservices.html

Advantages and disadvantages of microservices

advantage:

  1. Each service is highly cohesive and small, the code is easy to understand, and it can focus on a specified business function or business requirement.
  2. The development is simple and the development efficiency is high. A service may be dedicated to only one thing, the principle of single responsibility.
  3. Can be developed by a small team alone, the small team may be 2-5 people.
  4. Low coupling, both in the development stage and deployment stage are independent.
  5. Can be developed in different languages.
  6. It is easy for a developer to understand, modify, and maintain, so that the small team can pay more attention to their work results, and no cooperation is needed to realize value.
  7. It is just business logic code, and it will not be mixed with HTML, CSS or other interfaces.
  8. Each service has its own storage capacity. It can have its own database or a unified database.

Disadvantages:

  1. Developers have to deal with the complexity of distributed systems.

  2. With the increase of services, the complexity of management increases, which increases the difficulty of operation and maintenance.

  3. Cost of communication between services.

  4. Data consistency.

Technology stack for microservices

Microservice entry Floor technology
Service development SpringBoot,Spring,SpringMVC
Service configuration and management Netflix's Archaius, Alibaba's Diamond
Service registration and discovery Eureka,Consul,Zookeeper
Service call Rest,RPC,gRPC
Service fuse Hystrix,Envoy
Load balancing Ribbon,Nginx
Service interface call glad
message queue Kafka,RabbitMQ,ActiveMQ
Service Configuration Center Management SpringCloudConfig,Chef
Service routing (API gateway) Zuul
Service monitoring Zabbix,Nagios,Metrics,Specatator
Full link tracking Zipkin , Brave , Brave
Service deployment Docker,OpenStack,Kubernetes
Data flow operation development kit SpringClould Stream
Event message stack SpringCloud Bus

Guess you like

Origin www.cnblogs.com/yinrz/p/12724226.html