SlideShare a Scribd company logo
JAVA MICROSERVICES WITH
NETFLIX OSS & SPRING
CONOR SVENSSON
Java Microservices with Netflix OSS & Spring
Java Microservices with Netflix OSS & Spring
SPRING BOOT
SPRING BOOT
▸ Stand-alone Spring-based applications
▸ Tomcat embedded container (supports Jetty & JBoss
Undertow too)
▸ Starter POMs
▸ Annotation driven
SPRING BOOT
DEPLOYMENT
▸ Self contained jar
▸ Web application archive
▸ Build targets
▸ $ mvn spring-boot:run
▸ $ gradle bootRun
SPRING BOOT
ACME HOME LOANS
ACME HOME LOANS
LOAN APPLICATION
EXTERNAL
CREDIT
SERVICE
WEBSITE
SERVICE
SUBMISSION
SERVICE
1
2 3
ACME HOME LOANS
ACME HOME LOANS
ACME HOME LOANS
SPRING BOOT
TESTING
▸ spring-boot-starter-test starter POM provides:
▸ Spring Test
▸ Unit
▸ Hamcrest + Assert4J (v1.4)
▸ Mockito
▸ MockMvc
▸ @WebIntegrationTest
Java Microservices with Netflix OSS & Spring
Java Microservices with Netflix OSS & Spring
SPRING BOOT
CONFIGURATION BEANS
Java Microservices with Netflix OSS & Spring
SPRING CLOUD
SPRING CLOUD
▸ Microservice friendly components
▸ Distributed & versioned configuration
▸ Service discovery
▸ Dynamic routing
▸ Circuit breakers
▸ Distributed messaging
▸ Getting started:
SPRING CLOUD
SPRING CLOUD
▸ Config
▸ Netflix
▸ Bus
▸ Cloud Foundry
▸ Cluster
▸ Consul
▸ Security
▸ Sleuth
▸ Data Flow
▸ Stream
▸ Modules
▸ Task
▸ Zookeeper
▸ AWS
▸ Connectors
▸ CLI
SPRING CLOUD
CONFIG SERVER
▸ Git hosted configuration repository
▸ SVN & filesystem also supported (see implementations
of
org.springframework.cloud.config.server.EnvironmentR
epository)
▸ Multiple security options w/Spring Security (HTTP Basic ->
OAuth bearer tokens)
▸ Push updates via Spring Cloud Bus
SPRING CLOUD
CONFIG SERVER
SPRING CLOUD
CONFIG SERVER CONFIGURATION
application.yml:
SPRING CLOUD
CLIENT CONFIGURATION FILE
website.yml:
SPRING CLOUD
RESOURCE FORMAT
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
(label: master by default)
SPRING CLOUD
RESOLVED CONFIGURATION
SPRING CLOUD
SHARED RESOURCES
▸ Place in application.yml in root of configuration repo
▸ Profile specific configuration always takes precedence
over shared
▸ E.g. Eureka server (more on this shortly)
SPRING CLOUD
CLIENT CONFIGURATION
bootstrap.yml:
SPRING CLOUD
CLIENT PROFILES
▸ Annotate classes to associate with a profile
▸ @Profile(“…”)
▸ Configuration (bootstrap/application properties)
▸ spring.profiles.active = …
▸ Command line
▸ -Dspring.profiles.active=…
▸ Environment variable
▸ SPRING_PROFILES_ACTIVE=…
SPRING CLOUD
RESOLVED CLIENT CONFIGURATION
SPRING CLOUD
CONFIG SERVER GOTCHAS
▸ Client’s don’t fail on Config Server failure - boot with
defaults (e.g. port 8080)
▸ To enable use spring.cloud.config.failFast=true
▸ Enable retries:
▸ Add spring-retry and spring-boot-starter-aop
▸ spring.cloud.config.retry.
Java Microservices with Netflix OSS & Spring
NETFLIX OSS + SPRING
SPRING CLOUD NETFLIX
▸ Service discovery (Eureka)
▸ Client side load balancing (Ribbon)
▸ Dynamic routing (Zuul)
▸ Circuit breaker (Hystrix)
▸ + a few others…
NETFLIX OSS + SPRING
EUREKA
▸ Service discovery client & server
▸ Maintains registry of clients with metadata
▸ Host/port
▸ Health indicator URL
▸ Client heartbeats (30 sec default - changing not encouraged)
▸ Lease renewed with server
▸ Service available when client & server(s) metadata cache all in sync
▸ Can take up to 3 heart beats
NETFLIX OSS + SPRING
EUREKA SERVER
NETFLIX OSS + SPRING
EUREKA SERVER DASHBOARD
NETFLIX OSS + SPRING
EUREKA CLIENT SETUP
@EnableEurekaClient annotation
application.yml in Config Server repo
NETFLIX OSS + SPRING
RIBBON
▸ Client side loan balancer
▸ Can delegate to Eureka for server lists
▸ Or list servers
▸ stores.ribbon.listOfServers=… +
ribbon.eureka.enabled=false
NETFLIX OSS + SPRING
RIBBON USAGE
▸ Via RestTemplate
▸ No different to normal usage - Spring Cloud Commons
abstraction
▸ Qualifier’s required if using regular & Ribbon enabled
RestTemplate
NETFLIX OSS + SPRING
ZUUL
▸ JVM based router & load balancer
▸ Provides single point of entry to services
▸ Including single point of authentication
▸ By default creates route for every service in Eureka
▸ Refer to http://localhost/credit-service routes to http://credit-
service
▸ Filters provide limited entry points to system
NETFLIX OSS + SPRING
ZUUL SERVER CREATION
‣ Include dependency spring-cloud-starter-zuul
‣ @EnableZuulProxy application annotation
‣ E.g. Allow access only to credit-service
NETFLIX OSS + SPRING
SIDECAR
▸ Non-JVM access to components via Zuul proxy
▸ Setup Spring Boot application with @EnableSidecar
▸ Configure for your service:
▸ sidecar.port=… + sidecar.health-ui=…
▸ Access all services by Zuul URL (Sidecar running on port
80)
▸ http://localhost/config-server
NETFLIX OSS + SPRING
HYSTRIX
▸ Circuit breaker
▸ Threshold breached (20 failures in 5 seconds) => breaker
kicks in
▸ Default timeout threshold 1 second
▸ Per dependency thread pools
▸ Async command support (not Spring @Async)
▸ Sync or async fallback
NETFLIX OSS + SPRING
HYSTRIX CLIENT
▸ @EnableCircuitBreaker application annotation
▸ @HystrixCommand on applicable methods
NETFLIX OSS + SPRING
NETFLIX OSS + SPRING
HYSTRIX STREAM - PRE-REQUESTS
NETFLIX OSS + SPRING
HYSTRIX STREAM - POST-REQUESTS
NETFLIX OSS + SPRING
HYSTRIX DASHBOARD
NETFLIX OSS + SPRING
HYSTRIX STREAM
NETFLIX OSS + SPRING
HYSTRIX DASHBOARD
NETFLIX OSS + SPRING
TURBINE - AGGREGATE MULTIPLE HYSTRIX CLIENTS
NETFLIX OSS + SPRING
MONITORING
▸ Add dependency spring-boot-actuator
▸ Makes available various application metrics via /metrics
endpoint
▸ Integration also available with DropWizard metrics (add
dependency)
▸ Spring Cloud
▸ Spectator (supersedes Servo) - metrics collection
▸ Atlas - metrics backend
NETFLIX OSS + SPRING
NETFLIX OSS + SPRING
LOGGING
▸ Logback is the default choice
▸ Alternative starters are provided
▸ Using alternatives (such as log4j2) requires exclusions
throughout the starter POMs
NETFLIX OSS + SPRING
DOWNSIDES
▸ A lot of magic - e.g. CORS filters
▸ ADD (Annotation driven development)
▸ Dependency management
▸ RestTemplates - Ribbon enabled != Standard HTTP
▸ Lack of proper polygot support - libraries are in Java
(Sidecar is OK as a middle ground)
▸ Spring Hystrix documentation is pretty light
NETFLIX OSS + SPRING
ALTHOUGH…
NETFLIX OSS + SPRING
RESOURCES
▸ Spring Cloud documentation - http://projects.spring.io/spring-cloud/spring-cloud.html
▸ Spring Boot sample projects - https://github.com/spring-projects/spring-boot/tree/
master/spring-boot-samples
▸ Spring Cloud sample projects - https://github.com/spring-cloud-samples
▸ Hystrix annotations - https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/
hystrix-javanica
▸ Useful demonstration of Spring Cloud usage - http://callistaenterprise.se/blogg/teknik/
2015/05/20/blog-series-building-microservices/
▸ Spring project dependency selector - http://start.spring.io/
▸ Code to accompany this talk - https://github.com/conor10/homeloans
▸ https://www.huffle.com.au
NETFLIX OSS + SPRING
THANKS
conor@huffle.com.au

More Related Content

What's hot (20)

PDF
AWS re:Invent re:Cap 2019: My ElasticSearch Journey on AWS
smalltown
 
PDF
Service discovery with Eureka and Spring Cloud
Marcelo Serpa
 
PDF
Spring Cloud Into Production
Todd Miller
 
PPTX
Gatekeeper: API gateway
ChengHui Weng
 
PDF
Cloud Native Microservices with Spring Cloud
Conor Svensson
 
PPTX
Multi-Clusters Made Easy with Liqo:
Getting Rid of Your Clusters Keeping Them...
KCDItaly
 
PDF
NetflixOSS Meetup S6E2 - Spinnaker, Kayenta
aspyker
 
PDF
Microservices with Spring and Cloud Foundry
Alain Sahli
 
PDF
Sf bay area Kubernetes meetup dec8 2016 - deployment models
Peter Ss
 
PDF
Rohit yadav cloud stack internals
ShapeBlue
 
PDF
Microservices with Spring Cloud and Netflix OSS
Denis Danov
 
PPTX
Monitoring Weave Cloud with Prometheus
Weaveworks
 
PPTX
Netflix0SS Services on Docker
Docker, Inc.
 
PDF
The elements of kubernetes
Aaron Schlesinger
 
PPTX
Knative goes
 beyond serverless | Alexandre Roman
KCDItaly
 
PDF
Istio on Kubernetes
Daneyon Hansen
 
PDF
Large Scale Kubernetes on AWS at Europe's Leading Online Fashion Platform - A...
Henning Jacobs
 
PDF
Create Great CNCF User-Base from Lessons Learned from Other Open Source Commu...
Lee Calcote
 
PDF
Make Java Microservices Resilient with Istio - Mangesh - IBM - CC18
CodeOps Technologies LLP
 
PPTX
Kubernetes your next application server
Red Hat Developers
 
AWS re:Invent re:Cap 2019: My ElasticSearch Journey on AWS
smalltown
 
Service discovery with Eureka and Spring Cloud
Marcelo Serpa
 
Spring Cloud Into Production
Todd Miller
 
Gatekeeper: API gateway
ChengHui Weng
 
Cloud Native Microservices with Spring Cloud
Conor Svensson
 
Multi-Clusters Made Easy with Liqo:
Getting Rid of Your Clusters Keeping Them...
KCDItaly
 
NetflixOSS Meetup S6E2 - Spinnaker, Kayenta
aspyker
 
Microservices with Spring and Cloud Foundry
Alain Sahli
 
Sf bay area Kubernetes meetup dec8 2016 - deployment models
Peter Ss
 
Rohit yadav cloud stack internals
ShapeBlue
 
Microservices with Spring Cloud and Netflix OSS
Denis Danov
 
Monitoring Weave Cloud with Prometheus
Weaveworks
 
Netflix0SS Services on Docker
Docker, Inc.
 
The elements of kubernetes
Aaron Schlesinger
 
Knative goes
 beyond serverless | Alexandre Roman
KCDItaly
 
Istio on Kubernetes
Daneyon Hansen
 
Large Scale Kubernetes on AWS at Europe's Leading Online Fashion Platform - A...
Henning Jacobs
 
Create Great CNCF User-Base from Lessons Learned from Other Open Source Commu...
Lee Calcote
 
Make Java Microservices Resilient with Istio - Mangesh - IBM - CC18
CodeOps Technologies LLP
 
Kubernetes your next application server
Red Hat Developers
 

Viewers also liked (13)

PPTX
Data stream processing and micro service architecture
Vyacheslav Benedichuk
 
PDF
The seven more deadly sins of microservices final
Haufe-Lexware GmbH & Co KG
 
PDF
Building a Modern Microservices Architecture at Gilt: The Essentials
C4Media
 
PPTX
Deployment Automation with Microservices
Ganesh Ghag
 
PDF
Developing and deploying applications with Spring Boot and Docker (@oakjug)
Chris Richardson
 
PDF
Continuous Delivery - Voxxed Days Bucharest 2017
Rafał Leszko
 
PDF
Voxxed Days Thessaloniki 2016 - Continuous Delivery: Jenkins, Docker and Spri...
Voxxed Days Thessaloniki
 
PDF
From a Monolithic to a Distributed API Architecture
 at Eventbrite - Presente...
Renaud Visage
 
PDF
Scaling Gilt: from Monolithic Ruby Application to Distributed Scala Micro-Ser...
C4Media
 
PPTX
Zero to Continuous Delivery on Google Cloud
James Heggs
 
PDF
Microservices deployment patterns
Abhishek Tiwari
 
PDF
Edge architecture ieee international conference on cloud engineering
Mikey Cohen - Hiring Amazing Engineers
 
PPTX
Zuul @ Netflix SpringOne Platform
Mikey Cohen - Hiring Amazing Engineers
 
Data stream processing and micro service architecture
Vyacheslav Benedichuk
 
The seven more deadly sins of microservices final
Haufe-Lexware GmbH & Co KG
 
Building a Modern Microservices Architecture at Gilt: The Essentials
C4Media
 
Deployment Automation with Microservices
Ganesh Ghag
 
Developing and deploying applications with Spring Boot and Docker (@oakjug)
Chris Richardson
 
Continuous Delivery - Voxxed Days Bucharest 2017
Rafał Leszko
 
Voxxed Days Thessaloniki 2016 - Continuous Delivery: Jenkins, Docker and Spri...
Voxxed Days Thessaloniki
 
From a Monolithic to a Distributed API Architecture
 at Eventbrite - Presente...
Renaud Visage
 
Scaling Gilt: from Monolithic Ruby Application to Distributed Scala Micro-Ser...
C4Media
 
Zero to Continuous Delivery on Google Cloud
James Heggs
 
Microservices deployment patterns
Abhishek Tiwari
 
Edge architecture ieee international conference on cloud engineering
Mikey Cohen - Hiring Amazing Engineers
 
Zuul @ Netflix SpringOne Platform
Mikey Cohen - Hiring Amazing Engineers
 
Ad

Similar to Java Microservices with Netflix OSS & Spring (20)

PDF
Cloud Native Microservices with Spring Cloud
Conor Svensson
 
PDF
The Good Parts / The Hard Parts
Noah Zoschke
 
PDF
Traefik as an open source edge router for microservice architectures
Jakub Hajek
 
PDF
StackWatch: A prototype CloudWatch service for CloudStack
Chiradeep Vittal
 
PDF
ecs-presentation
Marc Costello
 
PDF
10. th cncf meetup - Routing microservice-architectures-with-traefik-cncfsk
Juraj Hantak
 
PDF
Going Serverless on AWS with Golang and SAM
George Tourkas
 
PDF
Scaling Microservices with Kubernetes
Deivid Hahn Fração
 
PDF
Security Practitioners guide to Micro Segmentation with VMware NSX and Log In...
Anthony Burke
 
PDF
Canary deployment with Traefik and K3S
Jakub Hajek
 
PDF
Stockholm Serverless Meetup - Serverless Challenges
İbrahim Gürses
 
PDF
ITB2019 Serverless CFML on AWS Lambda - Pete Freitag
Ortus Solutions, Corp
 
PDF
Cloud-native .NET-Microservices mit Kubernetes @BASTAcon
Mario-Leander Reimer
 
PDF
Introduction to istio
Andrea Monacchi
 
PDF
Traefik 2.x features - canary deployment with Traefik and K3S
Jakub Hajek
 
PDF
JDO 2019: Container orchestration with Docker Swarm - Jakub Hajek
PROIDEA
 
PDF
The state of the swarm
Mathieu Buffenoir
 
PDF
Kubernetes Workshop
Walter Liu
 
PDF
Big Data on AWS
Szilveszter Molnár
 
PDF
New features of Azure Cloud Provider in OpenShift Container Platform 3.10
Takayoshi Tanaka
 
Cloud Native Microservices with Spring Cloud
Conor Svensson
 
The Good Parts / The Hard Parts
Noah Zoschke
 
Traefik as an open source edge router for microservice architectures
Jakub Hajek
 
StackWatch: A prototype CloudWatch service for CloudStack
Chiradeep Vittal
 
ecs-presentation
Marc Costello
 
10. th cncf meetup - Routing microservice-architectures-with-traefik-cncfsk
Juraj Hantak
 
Going Serverless on AWS with Golang and SAM
George Tourkas
 
Scaling Microservices with Kubernetes
Deivid Hahn Fração
 
Security Practitioners guide to Micro Segmentation with VMware NSX and Log In...
Anthony Burke
 
Canary deployment with Traefik and K3S
Jakub Hajek
 
Stockholm Serverless Meetup - Serverless Challenges
İbrahim Gürses
 
ITB2019 Serverless CFML on AWS Lambda - Pete Freitag
Ortus Solutions, Corp
 
Cloud-native .NET-Microservices mit Kubernetes @BASTAcon
Mario-Leander Reimer
 
Introduction to istio
Andrea Monacchi
 
Traefik 2.x features - canary deployment with Traefik and K3S
Jakub Hajek
 
JDO 2019: Container orchestration with Docker Swarm - Jakub Hajek
PROIDEA
 
The state of the swarm
Mathieu Buffenoir
 
Kubernetes Workshop
Walter Liu
 
Big Data on AWS
Szilveszter Molnár
 
New features of Azure Cloud Provider in OpenShift Container Platform 3.10
Takayoshi Tanaka
 
Ad

More from Conor Svensson (9)

PDF
web3j Overview
Conor Svensson
 
PDF
Building Java and Android apps on the blockchain
Conor Svensson
 
PDF
Web3j 2.0 Update
Conor Svensson
 
PDF
Blockchain - Navigating this Game-Changing Technology
Conor Svensson
 
PDF
web3j 1.0 update
Conor Svensson
 
PDF
Java and the blockchain - introducing web3j
Conor Svensson
 
PDF
Ether mining 101 v2
Conor Svensson
 
PDF
web3j overview
Conor Svensson
 
PDF
Ether Mining 101
Conor Svensson
 
web3j Overview
Conor Svensson
 
Building Java and Android apps on the blockchain
Conor Svensson
 
Web3j 2.0 Update
Conor Svensson
 
Blockchain - Navigating this Game-Changing Technology
Conor Svensson
 
web3j 1.0 update
Conor Svensson
 
Java and the blockchain - introducing web3j
Conor Svensson
 
Ether mining 101 v2
Conor Svensson
 
web3j overview
Conor Svensson
 
Ether Mining 101
Conor Svensson
 

Recently uploaded (20)

PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 

Java Microservices with Netflix OSS & Spring

  • 1. JAVA MICROSERVICES WITH NETFLIX OSS & SPRING CONOR SVENSSON
  • 4. SPRING BOOT SPRING BOOT ▸ Stand-alone Spring-based applications ▸ Tomcat embedded container (supports Jetty & JBoss Undertow too) ▸ Starter POMs ▸ Annotation driven
  • 5. SPRING BOOT DEPLOYMENT ▸ Self contained jar ▸ Web application archive ▸ Build targets ▸ $ mvn spring-boot:run ▸ $ gradle bootRun
  • 8. ACME HOME LOANS LOAN APPLICATION EXTERNAL CREDIT SERVICE WEBSITE SERVICE SUBMISSION SERVICE 1 2 3
  • 12. SPRING BOOT TESTING ▸ spring-boot-starter-test starter POM provides: ▸ Spring Test ▸ Unit ▸ Hamcrest + Assert4J (v1.4) ▸ Mockito ▸ MockMvc ▸ @WebIntegrationTest
  • 17. SPRING CLOUD SPRING CLOUD ▸ Microservice friendly components ▸ Distributed & versioned configuration ▸ Service discovery ▸ Dynamic routing ▸ Circuit breakers ▸ Distributed messaging ▸ Getting started:
  • 18. SPRING CLOUD SPRING CLOUD ▸ Config ▸ Netflix ▸ Bus ▸ Cloud Foundry ▸ Cluster ▸ Consul ▸ Security ▸ Sleuth ▸ Data Flow ▸ Stream ▸ Modules ▸ Task ▸ Zookeeper ▸ AWS ▸ Connectors ▸ CLI
  • 19. SPRING CLOUD CONFIG SERVER ▸ Git hosted configuration repository ▸ SVN & filesystem also supported (see implementations of org.springframework.cloud.config.server.EnvironmentR epository) ▸ Multiple security options w/Spring Security (HTTP Basic -> OAuth bearer tokens) ▸ Push updates via Spring Cloud Bus
  • 21. SPRING CLOUD CONFIG SERVER CONFIGURATION application.yml:
  • 25. SPRING CLOUD SHARED RESOURCES ▸ Place in application.yml in root of configuration repo ▸ Profile specific configuration always takes precedence over shared ▸ E.g. Eureka server (more on this shortly)
  • 27. SPRING CLOUD CLIENT PROFILES ▸ Annotate classes to associate with a profile ▸ @Profile(“…”) ▸ Configuration (bootstrap/application properties) ▸ spring.profiles.active = … ▸ Command line ▸ -Dspring.profiles.active=… ▸ Environment variable ▸ SPRING_PROFILES_ACTIVE=…
  • 29. SPRING CLOUD CONFIG SERVER GOTCHAS ▸ Client’s don’t fail on Config Server failure - boot with defaults (e.g. port 8080) ▸ To enable use spring.cloud.config.failFast=true ▸ Enable retries: ▸ Add spring-retry and spring-boot-starter-aop ▸ spring.cloud.config.retry.
  • 31. NETFLIX OSS + SPRING SPRING CLOUD NETFLIX ▸ Service discovery (Eureka) ▸ Client side load balancing (Ribbon) ▸ Dynamic routing (Zuul) ▸ Circuit breaker (Hystrix) ▸ + a few others…
  • 32. NETFLIX OSS + SPRING EUREKA ▸ Service discovery client & server ▸ Maintains registry of clients with metadata ▸ Host/port ▸ Health indicator URL ▸ Client heartbeats (30 sec default - changing not encouraged) ▸ Lease renewed with server ▸ Service available when client & server(s) metadata cache all in sync ▸ Can take up to 3 heart beats
  • 33. NETFLIX OSS + SPRING EUREKA SERVER
  • 34. NETFLIX OSS + SPRING EUREKA SERVER DASHBOARD
  • 35. NETFLIX OSS + SPRING EUREKA CLIENT SETUP @EnableEurekaClient annotation application.yml in Config Server repo
  • 36. NETFLIX OSS + SPRING RIBBON ▸ Client side loan balancer ▸ Can delegate to Eureka for server lists ▸ Or list servers ▸ stores.ribbon.listOfServers=… + ribbon.eureka.enabled=false
  • 37. NETFLIX OSS + SPRING RIBBON USAGE ▸ Via RestTemplate ▸ No different to normal usage - Spring Cloud Commons abstraction ▸ Qualifier’s required if using regular & Ribbon enabled RestTemplate
  • 38. NETFLIX OSS + SPRING ZUUL ▸ JVM based router & load balancer ▸ Provides single point of entry to services ▸ Including single point of authentication ▸ By default creates route for every service in Eureka ▸ Refer to http://localhost/credit-service routes to http://credit- service ▸ Filters provide limited entry points to system
  • 39. NETFLIX OSS + SPRING ZUUL SERVER CREATION ‣ Include dependency spring-cloud-starter-zuul ‣ @EnableZuulProxy application annotation ‣ E.g. Allow access only to credit-service
  • 40. NETFLIX OSS + SPRING SIDECAR ▸ Non-JVM access to components via Zuul proxy ▸ Setup Spring Boot application with @EnableSidecar ▸ Configure for your service: ▸ sidecar.port=… + sidecar.health-ui=… ▸ Access all services by Zuul URL (Sidecar running on port 80) ▸ http://localhost/config-server
  • 41. NETFLIX OSS + SPRING HYSTRIX ▸ Circuit breaker ▸ Threshold breached (20 failures in 5 seconds) => breaker kicks in ▸ Default timeout threshold 1 second ▸ Per dependency thread pools ▸ Async command support (not Spring @Async) ▸ Sync or async fallback
  • 42. NETFLIX OSS + SPRING HYSTRIX CLIENT ▸ @EnableCircuitBreaker application annotation ▸ @HystrixCommand on applicable methods
  • 43. NETFLIX OSS + SPRING
  • 44. NETFLIX OSS + SPRING HYSTRIX STREAM - PRE-REQUESTS
  • 45. NETFLIX OSS + SPRING HYSTRIX STREAM - POST-REQUESTS
  • 46. NETFLIX OSS + SPRING HYSTRIX DASHBOARD
  • 47. NETFLIX OSS + SPRING HYSTRIX STREAM
  • 48. NETFLIX OSS + SPRING HYSTRIX DASHBOARD
  • 49. NETFLIX OSS + SPRING TURBINE - AGGREGATE MULTIPLE HYSTRIX CLIENTS
  • 50. NETFLIX OSS + SPRING MONITORING ▸ Add dependency spring-boot-actuator ▸ Makes available various application metrics via /metrics endpoint ▸ Integration also available with DropWizard metrics (add dependency) ▸ Spring Cloud ▸ Spectator (supersedes Servo) - metrics collection ▸ Atlas - metrics backend
  • 51. NETFLIX OSS + SPRING
  • 52. NETFLIX OSS + SPRING LOGGING ▸ Logback is the default choice ▸ Alternative starters are provided ▸ Using alternatives (such as log4j2) requires exclusions throughout the starter POMs
  • 53. NETFLIX OSS + SPRING DOWNSIDES ▸ A lot of magic - e.g. CORS filters ▸ ADD (Annotation driven development) ▸ Dependency management ▸ RestTemplates - Ribbon enabled != Standard HTTP ▸ Lack of proper polygot support - libraries are in Java (Sidecar is OK as a middle ground) ▸ Spring Hystrix documentation is pretty light
  • 54. NETFLIX OSS + SPRING ALTHOUGH…
  • 55. NETFLIX OSS + SPRING RESOURCES ▸ Spring Cloud documentation - http://projects.spring.io/spring-cloud/spring-cloud.html ▸ Spring Boot sample projects - https://github.com/spring-projects/spring-boot/tree/ master/spring-boot-samples ▸ Spring Cloud sample projects - https://github.com/spring-cloud-samples ▸ Hystrix annotations - https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/ hystrix-javanica ▸ Useful demonstration of Spring Cloud usage - http://callistaenterprise.se/blogg/teknik/ 2015/05/20/blog-series-building-microservices/ ▸ Spring project dependency selector - http://start.spring.io/ ▸ Code to accompany this talk - https://github.com/conor10/homeloans ▸ https://www.huffle.com.au
  • 56. NETFLIX OSS + SPRING THANKS conor@huffle.com.au