SlideShare una empresa de Scribd logo
1 de 67
Descargar para leer sin conexión
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!!

Más contenido relacionado

La actualidad más candente

Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
Jakub Kubrynski
 

La actualidad más candente (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
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
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Spring Core
Spring CoreSpring Core
Spring Core
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Micro services Architecture
Micro services ArchitectureMicro services Architecture
Micro services Architecture
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Monoliths and Microservices
Monoliths and Microservices Monoliths and Microservices
Monoliths and Microservices
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 

Destacado

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
 

Destacado (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 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
 
Blockchain Smartnetworks: Bitcoin and Blockchain Explained
Blockchain Smartnetworks: Bitcoin and Blockchain ExplainedBlockchain Smartnetworks: Bitcoin and Blockchain Explained
Blockchain Smartnetworks: Bitcoin and Blockchain Explained
 

Similar a Microservice With Spring Boot and Spring Cloud

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

Similar a 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
 

Más de Eberhard Wolff

Más de 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"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 ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

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!!