Cloud Native Applications
using
Spring Boot & Spring Cloud
K. 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
@EnableEurekaServer
public class ServiceRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceRegistryApplication.class,
args);
}
}
Eureka Service Registry
http://localhost:8761/
Spring Cloud Service Discovery
@SpringBootApplication
@EnableEurekaClient
public 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
@SpringBootApplication
public class CatalogServiceApplication {
…
}
@Service
public 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
@EnableTurbine
public class CatalogServiceApplication {
public static void main(String[] args) {
SpringApplication.run(CatalogServiceApplication.class, args);
}
}
Hystrix Dashboard
Building Cloud Native Applications Using Spring Boot and Spring Cloud

Building Cloud Native Applications Using Spring Boot and Spring Cloud

  • 1.
    Cloud Native Applications using SpringBoot & Spring Cloud K. Siva Prasad Reddy
  • 2.
    Agenda • What isCloud 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
  • 3.
    About me • K.Siva Prasad Reddy • Tech Lead at ThoughtWorks • Blog: http://sivalabs.in • Twitter: @sivalabs • Author of following books
  • 4.
    Cloud Native Applications Acloud-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
  • 5.
    12 Factor Applications(http://12factor.net) Source:https://www.linkedin.com/pulse/missing-factor-12-apps-prashant-musale/
  • 6.
  • 7.
    Spring Boot • Anopinionated 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 
  • 8.
    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
  • 9.
    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
  • 10.
  • 11.
    Spring Cloud ServiceRegistry & Discovery • Sophisticated registration and de-registration of servers with load balancer on the fly @SpringBootApplication @EnableEurekaServer public class ServiceRegistryApplication { public static void main(String[] args) { SpringApplication.run(ServiceRegistryApplication.class, args); } }
  • 13.
  • 14.
    Spring Cloud ServiceDiscovery @SpringBootApplication @EnableEurekaClient public class CatalogServiceApplication { public static void main(String[] args) { SpringApplication.run(CatalogServiceApplication.class, args); } } bootstrap.properties eureka.client.service- url.defaultZone=http://localhost:8761/eureka/
  • 15.
    Circuit Breaker Patternusing Hystrix • A pattern to prevent service failure from cascading to other services @EnableHystrix @EnableEurekaClient @SpringBootApplication public class CatalogServiceApplication { … } @Service public class CatalogService { @HystrixCommand(fallbackMethod = "getProductsFromCache") public List<Product> getProducts() { ... } private List<Product> getProductsFromCache() { ... } }
  • 16.
    Spring Cloud ZuulProxy • JVM based router and server side load balancer • Can use for: • Dynamic routing • Security/Authentication • Canary testing • Avoid CORS concerns
  • 17.
    Monitoring using HystrixDashboard/Turbine • Shows health of each circuit breaker • To monitor multiple applications use Turbine @SpringBootApplication @EnableHystrixDashboard @EnableTurbine public class CatalogServiceApplication { public static void main(String[] args) { SpringApplication.run(CatalogServiceApplication.class, args); } }
  • 18.

Editor's Notes

  • #5 https://www.nirmata.com/2014/05/20/cloud-native-software-key-characteristics/