building cloud native applications using spring boot and spring cloud

Post on 22-Jan-2018

161 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Cloud Native Applications using

Spring Boot & Spring CloudK. Siva Prasad Reddy

Agenda• What is Cloud Native Application?

• Introducing Spring Boot• Why Spring Boot?

• Features of Spring Boot

• Introducing Spring Cloud• Cloud Config: Centralized Configuration Server

• Service Registry using Eureka

• Circuit Breaker using Hystrix

• Zuul Proxy

• Monitoring using Hystrix Dashboard/Turbine

About me• K. Siva Prasad Reddy

• Tech Lead at ThoughtWorks

• Blog: http://sivalabs.in

• Twitter: @sivalabs

• Author of following books

Cloud Native Applications

A cloud-native application is composed of multiple services and each service is elastic, resilient, and composable.

• The Application is composed of multiple services

• Each service is elastic

• Each service is resilient

• Each service is composable

12 Factor Applications(http://12factor.net)

Source: https://www.linkedin.com/pulse/missing-factor-12-apps-prashant-musale/

Source: https://twitter.com/wattersjames/status/664044293250641920

Spring Boot

• An opinionated approach to building Spring based applications

• Convention over Configuration

• Auto Configuration

• Production ready features via Actuator

• I want to integrate with XYZ – There is a starter for that

Spring Cloud

Spring Cloud, builds on top of Spring Boot, provides higher level abstractions for the implementation of various commonly used patterns in distributed systems.

• Configuration management

• Service discovery

• Circuit breakers

• Intelligent routing

• Micro-proxy

• OAuth security

• Distributed sessions etc

Spring Cloud Config• Centralized Configuration Server

• No need to restart applications upon configuration changes

@SpringBootApplication

@EnableConfigServer

public class ConfigServerApplication {

public static void main(String[] args) {

SpringApplication.run(ConfigServerApplication.class, args);

}

}

bootstrap.properties

spring.cloud.config.server.git.uri=https://github.com/siva/config-repo.git

Spring Cloud Config

Spring Cloud Service Registry & Discovery• Sophisticated registration and de-registration of servers with load

balancer on the fly

@SpringBootApplication@EnableEurekaServerpublic class ServiceRegistryApplication {

public static void main(String[] args) {SpringApplication.run(ServiceRegistryApplication.class,

args);}

}

Eureka Service Registry http://localhost:8761/

Spring Cloud Service Discovery

@SpringBootApplication

@EnableEurekaClientpublic class CatalogServiceApplication {

public static void main(String[] args) {SpringApplication.run(CatalogServiceApplication.class, args);

}}

bootstrap.properties

eureka.client.service-url.defaultZone=http://localhost:8761/eureka/

Circuit Breaker Pattern using Hystrix• A pattern to prevent service failure from cascading to other services

@EnableHystrix@EnableEurekaClient@SpringBootApplicationpublic class CatalogServiceApplication {

…}

@Servicepublic class CatalogService {

@HystrixCommand(fallbackMethod = "getProductsFromCache")public List<Product> getProducts() {

...}

private List<Product> getProductsFromCache() {...

}}

Spring Cloud Zuul Proxy

• JVM based router and server side load balancer

• Can use for:• Dynamic routing

• Security/Authentication

• Canary testing

• Avoid CORS concerns

Monitoring using Hystrix Dashboard/Turbine

• Shows health of each circuit breaker

• To monitor multiple applications use Turbine

@SpringBootApplication

@EnableHystrixDashboard@EnableTurbinepublic class CatalogServiceApplication {

public static void main(String[] args) {SpringApplication.run(CatalogServiceApplication.class, args);

}}

Hystrix Dashboard

top related