SlideShare a Scribd company logo
1 of 67
Download to read offline
Microservices
with

Spring Boot &
Spring Cloud
Eberhard Wolff
Freelancer / Trainer
What are
Microservices?
Eberhard Wolff - @ewolff
Micro Services: Definition
•  Small
•  Independent deployment units
•  i.e. processes or VMs
•  Any technology
•  Any infrastructure
•  Include GUI
Micro
Service
Server
Micro
Service
Server
Eberhard Wolff - @ewolff
Components Collaborate
Micro
Service
Micro
Service
Link
Data Replication
REST
Messaging
Eberhard Wolff - @ewolff
Infrastructure for
Microservices
•  Lots of services
•  Need infrastructure
Easy to create a new project
REST integrated
Messaging supported
Uniform operations
Spring Boot
Demo
Eberhard Wolff - @ewolff
Easy to Create New Project
•  One pom.xml
•  …Gradle / Ant
•  Very few dependencies
•  One plug in
•  Versions defined for you
Eberhard Wolff - @ewolff
REST Integrated
•  Support in Spring MVC
•  As we have seen
•  Also support for JAX-RS
•  Jersey
Eberhard Wolff - @ewolff
Messaging Support
•  Numerous Spring Boot Starter
•  AMQP (RabbitMQ)
•  HornetQ (JMS)
•  ActiveMQ (JMS, no starter)
Eberhard Wolff - @ewolff
Messaging Support
•  Spring JMS abstraction
•  Message driven POJOs
•  Scalable
•  Simplify sending JMS
•  Can use other libs, too!
•  Boot can do everything plain Spring /
Java can do
Eberhard Wolff - @ewolff
Infrastructure for
Microservices
•  More services
•  Need infrastructure
Easy to create a new project
REST integrated
Messaging supported
Simple deployment
Uniform operations
✓
✓
✓
Spring Boot

Deploy Demo
Eberhard Wolff - @ewolff
Deploy
•  Just package everything in an
executable JAR
•  …or a WAR
•  Based on Maven, Ant or Gradle
•  Build in configuration (YAML,
properties etc.)
Eberhard Wolff - @ewolff
Deploy
•  Install a basic machine
•  Install Java
•  Copy over .jar
•  Optional: Create application.properties
Eberhard Wolff - @ewolff
Infrastructure for
Microservices
•  More services
•  Need infrastructure
Easy to create a new project
REST integrated
Messaging supported
Simple deployment
Uniform operations
✓
✓
✓
✓
Eberhard Wolff - @ewolff
Spring Boot Actuator
•  Provide information about the
application
•  Via http / JSON
•  Can be evaluated by monitoring
tools etc.
•  Another alternative approach to
monitoring
Spring Boot

Actuator
Demo
Eberhard Wolff - @ewolff
Infrastructure for
Microservices
•  More services
•  Need infrastructure
Easy to create a new project
REST integrated
Messaging supported
Simple deployment
Uniform operations
✓
✓
✓
✓
✓
Eberhard Wolff - @ewolff
Deploy
•  Just package everything in an
executable JAR
Eberhard Wolff - @ewolff
Deploy
•  Just package everything in an
executable JAR
•  …or a WAR
Eberhard Wolff - @ewolff
Spring Cloud
Eberhard Wolff - @ewolff
Based on
Spring Boot
Eberhard Wolff - @ewolff
Spring Cloud
•  Spring support for Amazon Web
Services
•  Connector for Heroku PaaS
•  …and Cloud Foundry PaaS
•  The rest of Spring Cloud is for
Microservices
Eberhard Wolff - @ewolff
Coordinating

Microservices
Eberhard Wolff - @ewolff
Microservice Microservice
Must find each other
Eberhard Wolff - @ewolff
Service
Discovery

Eureka
Eberhard Wolff - @ewolff
Why Eureka?
•  REST based service registry
•  Supports replication
•  Caches on the client
•  Resilient
•  Fast
•  …but not consistent
•  Foundation for other services
Eberhard Wolff - @ewolff
Eureka Client in Spring Cloud
•  @EnableDiscoveryClient:
generic
•  @EnableEurekaClient:
more specific
•  Dependency to
spring-cloud-starter-eureka
•  Automatically registers application
Eberhard Wolff - @ewolff
application.properties
eureka.client.serviceUrl.defaultZone=http://host:
8761/eureka/<
eureka.instance.leaseRenewalIntervalInSeconds=5<
spring.application.name=catalog<
eureka.instance.metadataMap.instanceId=$
{spring.application.name}:${random.value}<
eureka.instance.preferIpAddress=true<
Eureka server
Can include user / password
Need unique ID
Load balancing
Faster updates
Docker won’t resolve host names
Used for registration
In CAPITAL caps
Eberhard Wolff - @ewolff
Eureka Server
@EnableEurekaServer<
@EnableAutoConfiguration<
public'class'EurekaApplication'{'
<
<public'static'void'main(String[]'args)'{'
<<SpringApplication.run(EurekaApplication.class,'args);'
<}<
<
}<
Add dependency to
spring-cloud-starter-eureka-server
Eberhard Wolff - @ewolff
Eberhard Wolff - @ewolff
Eureka

Demo
Eberhard Wolff - @ewolff
Microservice Microservice
Must find each other
Route calls to a service
Eberhard Wolff - @ewolff
Zuul

Routing
Eberhard Wolff - @ewolff
Routing
•  One URL to the outside
•  Internal: Many Microservices
•  REST
•  Or HTML GUI
Eberhard Wolff - @ewolff
Customer Order Catalog
Zuul
Proxy
Automatically maps route to server registered on Eureka
i.e. /customer/**
to CUSTOMER
No configuration
Can add filters etc
Eberhard Wolff - @ewolff
Zuul Proxy
@SpringBootApplication
@EnableZuulProxy
public class ZuulApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ZuulApplication.class).
web(true).run(args);
}
}
Enable Zuul Proxy
Can change route
Also routing to external services possible
Eberhard Wolff - @ewolff
lokaler Rechner
Vagrant VM
eureka zuul
customer
-app
catalog-
app
order-app
172.17.0.0/16 Netzwerk
8761
8761
8080
8080
18761 18080
Eberhard Wolff - @ewolff
Zuul

Demo
Eberhard Wolff - @ewolff
Microservice Microservice
Must find each other
Configuration
Route calls to a service
Eberhard Wolff - @ewolff
Configuration
•  Spring Cloud Config
•  Central configuration
•  Dynamic updates
•  Can use git backend
•  I prefer immutable server
•  & DevOps tools (Docher, Chef…)
Eberhard Wolff - @ewolff
Microservice Microservice
Must find each other
Configuration
Route calls to a service
Communication
Eberhard Wolff - @ewolff
Spring Cloud
Bus
Eberhard Wolff - @ewolff
Spring Cloud Bus
•  Pushed config updates
•  …or individual message
•  I prefer a messaging solution
•  Independent from Spring
Eberhard Wolff - @ewolff
Microservice Microservice
Must find each other
Configuration
Route calls to a service
Communication
Security
Eberhard Wolff - @ewolff
Spring Cloud
Security
Eberhard Wolff - @ewolff
Spring Cloud Security
•  Single Sign On via OAuth2
•  Forward token e.g. via
RestTemplate
•  Support for Zuul
•  Very valuable!
Eberhard Wolff - @ewolff
Implementing

Microservices
Eberhard Wolff - @ewolff
Microservice Microservice
Load Balancing
Eberhard Wolff - @ewolff
Load
Balancing

Ribbon
Eberhard Wolff - @ewolff
Ribbon: Client Side Load
Balancing
•  Decentralized Load Balancing
•  No bottle neck
•  Resilient
•  Hard to consider metrics / health
•  Data might be inconsistent
Load
Balancer
Server
Client
Eberhard Wolff - @ewolff
RestTemplate & Load
Balancing
@RibbonClient(name = "ribbonApp")
…
public class RibbonApp {
@Autowired
private RestTemplate restTemplate;
public void callMicroService() {
Store store = restTemplate.
getForObject("http://stores/store/1",
Store.class);
}
}
Enable Ribbon
Left out other annotations
Eureka name or server list
Standard Spring
REST client
Can also use Ribbon API
Eberhard Wolff - @ewolff
Microservice Microservice
Load Balancing
Resilience
Eberhard Wolff - @ewolff
Hystrix

Resilience
Eberhard Wolff - @ewolff
Hystrix
•  Enable resilient applications
•  Do call in other thread pool
•  Won’t block request handler
•  Can implement timeout
Eberhard Wolff - @ewolff
Hystrix
•  Circuit Breaker
•  If call system fail open
•  If open do not forward call
•  Forward calls after a time window
•  System won’t be swamped with
requests
Eberhard Wolff - @ewolff
Hystrix / Spring Cloud
•  Annotation based approach
•  Java Proxies automatically created
•  Annotations of javanica libraries
•  Simplifies Hystrix dramatically
•  No commands etc
Eberhard Wolff - @ewolff
@HystrixCommand(fallbackMethod = "getItemsCache")
public Collection<Item> findAll() {
…
this.itemsCache = pagedResources.getContent();
return itemsCache;
}
private Collection<Item> getItemsCache() {
return itemsCache;
}<
Fallback
Eberhard Wolff - @ewolff
lokaler Rechner
Vagrant VM
eureka zuul
customer
-app
catalog-
app
order-app
172.17.0.0/16 Netzwerk
8761
8761
8080
8080
18761 18080
Eberhard Wolff - @ewolff
lokaler Rechner
Vagrant VM
eureka zuul
customer
-app
catalog-
app
turbine
order-app
172.17.0.0/16 Netzwerk
8761
8761
8989
8989
8080
8080
18761 18989 18080
Eberhard Wolff - @ewolff
Hystrix Dashboard
Stream via http
Circuit Breaker status
Thread Pool status
Eberhard Wolff - @ewolff
Conclusion
Eberhard Wolff - @ewolff
Spring Boot for Microservices
Easy to create a new project
REST integrated
Messaging supported
Simple deployment
Uniform operations
✓
✓
✓
✓
✓
Eberhard Wolff - @ewolff
Hystrix

Demo
Eberhard Wolff - @ewolff
Must find each other: Service Discovery
Configuration
Route calls to a service
Communication
Load Balancing
Resilience
Spring Cloud for
Microservices
Eberhard Wolff - @ewolff
Links
http://projects.spring.io/spring-boot/
http://projects.spring.io/spring-cloud
https://github.com/ewolff/spring-boot-demos
https://github.com/ewolff/microservices
https://spring.io/guides/
Eberhard Wolff - @ewolff
Thank You!!

More Related Content

What's hot

What's hot (20)

Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Do we need SOLID principles during software development?
Do we need SOLID principles during software development?
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
Microservices Platform with Spring Boot, Spring Cloud Config, Spring Cloud Ne...
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Microservices Design Patterns Explained | Edureka
Microservices Design Patterns Explained | EdurekaMicroservices Design Patterns Explained | Edureka
Microservices Design Patterns Explained | Edureka
 
Microservices Design Patterns | Edureka
Microservices Design Patterns | EdurekaMicroservices Design Patterns | Edureka
Microservices Design Patterns | Edureka
 
Building secure applications with keycloak
Building secure applications with keycloak Building secure applications with keycloak
Building secure applications with keycloak
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing Strategies
 
Microservices architecture overview v3
Microservices architecture overview v3Microservices architecture overview v3
Microservices architecture overview v3
 
Git interview questions | Edureka
Git interview questions | EdurekaGit interview questions | Edureka
Git interview questions | Edureka
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Service discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring CloudService discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring Cloud
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 

Viewers also liked

Spring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsugSpring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsug
Toshiaki Maki
 
Philosophy of Deep Learning
Philosophy of Deep LearningPhilosophy of Deep Learning
Philosophy of Deep Learning
Melanie Swan
 
Exploring Session Context using Distributed Representations of Queries and Re...
Exploring Session Context using Distributed Representations of Queries and Re...Exploring Session Context using Distributed Representations of Queries and Re...
Exploring Session Context using Distributed Representations of Queries and Re...
Bhaskar Mitra
 
Cs231n 2017 lecture11 Detection and Segmentation
Cs231n 2017 lecture11 Detection and SegmentationCs231n 2017 lecture11 Detection and Segmentation
Cs231n 2017 lecture11 Detection and Segmentation
Yanbin Kong
 

Viewers also liked (20)

Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Spring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsugSpring Bootで変わる Javaアプリ開発! #jsug
Spring Bootで変わる Javaアプリ開発! #jsug
 
Venkatesh Duppada - 2017 - SeerNet at EmoInt-2017: Tweet Emotion Intensity Es...
Venkatesh Duppada - 2017 - SeerNet at EmoInt-2017: Tweet Emotion Intensity Es...Venkatesh Duppada - 2017 - SeerNet at EmoInt-2017: Tweet Emotion Intensity Es...
Venkatesh Duppada - 2017 - SeerNet at EmoInt-2017: Tweet Emotion Intensity Es...
 
Matthew Marge - 2017 - Exploring Variation of Natural Human Commands to a Rob...
Matthew Marge - 2017 - Exploring Variation of Natural Human Commands to a Rob...Matthew Marge - 2017 - Exploring Variation of Natural Human Commands to a Rob...
Matthew Marge - 2017 - Exploring Variation of Natural Human Commands to a Rob...
 
Deep Learning for Chatbot (4/4)
Deep Learning for Chatbot (4/4)Deep Learning for Chatbot (4/4)
Deep Learning for Chatbot (4/4)
 
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
 
Technological Unemployment and the Robo-Economy
Technological Unemployment and the Robo-EconomyTechnological Unemployment and the Robo-Economy
Technological Unemployment and the Robo-Economy
 
Blockchain Economic Theory
Blockchain Economic TheoryBlockchain Economic Theory
Blockchain Economic Theory
 
Cs231n 2017 lecture10 Recurrent Neural Networks
Cs231n 2017 lecture10 Recurrent Neural NetworksCs231n 2017 lecture10 Recurrent Neural Networks
Cs231n 2017 lecture10 Recurrent Neural Networks
 
Satoshi Sonoh - 2015 - Toshiba MT System Description for the WAT2015 Workshop
Satoshi Sonoh - 2015 - Toshiba MT System Description for the WAT2015 WorkshopSatoshi Sonoh - 2015 - Toshiba MT System Description for the WAT2015 Workshop
Satoshi Sonoh - 2015 - Toshiba MT System Description for the WAT2015 Workshop
 
Roee Aharoni - 2017 - Towards String-to-Tree Neural Machine Translation
Roee Aharoni - 2017 - Towards String-to-Tree Neural Machine TranslationRoee Aharoni - 2017 - Towards String-to-Tree Neural Machine Translation
Roee Aharoni - 2017 - Towards String-to-Tree Neural Machine Translation
 
Philosophy of Deep Learning
Philosophy of Deep LearningPhilosophy of Deep Learning
Philosophy of Deep Learning
 
Hackathon 2014 NLP Hack
Hackathon 2014 NLP HackHackathon 2014 NLP Hack
Hackathon 2014 NLP Hack
 
State of Blockchain 2017: Smartnetworks and the Blockchain Economy
State of Blockchain 2017:  Smartnetworks and the Blockchain EconomyState of Blockchain 2017:  Smartnetworks and the Blockchain Economy
State of Blockchain 2017: Smartnetworks and the Blockchain Economy
 
Deep Learning in practice : Speech recognition and beyond - Meetup
Deep Learning in practice : Speech recognition and beyond - MeetupDeep Learning in practice : Speech recognition and beyond - Meetup
Deep Learning in practice : Speech recognition and beyond - Meetup
 
Recommender Systems, Matrices and Graphs
Recommender Systems, Matrices and GraphsRecommender Systems, Matrices and Graphs
Recommender Systems, Matrices and Graphs
 
Exploring Session Context using Distributed Representations of Queries and Re...
Exploring Session Context using Distributed Representations of Queries and Re...Exploring Session Context using Distributed Representations of Queries and Re...
Exploring Session Context using Distributed Representations of Queries and Re...
 
Cs231n 2017 lecture11 Detection and Segmentation
Cs231n 2017 lecture11 Detection and SegmentationCs231n 2017 lecture11 Detection and Segmentation
Cs231n 2017 lecture11 Detection and Segmentation
 

Similar to Microservice With Spring Boot and Spring Cloud

Amazon Elastic Beanstalk
Amazon Elastic BeanstalkAmazon Elastic Beanstalk
Amazon Elastic Beanstalk
Eberhard Wolff
 

Similar to Microservice With Spring Boot and Spring Cloud (20)

Micro Services - Small is Beautiful
Micro Services - Small is BeautifulMicro Services - Small is Beautiful
Micro Services - Small is Beautiful
 
Micro Service – The New Architecture Paradigm
Micro Service – The New Architecture ParadigmMicro Service – The New Architecture Paradigm
Micro Service – The New Architecture Paradigm
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Java Application Servers Are Dead!
Java Application Servers Are Dead!Java Application Servers Are Dead!
Java Application Servers Are Dead!
 
Microservice - All is Small, All is Well?
Microservice - All is Small, All is Well?Microservice - All is Small, All is Well?
Microservice - All is Small, All is Well?
 
Software Architecture for DevOps and Continuous Delivery
Software Architecture for DevOps and Continuous DeliverySoftware Architecture for DevOps and Continuous Delivery
Software Architecture for DevOps and Continuous Delivery
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Java Architectures - a New Hope
Java Architectures - a New HopeJava Architectures - a New Hope
Java Architectures - a New Hope
 
Continuous Delivery and Micro Services - A Symbiosis
Continuous Delivery and Micro Services - A SymbiosisContinuous Delivery and Micro Services - A Symbiosis
Continuous Delivery and Micro Services - A Symbiosis
 
Micro Services - Smaller is Better?
Micro Services - Smaller is Better?Micro Services - Smaller is Better?
Micro Services - Smaller is Better?
 
Micro Services - Neither Micro Nor Service
Micro Services - Neither Micro Nor ServiceMicro Services - Neither Micro Nor Service
Micro Services - Neither Micro Nor Service
 
Java Application Servers Are Dead! - Short Version
Java Application Servers Are Dead! - Short VersionJava Application Servers Are Dead! - Short Version
Java Application Servers Are Dead! - Short Version
 
Legacy Sins
Legacy SinsLegacy Sins
Legacy Sins
 
High Availability and Scalability: Too Expensive! Architectures for Future E...
High Availability and Scalability: Too Expensive! Architectures for Future E...High Availability and Scalability: Too Expensive! Architectures for Future E...
High Availability and Scalability: Too Expensive! Architectures for Future E...
 
Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?
 
NoSQL Riak MongoDB Elasticsearch - All The Same?
NoSQL Riak MongoDB Elasticsearch - All The Same?NoSQL Riak MongoDB Elasticsearch - All The Same?
NoSQL Riak MongoDB Elasticsearch - All The Same?
 
Continuous Delivery & DevOps in the Enterprise
Continuous Delivery & DevOps in the EnterpriseContinuous Delivery & DevOps in the Enterprise
Continuous Delivery & DevOps in the Enterprise
 
Amazon Elastic Beanstalk
Amazon Elastic BeanstalkAmazon Elastic Beanstalk
Amazon Elastic Beanstalk
 
Heroku
HerokuHeroku
Heroku
 
NoSQL and Architectures
NoSQL and ArchitecturesNoSQL and Architectures
NoSQL and Architectures
 

More from Eberhard Wolff

More from Eberhard Wolff (20)

Architectures and Alternatives
Architectures and AlternativesArchitectures and Alternatives
Architectures and Alternatives
 
Beyond Microservices
Beyond MicroservicesBeyond Microservices
Beyond Microservices
 
The Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryThe Frontiers of Continuous Delivery
The Frontiers of Continuous Delivery
 
Four Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncFour Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, Async
 
Microservices - not just with Java
Microservices - not just with JavaMicroservices - not just with Java
Microservices - not just with Java
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!
 
Data Architecture not Just for Microservices
Data Architecture not Just for MicroservicesData Architecture not Just for Microservices
Data Architecture not Just for Microservices
 
How to Split Your System into Microservices
How to Split Your System into MicroservicesHow to Split Your System into Microservices
How to Split Your System into Microservices
 
Microservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileMicroservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale Agile
 
How Small Can Java Microservices Be?
How Small Can Java Microservices Be?How Small Can Java Microservices Be?
How Small Can Java Microservices Be?
 
Data Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesData Architecturen Not Just for Microservices
Data Architecturen Not Just for Microservices
 
Microservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityMicroservices: Redundancy=Maintainability
Microservices: Redundancy=Maintainability
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to Microservices
 
Microservices Technology Stack
Microservices Technology StackMicroservices Technology Stack
Microservices Technology Stack
 
Software Architecture for Innovation
Software Architecture for InnovationSoftware Architecture for Innovation
Software Architecture for Innovation
 
Five (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryFive (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous Delivery
 
Nanoservices and Microservices with Java
Nanoservices and Microservices with JavaNanoservices and Microservices with Java
Nanoservices and Microservices with Java
 
Microservices: Architecture to Support Agile
Microservices: Architecture to Support AgileMicroservices: Architecture to Support Agile
Microservices: Architecture to Support Agile
 
Microservices: Architecture to scale Agile
Microservices: Architecture to scale AgileMicroservices: Architecture to scale Agile
Microservices: Architecture to scale Agile
 
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsMicroservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Microservice With Spring Boot and Spring Cloud

  • 1. Microservices with
 Spring Boot & Spring Cloud Eberhard Wolff Freelancer / Trainer
  • 3. Eberhard Wolff - @ewolff Micro Services: Definition •  Small •  Independent deployment units •  i.e. processes or VMs •  Any technology •  Any infrastructure •  Include GUI Micro Service Server Micro Service Server
  • 4. Eberhard Wolff - @ewolff Components Collaborate Micro Service Micro Service Link Data Replication REST Messaging
  • 5. Eberhard Wolff - @ewolff Infrastructure for Microservices •  Lots of services •  Need infrastructure Easy to create a new project REST integrated Messaging supported Uniform operations
  • 7. Eberhard Wolff - @ewolff Easy to Create New Project •  One pom.xml •  …Gradle / Ant •  Very few dependencies •  One plug in •  Versions defined for you
  • 8. Eberhard Wolff - @ewolff REST Integrated •  Support in Spring MVC •  As we have seen •  Also support for JAX-RS •  Jersey
  • 9. Eberhard Wolff - @ewolff Messaging Support •  Numerous Spring Boot Starter •  AMQP (RabbitMQ) •  HornetQ (JMS) •  ActiveMQ (JMS, no starter)
  • 10. Eberhard Wolff - @ewolff Messaging Support •  Spring JMS abstraction •  Message driven POJOs •  Scalable •  Simplify sending JMS •  Can use other libs, too! •  Boot can do everything plain Spring / Java can do
  • 11. Eberhard Wolff - @ewolff Infrastructure for Microservices •  More services •  Need infrastructure Easy to create a new project REST integrated Messaging supported Simple deployment Uniform operations ✓ ✓ ✓
  • 13. Eberhard Wolff - @ewolff Deploy •  Just package everything in an executable JAR •  …or a WAR •  Based on Maven, Ant or Gradle •  Build in configuration (YAML, properties etc.)
  • 14. Eberhard Wolff - @ewolff Deploy •  Install a basic machine •  Install Java •  Copy over .jar •  Optional: Create application.properties
  • 15. Eberhard Wolff - @ewolff Infrastructure for Microservices •  More services •  Need infrastructure Easy to create a new project REST integrated Messaging supported Simple deployment Uniform operations ✓ ✓ ✓ ✓
  • 16. Eberhard Wolff - @ewolff Spring Boot Actuator •  Provide information about the application •  Via http / JSON •  Can be evaluated by monitoring tools etc. •  Another alternative approach to monitoring
  • 18. Eberhard Wolff - @ewolff Infrastructure for Microservices •  More services •  Need infrastructure Easy to create a new project REST integrated Messaging supported Simple deployment Uniform operations ✓ ✓ ✓ ✓ ✓
  • 19. Eberhard Wolff - @ewolff Deploy •  Just package everything in an executable JAR
  • 20. Eberhard Wolff - @ewolff Deploy •  Just package everything in an executable JAR •  …or a WAR
  • 21. Eberhard Wolff - @ewolff Spring Cloud
  • 22. Eberhard Wolff - @ewolff Based on Spring Boot
  • 23. Eberhard Wolff - @ewolff Spring Cloud •  Spring support for Amazon Web Services •  Connector for Heroku PaaS •  …and Cloud Foundry PaaS •  The rest of Spring Cloud is for Microservices
  • 24. Eberhard Wolff - @ewolff Coordinating
 Microservices
  • 25. Eberhard Wolff - @ewolff Microservice Microservice Must find each other
  • 26. Eberhard Wolff - @ewolff Service Discovery
 Eureka
  • 27. Eberhard Wolff - @ewolff Why Eureka? •  REST based service registry •  Supports replication •  Caches on the client •  Resilient •  Fast •  …but not consistent •  Foundation for other services
  • 28. Eberhard Wolff - @ewolff Eureka Client in Spring Cloud •  @EnableDiscoveryClient: generic •  @EnableEurekaClient: more specific •  Dependency to spring-cloud-starter-eureka •  Automatically registers application
  • 29. Eberhard Wolff - @ewolff application.properties eureka.client.serviceUrl.defaultZone=http://host: 8761/eureka/< eureka.instance.leaseRenewalIntervalInSeconds=5< spring.application.name=catalog< eureka.instance.metadataMap.instanceId=$ {spring.application.name}:${random.value}< eureka.instance.preferIpAddress=true< Eureka server Can include user / password Need unique ID Load balancing Faster updates Docker won’t resolve host names Used for registration In CAPITAL caps
  • 30. Eberhard Wolff - @ewolff Eureka Server @EnableEurekaServer< @EnableAutoConfiguration< public'class'EurekaApplication'{' < <public'static'void'main(String[]'args)'{' <<SpringApplication.run(EurekaApplication.class,'args);' <}< < }< Add dependency to spring-cloud-starter-eureka-server
  • 31. Eberhard Wolff - @ewolff
  • 32. Eberhard Wolff - @ewolff Eureka
 Demo
  • 33. Eberhard Wolff - @ewolff Microservice Microservice Must find each other Route calls to a service
  • 34. Eberhard Wolff - @ewolff Zuul
 Routing
  • 35. Eberhard Wolff - @ewolff Routing •  One URL to the outside •  Internal: Many Microservices •  REST •  Or HTML GUI
  • 36. Eberhard Wolff - @ewolff Customer Order Catalog Zuul Proxy Automatically maps route to server registered on Eureka i.e. /customer/** to CUSTOMER No configuration Can add filters etc
  • 37. Eberhard Wolff - @ewolff Zuul Proxy @SpringBootApplication @EnableZuulProxy public class ZuulApplication { public static void main(String[] args) { new SpringApplicationBuilder(ZuulApplication.class). web(true).run(args); } } Enable Zuul Proxy Can change route Also routing to external services possible
  • 38. Eberhard Wolff - @ewolff lokaler Rechner Vagrant VM eureka zuul customer -app catalog- app order-app 172.17.0.0/16 Netzwerk 8761 8761 8080 8080 18761 18080
  • 39. Eberhard Wolff - @ewolff Zuul
 Demo
  • 40. Eberhard Wolff - @ewolff Microservice Microservice Must find each other Configuration Route calls to a service
  • 41. Eberhard Wolff - @ewolff Configuration •  Spring Cloud Config •  Central configuration •  Dynamic updates •  Can use git backend •  I prefer immutable server •  & DevOps tools (Docher, Chef…)
  • 42. Eberhard Wolff - @ewolff Microservice Microservice Must find each other Configuration Route calls to a service Communication
  • 43. Eberhard Wolff - @ewolff Spring Cloud Bus
  • 44. Eberhard Wolff - @ewolff Spring Cloud Bus •  Pushed config updates •  …or individual message •  I prefer a messaging solution •  Independent from Spring
  • 45. Eberhard Wolff - @ewolff Microservice Microservice Must find each other Configuration Route calls to a service Communication Security
  • 46. Eberhard Wolff - @ewolff Spring Cloud Security
  • 47. Eberhard Wolff - @ewolff Spring Cloud Security •  Single Sign On via OAuth2 •  Forward token e.g. via RestTemplate •  Support for Zuul •  Very valuable!
  • 48. Eberhard Wolff - @ewolff Implementing
 Microservices
  • 49. Eberhard Wolff - @ewolff Microservice Microservice Load Balancing
  • 50. Eberhard Wolff - @ewolff Load Balancing
 Ribbon
  • 51. Eberhard Wolff - @ewolff Ribbon: Client Side Load Balancing •  Decentralized Load Balancing •  No bottle neck •  Resilient •  Hard to consider metrics / health •  Data might be inconsistent Load Balancer Server Client
  • 52. Eberhard Wolff - @ewolff RestTemplate & Load Balancing @RibbonClient(name = "ribbonApp") … public class RibbonApp { @Autowired private RestTemplate restTemplate; public void callMicroService() { Store store = restTemplate. getForObject("http://stores/store/1", Store.class); } } Enable Ribbon Left out other annotations Eureka name or server list Standard Spring REST client Can also use Ribbon API
  • 53. Eberhard Wolff - @ewolff Microservice Microservice Load Balancing Resilience
  • 54. Eberhard Wolff - @ewolff Hystrix
 Resilience
  • 55. Eberhard Wolff - @ewolff Hystrix •  Enable resilient applications •  Do call in other thread pool •  Won’t block request handler •  Can implement timeout
  • 56. Eberhard Wolff - @ewolff Hystrix •  Circuit Breaker •  If call system fail open •  If open do not forward call •  Forward calls after a time window •  System won’t be swamped with requests
  • 57. Eberhard Wolff - @ewolff Hystrix / Spring Cloud •  Annotation based approach •  Java Proxies automatically created •  Annotations of javanica libraries •  Simplifies Hystrix dramatically •  No commands etc
  • 58. Eberhard Wolff - @ewolff @HystrixCommand(fallbackMethod = "getItemsCache") public Collection<Item> findAll() { … this.itemsCache = pagedResources.getContent(); return itemsCache; } private Collection<Item> getItemsCache() { return itemsCache; }< Fallback
  • 59. Eberhard Wolff - @ewolff lokaler Rechner Vagrant VM eureka zuul customer -app catalog- app order-app 172.17.0.0/16 Netzwerk 8761 8761 8080 8080 18761 18080
  • 60. Eberhard Wolff - @ewolff lokaler Rechner Vagrant VM eureka zuul customer -app catalog- app turbine order-app 172.17.0.0/16 Netzwerk 8761 8761 8989 8989 8080 8080 18761 18989 18080
  • 61. Eberhard Wolff - @ewolff Hystrix Dashboard Stream via http Circuit Breaker status Thread Pool status
  • 62. Eberhard Wolff - @ewolff Conclusion
  • 63. Eberhard Wolff - @ewolff Spring Boot for Microservices Easy to create a new project REST integrated Messaging supported Simple deployment Uniform operations ✓ ✓ ✓ ✓ ✓
  • 64. Eberhard Wolff - @ewolff Hystrix
 Demo
  • 65. Eberhard Wolff - @ewolff Must find each other: Service Discovery Configuration Route calls to a service Communication Load Balancing Resilience Spring Cloud for Microservices
  • 66. Eberhard Wolff - @ewolff Links http://projects.spring.io/spring-boot/ http://projects.spring.io/spring-cloud https://github.com/ewolff/spring-boot-demos https://github.com/ewolff/microservices https://spring.io/guides/
  • 67. Eberhard Wolff - @ewolff Thank You!!