Upload
alain-sahli
View
120
Download
3
Tags:
Embed Size (px)
Citation preview
© mimacom
30.03.2015
Agenda• Introduction • Microservices architecture • Spring Cloud components • Demo
© mimacom
30.03.2015
GitHub Builds & Deploys
Source: https://github.com/blog/1241-deploying-at-github
© mimacom
30.03.2015
GitHub Builds & Deploys
Source: https://github.com/blog/1241-deploying-at-github
175 deploys!
© mimacom
30.03.2015
Summary• Service discovery: Netflix Eureka• Client-side load balancing: Netflix Ribbon
© mimacom
30.03.2015
Summary• Service discovery: Netflix Eureka• Client-side load balancing: Netflix Ribbon• Circuit breaker: Netflix Hystrix
© mimacom
30.03.2015
Summary• Service discovery: Netflix Eureka• Client-side load balancing: Netflix Ribbon• Circuit breaker: Netflix Hystrix• API gateway: Netflix Zuul
© mimacom
30.03.2015
Summary• Service discovery: Netflix Eureka• Client-side load balancing: Netflix Ribbon• Circuit breaker: Netflix Hystrix• API gateway: Netflix Zuul• Configuration: Spring Cloud Config
• Spring Cloud Bus for refreshing the config
© mimacom
30.03.2015
Spring IOCLOUD
SERVICE REGISTRY,CIRCUIT BREAKER, METRICS
CORE
FRAMEWORK SECURITY GROOVY REACTOR
IO E
XECU
TION
IO F
OUND
ATIO
N
GRAILS
FULL STACK, WEB
XD
STREAMS, TAPS, JOBS
BOOT
BOOTABLE, MINIMAL, OPS-READY
BATCH
JOBS, STEPS,READERS, WRITERS
DATA
RELATIONAL DATA NON-RELATIONAL DATA
BIG DATA
INGESTION, EXPORT,ORCHESTRATION, HADOOP
WEB
CONTROLLERS, REST,WEBSOCKET
INTEGRATION
CHANNELS, FILTERS,ADAPTERS, TRANSFORMERS
IO C
OORD
INAT
ION
© mimacom
30.03.2015
Spring Boot: Short Introduction
“Takes an opinionated view of building production-ready Spring applications”
© mimacom
30.03.2015
Spring Boot: Short Introduction
• Create standalone Spring applications • Provide opinionated “starter” POMs to simplify
your maven configuration • Automatically configure Spring whenever
possible • Provide production-ready features such as metrics,
health checks and externalized configuration
“Takes an opinionated view of building production-ready Spring applications”
© mimacom
30.03.2015
Spring Boot: Key FeaturesMyApplication.java:
@SpringBootApplication public class EurekaServer {
public static void main(String[] args) { SpringApplication.run(MyApplication.class, args);
} }
© mimacom
30.03.2015
Spring Boot: Key FeaturesMyApplication.java:
@SpringBootApplication public class EurekaServer {
public static void main(String[] args) { SpringApplication.run(MyApplication.class, args);
} }
pom.xml:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>
</dependency>
© mimacom
30.03.2015
Spring Boot: Key FeaturesMyApplication.java:
@SpringBootApplication public class EurekaServer {
public static void main(String[] args) { SpringApplication.run(MyApplication.class, args);
} }
pom.xml:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>
</dependency>
Configuration file: application.yml, bootstrap.yml
© mimacom
30.03.2015
Spring Cloud
Bus
Connectors
Starters
Amazon Web Services
Config
Cloud Foundry
Netflix
CLI
© mimacom
30.03.2015
Spring Cloud Config: Server
Spring Cloud Config Server
GIT
SVN
File
ConfigServer.java:
@SpringBootApplication @EnableConfigServer public class ConfigServer {…}
© mimacom
30.03.2015
Spring Cloud Config: Server
Spring Cloud Config Server
GIT
SVN
File
ConfigServer.java:
@SpringBootApplication @EnableConfigServer public class ConfigServer {…}
application.yml
spring.cloud.config.git.uri: https://github.com/…
© mimacom
30.03.2015
Spring Cloud Config: Client
Spring Cloud Config Server
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
© mimacom
30.03.2015
Spring Cloud Config: Client
Spring Cloud Config Server
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
Application
Spring Cloud Config Client
bootstrap.yml: spring.cloud.config.uri: ${vcap.services.configserver.credentials.uri}
© mimacom
30.03.2015
Spring Cloud Netflix: Eureka
Spring Cloud Eureka Server
Application
Spring Cloud Eureka Client
Application
Spring Cloud Eureka Client
Application
Spring Cloud Eureka Client
© mimacom
30.03.2015
Spring Cloud Netflix: Eureka
Spring Cloud Eureka Server
Application
Spring Cloud Eureka Client
Application
Spring Cloud Eureka Client
Application
Spring Cloud Eureka Client
EurekaServer.java:
@SpringBootApplication @EnableEurekaServer public class EurekaServer {…}
© mimacom
30.03.2015
Spring Cloud Netflix: Eureka
Spring Cloud Eureka Server
Application
Spring Cloud Eureka Client
Application
Spring Cloud Eureka Client
Application
Spring Cloud Eureka Client
EurekaServer.java:
@SpringBootApplication @EnableEurekaServer public class EurekaServer {…}
Application.java:
@SpringBootApplication @EnableEurekaClient public class Application {…}
© mimacom
30.03.2015
Spring Cloud Netflix: RibbonRibbonSample.java:
public class RibbonSample {
@Autowired private RestTemplate restTemplate;
public void foo() { restTemplate.postForLocation(“http://customers/add”, customer); } }
© mimacom
30.03.2015
Spring Cloud Netflix: Zuul
ApiGateway.java: @SpringBootApplication @EnableZuulProxy public class ApiGateway {…}
© mimacom
30.03.2015
Spring Cloud Netflix: Zuul
ApiGateway.java: @SpringBootApplication @EnableZuulProxy public class ApiGateway {…}
application.yml: zuul: ignoredServices: * routes: users: /myusers/**
© mimacom
30.03.2015
Spring Cloud Netflix: HystrixPentagonApplication.java: @SpringBootApplication @EnableHystrix public class PentagonApplication {…}
© mimacom
30.03.2015
Spring Cloud Netflix: HystrixPentagonApplication.java: @SpringBootApplication @EnableHystrix public class PentagonApplication {…}
Store.java: @HystrixCommand(fallbackMethod = "defaultStores") public Object getStores(Map<String, Object> parameters) {
//Call another service over HTTP (ribbon) }
public Object defaultStores(Map<String, Object> parameters) { return /* some fallback data */;
}
© mimacom
30.03.2015
Spring Cloud Netflix: HystrixPentagonApplication.java: @SpringBootApplication @EnableHystrix public class PentagonApplication {…}
Store.java: @HystrixCommand(fallbackMethod = "defaultStores") public Object getStores(Map<String, Object> parameters) {
//Call another service over HTTP (ribbon) }
public Object defaultStores(Map<String, Object> parameters) { return /* some fallback data */;
}
© mimacom
30.03.2015
Spring Cloud Netflix: HystrixPentagonApplication.java: @SpringBootApplication @EnableHystrix public class PentagonApplication {…}
Store.java: @HystrixCommand(fallbackMethod = "defaultStores") public Object getStores(Map<String, Object> parameters) {
//Call another service over HTTP (ribbon) }
public Object defaultStores(Map<String, Object> parameters) { return /* some fallback data */;
}
© mimacom
30.03.2015
Demo Application
Zuul Server
Service Discovery
EurekaCustomers Stores
Config Server
Hystrix Dashboard
Browser
Turbine
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard• Netflix Turbine: Aggregate hystrix streams
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard• Netflix Turbine: Aggregate hystrix streams• Netflix Ribbon: Client-side load-balancing
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard• Netflix Turbine: Aggregate hystrix streams• Netflix Ribbon: Client-side load-balancing• Netflix Zuul: Reverse proxy for API gateway
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard• Netflix Turbine: Aggregate hystrix streams• Netflix Ribbon: Client-side load-balancing• Netflix Zuul: Reverse proxy for API gateway• Spring Cloud Config: Centralized configuration
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard• Netflix Turbine: Aggregate hystrix streams• Netflix Ribbon: Client-side load-balancing• Netflix Zuul: Reverse proxy for API gateway• Spring Cloud Config: Centralized configuration• Spring Cloud Bus: Publish events over RabbitMQ
© mimacom
30.03.2015
Summary• Netflix Eureka: Service registry & discovery• Netflix Hystrix: Circuit breaker and dashboard• Netflix Turbine: Aggregate hystrix streams• Netflix Ribbon: Client-side load-balancing• Netflix Zuul: Reverse proxy for API gateway• Spring Cloud Config: Centralized configuration• Spring Cloud Bus: Publish events over RabbitMQ• Spring Cloud Netflix: Configure Netflix components