SlideShare a Scribd company logo
1 of 37
Download to read offline
Microservices With Spring Boot and Spring Cloud
Netflix
Capgemini APPS Evolve! Summit 2016
Bad Soden, 3rd of March 2016
Krzysztof Sobkowiak ( )
The Apache Software Foundation Member
Senior Solution Architect at Capgemini
@ksobkowiak
Outline
Domain Architecture
Basic Technologies
Service Discovery
Load Balancing
Communication
Resilience
Domain Architecture
Three Microservices
Architecture Considerations
Separate data storages
Lots of communication
Bounded Context
Don’t modularize microservices by data
Basic Technologies
HSQL Database
In memory database
Not really suited for production use
Keeps the example application easy
Spring Data JPA
Provides support to build repositories based on Spring and JPA
Support for Querydsl predicates and thus type-safe JPA queries
Pagination support, dynamic query execution, ability to integrate custom data access code
p u b l i c i n t e r f a c e P e r s o n R e p o s i t o r y e x t e n d s P a g i n g A n d S o r t i n g R e p o s i t o r y < P e r s o n , L o n g > {
L i s t < P e r s o n > f i n d B y L a s t N a m e ( @ P a r a m ( " n a m e " ) S t r i n g n a m e ) ;
}
Spring Data REST
Provides the domain objects with little effort via REST
Can hide certain data elements
Can be con gured exibly
Tight coupling between the internal model and the interface can be decoupled
@ R e p o s i t o r y R e s t R e s o u r c e ( c o l l e c t i o n R e s o u r c e R e l = " p e o p l e " , p a t h = " p e o p l e " )
p u b l i c i n t e r f a c e P e r s o n R e p o s i t o r y e x t e n d s P a g i n g A n d S o r t i n g R e p o s i t o r y < P e r s o n , L o n g > {
L i s t < P e r s o n > f i n d B y L a s t N a m e ( @ P a r a m ( " n a m e " ) S t r i n g n a m e ) ;
}
Spring Boot
It can be pretty small…
Prede ned packages/starters available
Can generate WAR or JAR le
@ R e s t C o n t r o l l e r
@ S p r i n g B o o t A p p l i c a t i o n
p u b l i c c l a s s C o n t r o l l e r A n d M a i n {
@ R e q u e s t M a p p i n g ( " / " )
p u b l i c S t r i n g h e l l o ( ) {
r e t u r n " h e l l o " ;
}
p u b l i c s t a t i c v o i d m a i n ( S t r i n g [ ] a r g s ) {
S p r i n g A p p l i c a t i o n . r u n (
C o n t r o l l e r A n d M a i n . c l a s s , a r g s ) ;
}
}
Writing a single service is nice…
…but no microservice is an island
Challenges of Distributed Systems
Con guration management
Service registration & discovery
Routing & balancing
Fault tolerance (Circuit Breakers!)
Monitoring
Spring Cloud
Spring Cloud Components
Security - supports the implementation of security mechanisms
Con g - centralizes and dynamically adjusts the con guration
Bus - sends dynamic con guration changes for Spring Cloud Con g
Sleuth - distributed tracing with tools like Zipkin or Htrace
Zookeeper - supports Apache Zookeeper
Consult - facilitates Services Discovery using Consul
Cluster - implements leader election and stateful patterns using technologies like Zookeeper or Consul
Stream - supports messaging using Redis, Rabbit or Kafka
Spring Cloud Netflix
Zuul - routing
Ribbon - Load Balancer.
Hystrix - resilience in Microservices.
Turbine - can consolidate monitoring data from different Hystrix servers.
Feign - option for an easier implementation of REST clients
Eureka - Service Discovery
Service Discovery
Why Eureka?
REST based service registry
Supports replication
Caches on the client
Resilient
Fast, but not consistent
Foundation for other services
Eureka Client
Registers automatically with the Eureka server under a de ned name
Can access other Microservices
Integrates Load Balancing with Ribbon using
DiscoveryClient, FeignClient
Eureka aware RestTemplate(sample later)
@EnableDiscoveryClientor @EnableEurekaClient
Dependency to spring-cloud-starter-eureka
e u r e k a . c l i e n t . s e r v i c e U r l . d e f a u l t Z o n e = h t t p : / / e u r e k a : 8 7 6 1 / e u r e k a /
e u r e k a . i n s t a n c e . l e a s e R e n e w a l I n t e r v a l I n S e c o n d s = 5
s p r i n g . a p p l i c a t i o n . n a m e = c a t a l o g
e u r e k a . i n s t a n c e . m e t a d a t a M a p . i n s t a n c e I d = c a t a l o g : $ { r a n d o m . v a l u e }
e u r e k a . i n s t a n c e . p r e f e r I p A d d r e s s = t r u e
Eureka Server
@EnableEurekaServer
Dependency to cloud-starter-eureka-server
@ E n a b l e E u r e k a S e r v e r
@ E n a b l e A u t o C o n f i g u r a t i o n
p u b l i c c l a s s E u r e k a A p p l i c a t i o n {
p u b l i c s t a t i c v o i d m a i n ( S t r i n g [ ] a r g s ) {
S p r i n g A p p l i c a t i o n . r u n ( E u r e k a A p p l i c a t i o n . c l a s s , a r g s ) ;
}
}
Eureka Dashboard
Load Balancing
Ribbon
Decentralized, client side Load Balancing
No bottle neck
Resilient
Registration information might be inconsistent
RestTemplate& Load Balancing
@RibbonClient
Dependency to spring-cloud-starter-ribbon
@ R i b b o n C l i e n t ( n a m e = " r i b b o n A p p " )
. . . / / L e f t o u t o t h e r S p r i n g C l o u d / B o o t A n n o t a t i o n s
p u b l i c c l a s s R i b b o n A p p {
@ A u t o w i r e d
p r i v a t e R e s t T e m p l a t e r e s t T e m p l a t e ;
p u b l i c v o i d c a l l M i c r o s e r v i c e ( ) {
S t o r e s t o r e = r e s t T e m p l a t e . g e t F o r O b j e c t ( " h t t p : / / s t o r e s / s t o r e / 1 " , S t o r e . c l a s s ) ;
}
}
Communication
Zuul Routing
One URL to outside
Internal many microservices
Maps route to server registered on Eureka, e.g.
/customer/**to CUSTOMER
Allows to internally change the structure of the
Microservices
REST or HTML gui
@EnableZuulProxy, dependency to spring-cloud-starter-zuul
Alternatively @EnableZuulServer- no routing, uses lters
Eureka, Zuul & Ribbon Interactions
Resilience
Microservices can deal with the failure of other Microservices
Even if a called Microservice is not available, they will still work
Hystrix
Enables resilient applications
Call in other thread
Won’t block request handler
Can implement timeout
Circuit Breaker with Hystrix
Circuit open after certain number (error threshold) of failed calls
If open, calls not directed to called system
After con gured window circuit closes
Hystrix with Annotations
Java proxies automaticaly created
Annotations of javanica library
@EnableCircuitBreakeror @EnableHystrix, dependency to spring-cloud-starter-hystrix
@ H y s t r i x C o m m a n d ( f a l l b a c k M e t h o d = " g e t I t e m s C a c h e " , c o m m a n d P r o p e r t i e s = {
@ H y s t r i x P r o p e r t y ( n a m e = " c i r c u i t B r e a k e r . r e q u e s t V o l u m e T h r e s h o l d " , v a l u e = " 2 " )
} )
p u b l i c C o l l e c t i o n < I t e m > f i n d A l l ( ) {
t h i s . i t e m s C a c h e = . . .
. . .
r e t u r n p a g e d R e s o u r c e s . g e t C o n t e n t ( ) ;
}
p r i v a t e C o l l e c t i o n < I t e m > g e t I t e m s C a c h e ( ) {
r e t u r n i t e m s C a c h e ;
}
Hystrix Dashboard
Turbine
Aggregates data from different Hystrix systems
The state of all Circuit Breakers can be summarized on a single dashboard
Turbine
@EnableTurbineand @EnableEurekaClient, dependency to spring-cloud-starter-turbine
Can use @EnableHystrixDashboardto display dahsboard on the same instance
Consolidated data determined by the con guration
t u r b i n e :
a g g r e g a t o r :
c l u s t e r C o n f i g : O R D E R
a p p C o n f i g : o r d e r
Conclusion
Easy to create new project
REST integrated
messaging supported
Simple deployment
Uniform operations
Thanks!
Any questions?
Microservices demo -
Travel demo -
https://github.com/ewolff/microservice
https://github.com/microservices-summit-2016/resilience-demo

More Related Content

What's hot

Crs issue commands
Crs issue commandsCrs issue commands
Crs issue commandsraviranchi02
 
Spork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD ProcessSpork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD ProcessArik Fraimovich
 
msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...
msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...
msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...digitalwave
 
Bash Script - How To Monitor Application Error Logs and Send Notification
Bash Script - How To Monitor Application Error Logs and Send NotificationBash Script - How To Monitor Application Error Logs and Send Notification
Bash Script - How To Monitor Application Error Logs and Send NotificationVCP Muthukrishna
 
Zuul's Journey to Non-Blocking
Zuul's Journey to Non-BlockingZuul's Journey to Non-Blocking
Zuul's Journey to Non-BlockingArthur Gonigberg
 
Scalable Anomaly Detection (with Zero Machine Learning)
Scalable Anomaly Detection (with Zero Machine Learning)Scalable Anomaly Detection (with Zero Machine Learning)
Scalable Anomaly Detection (with Zero Machine Learning)Arthur Gonigberg
 
Intelligent infrastructure with SaltStack
Intelligent infrastructure with SaltStackIntelligent infrastructure with SaltStack
Intelligent infrastructure with SaltStackLove Nyberg
 
Spark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 FuriousSpark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 FuriousRussell Spitzer
 
[Perforce] Tasks - The Holy Hand Grenade of Branching
[Perforce] Tasks - The Holy Hand Grenade of Branching[Perforce] Tasks - The Holy Hand Grenade of Branching
[Perforce] Tasks - The Holy Hand Grenade of BranchingPerforce
 
Maximum Overdrive: Tuning the Spark Cassandra Connector
Maximum Overdrive: Tuning the Spark Cassandra ConnectorMaximum Overdrive: Tuning the Spark Cassandra Connector
Maximum Overdrive: Tuning the Spark Cassandra ConnectorRussell Spitzer
 

What's hot (10)

Crs issue commands
Crs issue commandsCrs issue commands
Crs issue commands
 
Spork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD ProcessSpork || How To Streamline Your TDD Process
Spork || How To Streamline Your TDD Process
 
msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...
msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...
msc_pyparser - ModSecurity config parser presentation @CRS Community Summit i...
 
Bash Script - How To Monitor Application Error Logs and Send Notification
Bash Script - How To Monitor Application Error Logs and Send NotificationBash Script - How To Monitor Application Error Logs and Send Notification
Bash Script - How To Monitor Application Error Logs and Send Notification
 
Zuul's Journey to Non-Blocking
Zuul's Journey to Non-BlockingZuul's Journey to Non-Blocking
Zuul's Journey to Non-Blocking
 
Scalable Anomaly Detection (with Zero Machine Learning)
Scalable Anomaly Detection (with Zero Machine Learning)Scalable Anomaly Detection (with Zero Machine Learning)
Scalable Anomaly Detection (with Zero Machine Learning)
 
Intelligent infrastructure with SaltStack
Intelligent infrastructure with SaltStackIntelligent infrastructure with SaltStack
Intelligent infrastructure with SaltStack
 
Spark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 FuriousSpark and Cassandra 2 Fast 2 Furious
Spark and Cassandra 2 Fast 2 Furious
 
[Perforce] Tasks - The Holy Hand Grenade of Branching
[Perforce] Tasks - The Holy Hand Grenade of Branching[Perforce] Tasks - The Holy Hand Grenade of Branching
[Perforce] Tasks - The Holy Hand Grenade of Branching
 
Maximum Overdrive: Tuning the Spark Cassandra Connector
Maximum Overdrive: Tuning the Spark Cassandra ConnectorMaximum Overdrive: Tuning the Spark Cassandra Connector
Maximum Overdrive: Tuning the Spark Cassandra Connector
 

Similar to Microservices With Spring Boot and Spring Cloud Netflix

Meteor - not just for rockstars
Meteor - not just for rockstarsMeteor - not just for rockstars
Meteor - not just for rockstarsStephan Hochhaus
 
Spring scala - Sneaking Scala into your corporation
Spring scala  - Sneaking Scala into your corporationSpring scala  - Sneaking Scala into your corporation
Spring scala - Sneaking Scala into your corporationHenryk Konsek
 
Apache Spark: the next big thing? - StampedeCon 2014
Apache Spark: the next big thing? - StampedeCon 2014Apache Spark: the next big thing? - StampedeCon 2014
Apache Spark: the next big thing? - StampedeCon 2014StampedeCon
 
SAI - Serverless Integration Architectures - 09/2019
SAI - Serverless Integration Architectures - 09/2019SAI - Serverless Integration Architectures - 09/2019
SAI - Serverless Integration Architectures - 09/2019Samuel Vandecasteele
 
Model Serving via Pulsar Functions
Model Serving via Pulsar FunctionsModel Serving via Pulsar Functions
Model Serving via Pulsar FunctionsArun Kejariwal
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAjeet Singh Raina
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersMarina Kolpakova
 
OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009marpierc
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPAdam Englander
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPAdam Englander
 
Consistency, Availability, Partition: Make Your Choice
Consistency, Availability, Partition: Make Your ChoiceConsistency, Availability, Partition: Make Your Choice
Consistency, Availability, Partition: Make Your ChoiceAndrea Giuliano
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler DevelopmentLogan Chien
 
Introduction to Java Profiling
Introduction to Java ProfilingIntroduction to Java Profiling
Introduction to Java ProfilingJerry Yoakum
 
API Security: Assume Possible Interference
API Security: Assume Possible InterferenceAPI Security: Assume Possible Interference
API Security: Assume Possible InterferenceJulie Tsai
 
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...Jean-Paul Calbimonte
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaTony Fabeen
 

Similar to Microservices With Spring Boot and Spring Cloud Netflix (20)

Meteor WWNRW Intro
Meteor WWNRW IntroMeteor WWNRW Intro
Meteor WWNRW Intro
 
Meteor - not just for rockstars
Meteor - not just for rockstarsMeteor - not just for rockstars
Meteor - not just for rockstars
 
Spring scala - Sneaking Scala into your corporation
Spring scala  - Sneaking Scala into your corporationSpring scala  - Sneaking Scala into your corporation
Spring scala - Sneaking Scala into your corporation
 
Apache Spark: the next big thing? - StampedeCon 2014
Apache Spark: the next big thing? - StampedeCon 2014Apache Spark: the next big thing? - StampedeCon 2014
Apache Spark: the next big thing? - StampedeCon 2014
 
SAI - Serverless Integration Architectures - 09/2019
SAI - Serverless Integration Architectures - 09/2019SAI - Serverless Integration Architectures - 09/2019
SAI - Serverless Integration Architectures - 09/2019
 
Model Serving via Pulsar Functions
Model Serving via Pulsar FunctionsModel Serving via Pulsar Functions
Model Serving via Pulsar Functions
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHP
 
Consistency, Availability, Partition: Make Your Choice
Consistency, Availability, Partition: Make Your ChoiceConsistency, Availability, Partition: Make Your Choice
Consistency, Availability, Partition: Make Your Choice
 
Fast api
Fast apiFast api
Fast api
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
Loom and concurrency latest
Loom and concurrency latestLoom and concurrency latest
Loom and concurrency latest
 
Introduction to Java Profiling
Introduction to Java ProfilingIntroduction to Java Profiling
Introduction to Java Profiling
 
API Security: Assume Possible Interference
API Security: Assume Possible InterferenceAPI Security: Assume Possible Interference
API Security: Assume Possible Interference
 
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 

Recently uploaded

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Recently uploaded (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

Microservices With Spring Boot and Spring Cloud Netflix

  • 1. Microservices With Spring Boot and Spring Cloud Netflix Capgemini APPS Evolve! Summit 2016 Bad Soden, 3rd of March 2016 Krzysztof Sobkowiak ( ) The Apache Software Foundation Member Senior Solution Architect at Capgemini @ksobkowiak
  • 2. Outline Domain Architecture Basic Technologies Service Discovery Load Balancing Communication Resilience
  • 5. Architecture Considerations Separate data storages Lots of communication Bounded Context Don’t modularize microservices by data
  • 7. HSQL Database In memory database Not really suited for production use Keeps the example application easy
  • 8. Spring Data JPA Provides support to build repositories based on Spring and JPA Support for Querydsl predicates and thus type-safe JPA queries Pagination support, dynamic query execution, ability to integrate custom data access code p u b l i c i n t e r f a c e P e r s o n R e p o s i t o r y e x t e n d s P a g i n g A n d S o r t i n g R e p o s i t o r y < P e r s o n , L o n g > { L i s t < P e r s o n > f i n d B y L a s t N a m e ( @ P a r a m ( " n a m e " ) S t r i n g n a m e ) ; }
  • 9. Spring Data REST Provides the domain objects with little effort via REST Can hide certain data elements Can be con gured exibly Tight coupling between the internal model and the interface can be decoupled @ R e p o s i t o r y R e s t R e s o u r c e ( c o l l e c t i o n R e s o u r c e R e l = " p e o p l e " , p a t h = " p e o p l e " ) p u b l i c i n t e r f a c e P e r s o n R e p o s i t o r y e x t e n d s P a g i n g A n d S o r t i n g R e p o s i t o r y < P e r s o n , L o n g > { L i s t < P e r s o n > f i n d B y L a s t N a m e ( @ P a r a m ( " n a m e " ) S t r i n g n a m e ) ; }
  • 10. Spring Boot It can be pretty small… Prede ned packages/starters available Can generate WAR or JAR le @ R e s t C o n t r o l l e r @ S p r i n g B o o t A p p l i c a t i o n p u b l i c c l a s s C o n t r o l l e r A n d M a i n { @ R e q u e s t M a p p i n g ( " / " ) p u b l i c S t r i n g h e l l o ( ) { r e t u r n " h e l l o " ; } p u b l i c s t a t i c v o i d m a i n ( S t r i n g [ ] a r g s ) { S p r i n g A p p l i c a t i o n . r u n ( C o n t r o l l e r A n d M a i n . c l a s s , a r g s ) ; } }
  • 11. Writing a single service is nice…
  • 12. …but no microservice is an island
  • 13. Challenges of Distributed Systems Con guration management Service registration & discovery Routing & balancing Fault tolerance (Circuit Breakers!) Monitoring
  • 15. Spring Cloud Components Security - supports the implementation of security mechanisms Con g - centralizes and dynamically adjusts the con guration Bus - sends dynamic con guration changes for Spring Cloud Con g Sleuth - distributed tracing with tools like Zipkin or Htrace Zookeeper - supports Apache Zookeeper Consult - facilitates Services Discovery using Consul Cluster - implements leader election and stateful patterns using technologies like Zookeeper or Consul Stream - supports messaging using Redis, Rabbit or Kafka
  • 16. Spring Cloud Netflix Zuul - routing Ribbon - Load Balancer. Hystrix - resilience in Microservices. Turbine - can consolidate monitoring data from different Hystrix servers. Feign - option for an easier implementation of REST clients Eureka - Service Discovery
  • 18. Why Eureka? REST based service registry Supports replication Caches on the client Resilient Fast, but not consistent Foundation for other services
  • 19. Eureka Client Registers automatically with the Eureka server under a de ned name Can access other Microservices Integrates Load Balancing with Ribbon using DiscoveryClient, FeignClient Eureka aware RestTemplate(sample later) @EnableDiscoveryClientor @EnableEurekaClient Dependency to spring-cloud-starter-eureka e u r e k a . c l i e n t . s e r v i c e U r l . d e f a u l t Z o n e = h t t p : / / e u r e k a : 8 7 6 1 / e u r e k a / e u r e k a . i n s t a n c e . l e a s e R e n e w a l I n t e r v a l I n S e c o n d s = 5 s p r i n g . a p p l i c a t i o n . n a m e = c a t a l o g e u r e k a . i n s t a n c e . m e t a d a t a M a p . i n s t a n c e I d = c a t a l o g : $ { r a n d o m . v a l u e } e u r e k a . i n s t a n c e . p r e f e r I p A d d r e s s = t r u e
  • 20. Eureka Server @EnableEurekaServer Dependency to cloud-starter-eureka-server @ E n a b l e E u r e k a S e r v e r @ E n a b l e A u t o C o n f i g u r a t i o n p u b l i c c l a s s E u r e k a A p p l i c a t i o n { p u b l i c s t a t i c v o i d m a i n ( S t r i n g [ ] a r g s ) { S p r i n g A p p l i c a t i o n . r u n ( E u r e k a A p p l i c a t i o n . c l a s s , a r g s ) ; } }
  • 23. Ribbon Decentralized, client side Load Balancing No bottle neck Resilient Registration information might be inconsistent
  • 24. RestTemplate& Load Balancing @RibbonClient Dependency to spring-cloud-starter-ribbon @ R i b b o n C l i e n t ( n a m e = " r i b b o n A p p " ) . . . / / L e f t o u t o t h e r S p r i n g C l o u d / B o o t A n n o t a t i o n s p u b l i c c l a s s R i b b o n A p p { @ A u t o w i r e d p r i v a t e R e s t T e m p l a t e r e s t T e m p l a t e ; p u b l i c v o i d c a l l M i c r o s e r v i c e ( ) { S t o r e s t o r e = r e s t T e m p l a t e . g e t F o r O b j e c t ( " h t t p : / / s t o r e s / s t o r e / 1 " , S t o r e . c l a s s ) ; } }
  • 26. Zuul Routing One URL to outside Internal many microservices Maps route to server registered on Eureka, e.g. /customer/**to CUSTOMER Allows to internally change the structure of the Microservices REST or HTML gui @EnableZuulProxy, dependency to spring-cloud-starter-zuul Alternatively @EnableZuulServer- no routing, uses lters
  • 27. Eureka, Zuul & Ribbon Interactions
  • 29. Microservices can deal with the failure of other Microservices Even if a called Microservice is not available, they will still work
  • 30. Hystrix Enables resilient applications Call in other thread Won’t block request handler Can implement timeout
  • 31. Circuit Breaker with Hystrix Circuit open after certain number (error threshold) of failed calls If open, calls not directed to called system After con gured window circuit closes
  • 32. Hystrix with Annotations Java proxies automaticaly created Annotations of javanica library @EnableCircuitBreakeror @EnableHystrix, dependency to spring-cloud-starter-hystrix @ H y s t r i x C o m m a n d ( f a l l b a c k M e t h o d = " g e t I t e m s C a c h e " , c o m m a n d P r o p e r t i e s = { @ H y s t r i x P r o p e r t y ( n a m e = " c i r c u i t B r e a k e r . r e q u e s t V o l u m e T h r e s h o l d " , v a l u e = " 2 " ) } ) p u b l i c C o l l e c t i o n < I t e m > f i n d A l l ( ) { t h i s . i t e m s C a c h e = . . . . . . r e t u r n p a g e d R e s o u r c e s . g e t C o n t e n t ( ) ; } p r i v a t e C o l l e c t i o n < I t e m > g e t I t e m s C a c h e ( ) { r e t u r n i t e m s C a c h e ; }
  • 34. Turbine Aggregates data from different Hystrix systems The state of all Circuit Breakers can be summarized on a single dashboard
  • 35. Turbine @EnableTurbineand @EnableEurekaClient, dependency to spring-cloud-starter-turbine Can use @EnableHystrixDashboardto display dahsboard on the same instance Consolidated data determined by the con guration t u r b i n e : a g g r e g a t o r : c l u s t e r C o n f i g : O R D E R a p p C o n f i g : o r d e r
  • 36. Conclusion Easy to create new project REST integrated messaging supported Simple deployment Uniform operations
  • 37. Thanks! Any questions? Microservices demo - Travel demo - https://github.com/ewolff/microservice https://github.com/microservices-summit-2016/resilience-demo