掌握高并发、高可用架构第四章 微服务

本章介绍微服务的概念、为何要引入微服务、微服务会引发的问题,以及流行的微服务架构等。

第二节 SpringCloud

SpringBoot SpringCloud

Spring Boot

是Spring组件一站式解决方案,主要是简化了使用Spring的难度,减省了繁重的配置,提供了各种启动器,使得开发者快速上手

主要有三个注解:

@SpringBootConfiguration,实现了配置文件的功能@EnableAutoConfiguration,开启自动配置@ComponentScan,组件扫描

各种启动器:

spring-boot-starter-webspring-boot-starter-jdbcspring-boot-starter-jpaspring-boot-starter-securityspring-boot-starter-actuator,监控和跟踪的功能spring-boot-starter-logging,使用logback进行日志记录spring-boot-starter-cacheSpring Cloud

分布式注册中心-Eureka

@EnableEurekaServer

@EnableDiscoveryClient

服务调用-Feign

@FeignClient(servername)

本地负载均衡-Ribbon

@LoadBalanced

服务断路器、降级、隔离-Hystrix

@HystrixCommand(fallback=method)

网关Zuul

@EnableZuulProxy

配置中心-SpringCloud Config

消息总线-Bus