SlideShare a Scribd company logo
Micro-Services Stack
Spring Cloud vs. Docker
Micro-Services
• Micro-services are the current architectural trend.
• We need to deal with:
• Discovery.
• Configuration.
• Load-balancing.
• Security.
• High-Availability.
• Monitoring.
• Scheduling.
The Infrastructure
• Many of these concerns can be dealt by either the application
framework (e.g., Spring Cloud) or the infrastructure (Docker
Swarm/K8S).
• Let’s review both and compare them…
Docker
• Docker provides:
• Decent isolation.
• Evolution.
• Distribution (e.g., Swarm, Kubernetes).
• Fast start time.
• Shared resources.
Docker
• Docker is a lightweight container.
• Useful for deploying and running an application/ service/ micro-
service with its environment.
• You can run your packaged application on production server,
staging server, development machine or even a laptop.
Spring Cloud
Spring Cloud provides tools for developers to quickly
build some of the common patterns in distributed
systems (e.g., configuration management, service
discovery, circuit breakers, etc.) http://projects.spring.io/spring-cloud/
Spring Cloud
• Based on Spring Boot.
• An umbrella project for many other e.g., Spring Cloud Config,
Spring Cloud Netflix, Spring Cloud Security, Spring Cloud AWS
and more.
• Allows relatively easy implementation of distributed
architecture (micro services) design patterns and usecases.
Spring Cloud Netflix
• Netflix OSS integration:
• Eureka – Service Discovery.
• Hystrix – Circuit Breaker.
• Zuul – Routing.
• Ribbon – client-side load balancing.
Configuration Management
• Swarm provides only Secrets.
• K8S provides both Secrets and ConfigMaps.
• Spring provides Config Server.
• E.g.:
@SpringBootApplication
@EnableConfigServer
public class ConfigServer {
public static void main(String[] args) {
SpringApplication.run(ConfigServer.class, args);
}
}
Config Server
• Default backend is Git repository.
• Great for upgrades and auditing.
• Can also use the Vault project for storing secrets.
• Spring Cloud clients can easily benefit from the Config Server.
• There is also Archaius by Netflix which provides dynamic
configuration changes to be pushed to the clients.
Service Discovery
• Swarm and Kubernetes provide Service components which
serve both as load-balancers and service discovery (DNS).
• Spring Cloud provides Eureka & Consul for discovery and
Ribbon for load balancing.
Service Discovery
• Starting a Eureka service is easy:
@SpringBootApplication
@EnableEurekaServer
public class Application {
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args);
}
}
Service Discovery
• On the client side (the micro-services) you just enable Eureka
client: @EnableEurekaClient (and provide configuration).
• Out-of-the-box support for health indicator (/health) and status
url (/info).
• You can also use DiscoveryClient to search for other micro-
services.
Load Balancing
• Spring Cloud provides Ribbon and Feign to get a client-side
load balancer for your services.
• K8S and Swarm provide strong support for server-side load
balancing!
• Based on health-check.
Health Check
• Sometimes something can go wrong (and it will).
• E.g.,
• VM crash (memory, disk or power).
• Application is hung (GC, bug).
• JVM crashes (OOME, Stack overflow).
• A service is unusable (can’t connect to the DB).
• First we need to know about it and then (maybe) take an action.
Possible Actions
• The most common action we’ll want to perform is some kind of
service restart.
• Sometimes we’ll just want to exclude the service from the load-
balancer (temporary problem).
• Rarely, we’ll want to invoke some specific API of the service.
Basic Mechanism
• Docker is bundled with a basic and simple mechanism, the
entrypoint.
• A special process in the container, that when exit, stops the
container.
• An easy way for errors like OOME!
• However, usually it’s not enough.
Health Check (Docker)
• Docker provides the HEALTHCHECK instruction for the
dockerfile.
• You can provide a command that will be invoked inside the
container and by its exit code (0 for success) will determine if
the container is healthy or not.
• You can control the interval, timeout and retries of the check.
Swarm
• Swarm services only load-balance to healthy containers (need
at least a single successful health-check).
• An unhealthy container will be restarted (another instance).
• There is no out-of-box support yet for other actions.
Kubernetes
• Kubernetes ignores the HEALTHCHECK instruction.
• Instead, each Pod can be configured with two kinds of probes:
• Liveness – a command or HTTP request to check if the container is
alive (dead containers will be restarted).
• Readiness – a command or HTTP request to check if the container is
ready (unready containers will not belong to the load-balancer).
Health-check in Spring Cloud
• Can use Spring Actuator (from Spring Boot) for built-in “/health”
URL.
• Combining both Spring Boot and Docker support can be very
useful!
Hystrix
• Provides a circuit breaker pattern implementation.
• What is a circuit breaker?
Circuit Breaker
• Let’s say we fail to connect to some service (request will
timeout).
• Usually the problem will take some time to fix.
• In the meanwhile our service might crash (especially when
we’re under load and there’s no pushback).
• Circuit breaker to the rescue…
Circuit Breaker
• Can be in 3 states:
• Closed – normal work.
• Open – will not forward calls to the failing service. Works with a
fallback.
• Half-Open – a single invocation will continue to the failing service to
check the status.
Hystrix
• Supports:
• Fallbacks.
• Dashboard.
Discussion
• With Docker, you have a language-independent solution!
• With Spring Cloud you only get JVM-based support.
• Docker-based solutions make deployment extremely easy.
Discussion
• Spring Cloud make client-side solutions (e.g., Hystrix & Ribbon)
extremely powerful.
• Combining both (Spring Cloud on Swarm/K8S) works great.
Discussion
• Current trends lead into K8S/Swarm cluster management.
• For managing:
• Cluster Resilience.
• Scale.
• Server-side Load Balancing.
• Secrets.
• Jobs.
Discussion
• So, where does it leave use regarding Spring services?
• We can still benefit from:
• Hystrix.
• Config Server.
• Internal application framework.
Alternatives
• Spring Cloud is not the only possible application framework
solution.
• Lightbend’s Lagom can also be considered.
• Combines:
• Akka + Play.
• Cassandra.
Akka Cluster
• Can provide:
• Client-side load-balancing.
• Scaling.
• Persistence.
• Sharding.
• Cluster-wide singleton.
• Event bus.

More Related Content

What's hot (20)

PDF
Scala, Akka, and Play: An Introduction on Heroku
Havoc Pennington
 
PPTX
Developing distributed applications with Akka and Akka Cluster
Konstantin Tsykulenko
 
PPTX
Akka Actor presentation
Gene Chang
 
PDF
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Jonas Bonér
 
KEY
Building Distributed Systems in Scala
Alex Payne
 
PDF
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Lightbend
 
PPTX
Real-time streaming and data pipelines with Apache Kafka
Joe Stein
 
PDF
Reactive Streams: Handling Data-Flow the Reactive Way
Roland Kuhn
 
PDF
Introduction to akka actors with java 8
Johan Andrén
 
PDF
Akka Cluster in Production
bilyushonak
 
PPTX
Zoo keeper in the wild
datamantra
 
PDF
Akka Http , Routes, Streams with Scala
Jerry Kuru
 
PDF
Building stateful systems with akka cluster sharding
Knoldus Inc.
 
PDF
Lightbend Lagom: Microservices Just Right
mircodotta
 
PDF
PaaSTA: Autoscaling at Yelp
Nathan Handler
 
PDF
Reactive Streams 1.0 and Akka Streams
Dean Wampler
 
PDF
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Lightbend
 
PDF
Spring Boot Microservices vs Akka Actor Cluster
OpenCredo
 
ODP
Introduction to Apache Kafka- Part 2
Knoldus Inc.
 
PDF
Reactor, Reactive streams and MicroServices
Stéphane Maldini
 
Scala, Akka, and Play: An Introduction on Heroku
Havoc Pennington
 
Developing distributed applications with Akka and Akka Cluster
Konstantin Tsykulenko
 
Akka Actor presentation
Gene Chang
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Jonas Bonér
 
Building Distributed Systems in Scala
Alex Payne
 
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Lightbend
 
Real-time streaming and data pipelines with Apache Kafka
Joe Stein
 
Reactive Streams: Handling Data-Flow the Reactive Way
Roland Kuhn
 
Introduction to akka actors with java 8
Johan Andrén
 
Akka Cluster in Production
bilyushonak
 
Zoo keeper in the wild
datamantra
 
Akka Http , Routes, Streams with Scala
Jerry Kuru
 
Building stateful systems with akka cluster sharding
Knoldus Inc.
 
Lightbend Lagom: Microservices Just Right
mircodotta
 
PaaSTA: Autoscaling at Yelp
Nathan Handler
 
Reactive Streams 1.0 and Akka Streams
Dean Wampler
 
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Lightbend
 
Spring Boot Microservices vs Akka Actor Cluster
OpenCredo
 
Introduction to Apache Kafka- Part 2
Knoldus Inc.
 
Reactor, Reactive streams and MicroServices
Stéphane Maldini
 

Similar to Implementing Micro Services Tasks (service discovery, load balancing etc.) - Infrastructure (Docker) vs applicative (Spring Cloud) (20)

PDF
Spring cloud
Milan Ashara
 
PDF
Resilient Microservices with Spring Cloud
VMware Tanzu
 
PPTX
Microservices, Spring Cloud & Cloud Foundry
Emilio Garcia
 
PDF
Микросервисы со Spring Boot & Spring Cloud
Vitebsk DSC
 
PDF
Spring Cloud: Why? How? What?
Orkhan Gasimov
 
ODP
Microservices Patterns and Anti-Patterns
Corneil du Plessis
 
PPTX
Microservices deck
Raja Chattopadhyay
 
PPTX
Microservices pros and cons dark
Andrew Siemer
 
ODP
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
PPTX
Kubernetes + netflix oss
Cristiano Altmann
 
PDF
Containerising bootiful microservices javaeeconf
Ivan Vasyliev
 
PPTX
Microservices with kubernetes @190316
Jupil Hwang
 
PDF
SpringBoot and Spring Cloud Service for MSA
Oracle Korea
 
PPT
JDD 2016 - Jacek Bukowski - "Flying To Clouds" - Can It Be Easy?
PROIDEA
 
PPT
Flying to clouds - can it be easy? Cloud Native Applications
Jacek Bukowski
 
PDF
Microservices - not just with Java
Eberhard Wolff
 
PPTX
Microservices with Spring
Carlos Cavero Barca
 
ODP
Spring cloud for microservices architecture
Igor Khotin
 
PDF
Getting started with Spring Cloud - Dave Syer
JAXLondon_Conference
 
PPTX
A docker love story
Brian de Heus
 
Spring cloud
Milan Ashara
 
Resilient Microservices with Spring Cloud
VMware Tanzu
 
Microservices, Spring Cloud & Cloud Foundry
Emilio Garcia
 
Микросервисы со Spring Boot & Spring Cloud
Vitebsk DSC
 
Spring Cloud: Why? How? What?
Orkhan Gasimov
 
Microservices Patterns and Anti-Patterns
Corneil du Plessis
 
Microservices deck
Raja Chattopadhyay
 
Microservices pros and cons dark
Andrew Siemer
 
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
Kubernetes + netflix oss
Cristiano Altmann
 
Containerising bootiful microservices javaeeconf
Ivan Vasyliev
 
Microservices with kubernetes @190316
Jupil Hwang
 
SpringBoot and Spring Cloud Service for MSA
Oracle Korea
 
JDD 2016 - Jacek Bukowski - "Flying To Clouds" - Can It Be Easy?
PROIDEA
 
Flying to clouds - can it be easy? Cloud Native Applications
Jacek Bukowski
 
Microservices - not just with Java
Eberhard Wolff
 
Microservices with Spring
Carlos Cavero Barca
 
Spring cloud for microservices architecture
Igor Khotin
 
Getting started with Spring Cloud - Dave Syer
JAXLondon_Conference
 
A docker love story
Brian de Heus
 
Ad

Recently uploaded (20)

PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Ad

Implementing Micro Services Tasks (service discovery, load balancing etc.) - Infrastructure (Docker) vs applicative (Spring Cloud)

  • 2. Micro-Services • Micro-services are the current architectural trend. • We need to deal with: • Discovery. • Configuration. • Load-balancing. • Security. • High-Availability. • Monitoring. • Scheduling.
  • 3. The Infrastructure • Many of these concerns can be dealt by either the application framework (e.g., Spring Cloud) or the infrastructure (Docker Swarm/K8S). • Let’s review both and compare them…
  • 4. Docker • Docker provides: • Decent isolation. • Evolution. • Distribution (e.g., Swarm, Kubernetes). • Fast start time. • Shared resources.
  • 5. Docker • Docker is a lightweight container. • Useful for deploying and running an application/ service/ micro- service with its environment. • You can run your packaged application on production server, staging server, development machine or even a laptop.
  • 6. Spring Cloud Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g., configuration management, service discovery, circuit breakers, etc.) http://projects.spring.io/spring-cloud/
  • 7. Spring Cloud • Based on Spring Boot. • An umbrella project for many other e.g., Spring Cloud Config, Spring Cloud Netflix, Spring Cloud Security, Spring Cloud AWS and more. • Allows relatively easy implementation of distributed architecture (micro services) design patterns and usecases.
  • 8. Spring Cloud Netflix • Netflix OSS integration: • Eureka – Service Discovery. • Hystrix – Circuit Breaker. • Zuul – Routing. • Ribbon – client-side load balancing.
  • 9. Configuration Management • Swarm provides only Secrets. • K8S provides both Secrets and ConfigMaps. • Spring provides Config Server. • E.g.: @SpringBootApplication @EnableConfigServer public class ConfigServer { public static void main(String[] args) { SpringApplication.run(ConfigServer.class, args); } }
  • 10. Config Server • Default backend is Git repository. • Great for upgrades and auditing. • Can also use the Vault project for storing secrets. • Spring Cloud clients can easily benefit from the Config Server. • There is also Archaius by Netflix which provides dynamic configuration changes to be pushed to the clients.
  • 11. Service Discovery • Swarm and Kubernetes provide Service components which serve both as load-balancers and service discovery (DNS). • Spring Cloud provides Eureka & Consul for discovery and Ribbon for load balancing.
  • 12. Service Discovery • Starting a Eureka service is easy: @SpringBootApplication @EnableEurekaServer public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); } }
  • 13. Service Discovery • On the client side (the micro-services) you just enable Eureka client: @EnableEurekaClient (and provide configuration). • Out-of-the-box support for health indicator (/health) and status url (/info). • You can also use DiscoveryClient to search for other micro- services.
  • 14. Load Balancing • Spring Cloud provides Ribbon and Feign to get a client-side load balancer for your services. • K8S and Swarm provide strong support for server-side load balancing! • Based on health-check.
  • 15. Health Check • Sometimes something can go wrong (and it will). • E.g., • VM crash (memory, disk or power). • Application is hung (GC, bug). • JVM crashes (OOME, Stack overflow). • A service is unusable (can’t connect to the DB). • First we need to know about it and then (maybe) take an action.
  • 16. Possible Actions • The most common action we’ll want to perform is some kind of service restart. • Sometimes we’ll just want to exclude the service from the load- balancer (temporary problem). • Rarely, we’ll want to invoke some specific API of the service.
  • 17. Basic Mechanism • Docker is bundled with a basic and simple mechanism, the entrypoint. • A special process in the container, that when exit, stops the container. • An easy way for errors like OOME! • However, usually it’s not enough.
  • 18. Health Check (Docker) • Docker provides the HEALTHCHECK instruction for the dockerfile. • You can provide a command that will be invoked inside the container and by its exit code (0 for success) will determine if the container is healthy or not. • You can control the interval, timeout and retries of the check.
  • 19. Swarm • Swarm services only load-balance to healthy containers (need at least a single successful health-check). • An unhealthy container will be restarted (another instance). • There is no out-of-box support yet for other actions.
  • 20. Kubernetes • Kubernetes ignores the HEALTHCHECK instruction. • Instead, each Pod can be configured with two kinds of probes: • Liveness – a command or HTTP request to check if the container is alive (dead containers will be restarted). • Readiness – a command or HTTP request to check if the container is ready (unready containers will not belong to the load-balancer).
  • 21. Health-check in Spring Cloud • Can use Spring Actuator (from Spring Boot) for built-in “/health” URL. • Combining both Spring Boot and Docker support can be very useful!
  • 22. Hystrix • Provides a circuit breaker pattern implementation. • What is a circuit breaker?
  • 23. Circuit Breaker • Let’s say we fail to connect to some service (request will timeout). • Usually the problem will take some time to fix. • In the meanwhile our service might crash (especially when we’re under load and there’s no pushback). • Circuit breaker to the rescue…
  • 24. Circuit Breaker • Can be in 3 states: • Closed – normal work. • Open – will not forward calls to the failing service. Works with a fallback. • Half-Open – a single invocation will continue to the failing service to check the status.
  • 26. Discussion • With Docker, you have a language-independent solution! • With Spring Cloud you only get JVM-based support. • Docker-based solutions make deployment extremely easy.
  • 27. Discussion • Spring Cloud make client-side solutions (e.g., Hystrix & Ribbon) extremely powerful. • Combining both (Spring Cloud on Swarm/K8S) works great.
  • 28. Discussion • Current trends lead into K8S/Swarm cluster management. • For managing: • Cluster Resilience. • Scale. • Server-side Load Balancing. • Secrets. • Jobs.
  • 29. Discussion • So, where does it leave use regarding Spring services? • We can still benefit from: • Hystrix. • Config Server. • Internal application framework.
  • 30. Alternatives • Spring Cloud is not the only possible application framework solution. • Lightbend’s Lagom can also be considered. • Combines: • Akka + Play. • Cassandra.
  • 31. Akka Cluster • Can provide: • Client-side load-balancing. • Scaling. • Persistence. • Sharding. • Cluster-wide singleton. • Event bus.