Microservices Management微服务的链路保护机制

Microservices Management

What is a microservice avalanche

the failure of a single component can lead to a crash of the entire system.

The avalanche effect Solutions

(1) fusing mode:

This mode is mainly blown reference circuit, if a line voltage is too high, blown fuses and prevent fires. Into our system, if a target service invocation slow or there is a lot of time expires, blown to call the service, the request for a subsequent call, do not continue to call the target service, direct return, quick release resources. If the goal is to restore the situation improved service calls.****The use of time-out mechanism, service degradation****The so-called service degradation is this: when calling an interface service, if an error occurs or a time-out, do not let it calls this interface, but call the local fallback,fallback method can return a fixed value.

What is service degradation

All RPC technology which service degradation is one of the most important topic, so-called demotion refers to the time when the service provider is not available, the program will not be an exception, and the local operation will call fallback

=>circuit breaker

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传Microservices Management微服务的链路保护机制_第1张图片

(2) Isolation mode:

This mode of the system as requested by the same type into one island, when the island is a fire, the less light will not affect the other islands. For example, may be used for different types of requests to the thread pool resource isolation, independently of each other for each type of request, if one type of resource exhaustion request thread, then the type of the subsequent request returned directly, instead of calling up resources. This mode uses scene very much, for example, will open a service, for important services use to deploy a separate server, or again recently to promote multi-center.

(3) limiting mode:

mode and the above-described fuse isolation mode belong to a fault-tolerant processing mechanism after an error, while the current limiting mode may be referred to as a preventive mode. Limiting mode is primarily set in advance QPS highest threshold value for each type of request, if the above threshold is set to return directly to the request, instead of calling up resources. This model does not solve the problem of service depends, can only solve the overall problem of resource allocation system, because the request has not been limiting still likely to cause an avalanche effect.

=>rate limiter

Tools:

Hystrix

Microservices Management微服务的链路保护机制_第2张图片

Hystrix+Turbine

Microservices Management微服务的链路保护机制_第3张图片

The below is one Turbine application example:

spring:
  application:
    name: springcloud-turbine-dept-9002
server:
  port: 9002

eureka:
  client:
    serviceUrl:
      defaultZone: http://eureka7001.com:7001/eureka/
turbine:
  app-config: springcloud-provider-dept8001,springcloud-provider-dept8002
  aggregator:
    cluster-config: default
  cluster-name-expression: new String('default')
  combine-host-port: true

when you input the hystrix stream with cluster information, the below is the format:

Hystrix stream: `IP:Turbine端口号/turbine.stream?cluster=[cluster name]`

Following the above format, you may try http://localhost:9900/turbine.stream?cluster=providers in your browser.

Anyway there would be tons of microservices in the whole system. And some of them will belong to one cluster. If you just want to monitor one cluster’s status, you need configure the cluster information in each application and also in your turbine application.

in your application:

eureka:
  client:
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka
  instance:
    instance-id: providerHystrix8001
    metadata-map:
      cluster: providers

in your Turbine:

spring:
  application:
    name: springcloud-turbine-dept-9002
server:
  port: 9002

eureka:
  client:
    serviceUrl:
      defaultZone: http://eureka7001.com:7001/eureka/
turbine:
  app-config: springcloud-provider-dept8001,springcloud-provider-dept8002
  aggregator:
    cluster-config: providers
  cluster-name-expression: metadata['cluster']
  combine-host-port: true

All in all Turbine is a library which could aggregate the multiple hystrix streams into one stream and then Hystrix dashboard could display this single stream on just one web page instead of creating one monitor page for each microservice’s hystrix stream.

Sentinel

N/A

resilience4j

TBD

*resilience4j-circuitbreaker: Circuit breaking*

*resilience4j-ratelimiter: Rate limiting*

*resilience4j-bulkhead: Bulkheading*

*resilience4j-retry: Automatic retrying (sync and async)*

*resilience4j-cache: Result caching*

*resilience4j-timelimiter: Timeout handling*

Reference:

https://martinfowler.com/bliki/CircuitBreaker.html

https://www.programmersought.com/article/19572178599/

https://github.com/resilience4j/resilience4j

Microservices Management微服务的链路保护机制_第4张图片

misc:

Failover:失败自动切换,当出现失败,重试其它服务器。
Failfast:快速失败,只发起一次调用,失败立即报错。
Failsafe:失败安全,出现异常时,直接忽略。
Failback:失败自动恢复,后台记录失败请求,定时重发。
Forking:并行调用多个服务器,只要一个成功即返回。
Broadcast:广播调用所有提供者,逐个调用,任意一台报错则报错。

你可能感兴趣的:(听课记录,MicroServices)