Spring Cloud- new generation of Web services framework Micro

Preface

springcloud is a master of micro-service architecture, a series of excellent components were integrated. springboot build on our familiar spring programmers based, relatively easy to get started.

With a few simple annotations, we can quickly look at commonly used in the application configuration module and build large distributed systems.

FIG mainly used below to understand the concept of the individual components of it

Which components have outstanding

 

Eureka

Function: service registration and discovery, when each service starts, Eureka Client service will be registered with the Eureka Server, and Eureka Client can also turn to take the registry from Eureka Server pull, so they know where other services

Ribbon

Function: Service calls requesting client load balancing, time between service initiated the request, based on the Ribbon to do load balancing, multiple machines from a service, select a 

Feign

Function: Service call request, based on a dynamic proxy mechanism Feign, according to the notes and selected machine, stitching request URL address and send a request

Hystrix

Function: Fuse, initiates a request by Hystrix thread pool to go, different services take a different thread pool to achieve the isolation of different service calls, to avoid the avalanche of service issues

Zuul

Function: api routing gateway, if the front-end, back-end system to call the mobile terminal, the gateway into the Unified from Zuul, forwarded by Zuul gateway request to the corresponding service

Sleuth

Function: link tracking service, the main function is to provide tracking solutions in distributed systems, and is compatible support zipkin

 

Spring Cloud core components: Eureka service registration and discovery

He has composed three-terminal

1.Eureka Server service registration and discovery center end

2.Service Provider service provider side

3.Service Consumer Services callers end

Official figure

Spring Cloud core components: Feign

Interface calls, restful style http java interface mode can be used to call the tune.

Assemble their own url and parameters as well as first-class information request, you do not have to go write it. Easy to use.

Look to the code is called

//url=http://www.me.com@FeignClient(url = "${feign.order-promotion.url}")
public interface PromotionClient {
    @RequestMapping(value = "/Member/Promotion/ReleasePromtionByOrderId", method = RequestMethod.POST)
    BaseWcfResponse<Integer> ReleasePromtionByOrderId(@RequestBody ReleasePromtionReq request);
}

Spring Cloud核心组件:Ribbon

客户端负载均衡,一个服务部署多台机器的情况feign不知道调用那台服务,那么ribbon就可以使用默认abab的轮询算法,给确定那一台机器

Spring Cloud核心组件:Hystrix

熔断器,个别服务接口挂拉,可能会影响整个服务链路,导致整体服务不可用,这个时候hystrix就派上用场啦。

Spring Cloud核心组件:Zuul

前端、移动端要调用后端系统,统一从Zuul网关进入,由Zuul网关转发请求给对应的服务

整体项目架构图

 

Guess you like

Origin www.cnblogs.com/dekevin/p/11588013.html