building cloud native applications using spring boot and spring cloud

19
Cloud Native Applications using Spring Boot & Spring Cloud K. Siva Prasad Reddy

Upload: geeknighthyderabad

Post on 22-Jan-2018

161 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Building Cloud Native Applications Using Spring Boot and Spring Cloud

Cloud Native Applications using

Spring Boot & Spring CloudK. Siva Prasad Reddy

Page 2: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

Page 3: Building Cloud Native Applications Using Spring Boot and Spring Cloud

About me• K. Siva Prasad Reddy

• Tech Lead at ThoughtWorks

• Blog: http://sivalabs.in

• Twitter: @sivalabs

• Author of following books

Page 4: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

Page 5: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

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

Page 6: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

Page 7: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

Page 8: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

Page 9: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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

Page 10: Building Cloud Native Applications Using Spring Boot and Spring Cloud

Spring Cloud Config

Page 11: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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);}

}

Page 12: Building Cloud Native Applications Using Spring Boot and Spring Cloud
Page 13: Building Cloud Native Applications Using Spring Boot and Spring Cloud

Eureka Service Registry http://localhost:8761/

Page 14: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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/

Page 15: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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() {...

}}

Page 16: Building Cloud Native Applications Using Spring Boot and Spring Cloud

Spring Cloud Zuul Proxy

• JVM based router and server side load balancer

• Can use for:• Dynamic routing

• Security/Authentication

• Canary testing

• Avoid CORS concerns

Page 17: Building Cloud Native Applications Using Spring Boot and Spring Cloud

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);

}}

Page 18: Building Cloud Native Applications Using Spring Boot and Spring Cloud

Hystrix Dashboard

Page 19: Building Cloud Native Applications Using Spring Boot and Spring Cloud