SlideShare uma empresa Scribd logo
1 de 34
Efficiently 
building 
and deploying 
MICROSERVICES
Bart Blommaerts 
Me 
• bart.blommaerts@hp.com 
• @DaggieBe 
HP Enterprise Services 
• EMEA Java SME 
• Technical Lead at Flemish Government 
Web 
• https://github.com/bart-blommaerts/ 
• http://www.daggie.be
MICROSERVICES
Why? 
Monoliths … 
• Don’t scale easily 
• Are difficult 
– To understand 
– To maintain 
– To test 
– To deploy 
• Make it difficult to adopt new technology 
A monolithic application is like a house of cards ...
Small 
Do 1 thing well 
• 1 responsibility 
• About use case / business capability 
Not about LOC 
Stateless
Small 
Decomposition 
• A monolitic application has disadvantages 
• Decompose the monolith into microservices
Smart endpoints and dumb pipes 
Loosely coupled 
• Make the service smart. Keep the communication dumb. 
• Favor coarse-grained over fine-grained communication.
Smart endpoints and dumb pipes 
Synchronous 
• HTTP request / response
Smart endpoints and dumb pipes 
Synchronous 
• HTTP request / response
Smart endpoints and dumb pipes 
Asynchronous 
• Lightweight messaging
Smart endpoints and dumb pipes 
Asynchronous 
• Event-driven
Decentralized governance 
API interface 
• Language agnostic 
• Multiple versions allowed / encouraged 
• Publish anything of interest. Don’t wait to be asked. 
• Evolutionary 
Disposable
Decentralized data management 
Polyglot persistence 
• Each service owns it’s data storage
Decentralized data management 
Eventual consistency 
• Transactions impose coupling 
• Synchronizing databases might be needed 
Do 1 thing
Design for failure 
Self-monitoring 
• Application will use services as components: many moving parts 
• Any service can fail (or be unreachable): 
– Detect quickly 
– Restore automatically (if possible)
Automation 
Infrastructure (deployment) 
• Large number of services will require automation 
– Use existing solutions (eg. Jenkins, Bamboo, ..) 
• Automation as an enabler for microservices
Recap 
Small 
Smart endpoints and dumb pipes 
Decentralised governance 
Decentralised data management 
Design for failure 
Automation
building 
and deploying
Building: Synchronous 
Person 
• Spring Boot 
• Tomcat 
@ComponentScan 
@EnableAutoConfiguration 
public class PersonApplication { 
public static void main(String[] args) { 
SpringApplication.run(PersonApplication.class, args); 
} 
}
Building: Synchronous 
Address 
• DropWizard 
• Jetty 
@Override 
public void run(AddressConfiguration configuration, Environment environment) { 
final AddressResource resource = new AddressResource(); 
final AddressHealthCheck addressHealthCheck = new AddressHealthCheck(); 
environment.healthChecks().register("address", addressHealthCheck); 
environment.jersey().register(resource); 
}
Building: Synchronous 
PersonAddress 
• DropWizard 
• Jetty 
• Calling Person and Address service, using Jersey. 
@Override 
public void run(PersAddrConfiguration configuration, Environment environment) { 
final Client client = new JerseyClientBuilder(environment).using( 
configuration.getJerseyClientConfiguration()).build(getName()); 
final PersonAddressResource resource = new PersonAddressResource(client); 
…
Building: Asynchronous 
Person Publisher 
• Spring Boot 
• Tomcat 
• Rabbit MQ 
@Autowired 
RabbitTemplate rabbitTemplate; 
… 
rabbitTemplate.convertAndSend(QUEUE_NAME, repository.getAllPersons()); 
…
Building: Asynchronous: Person Publisher 
@Bean 
Queue queue() { 
return new Queue(QUEUE_NAME, false); 
} 
@Bean 
TopicExchange exchange() { 
return new TopicExchange(TOPIC_EXCHANGE); 
} 
@Bean 
Binding binding(Queue queue, TopicExchange exchange) { 
return BindingBuilder.bind(queue).to(exchange).with(QUEUE_NAME); 
}
Building: Asynchronous 
Person Listener 
• Spring Boot 
• Tomcat 
• Rabbit MQ 
Application: 
@Bean 
private MessageListenerAdapter listenerAdapter(PersonListener listener) { 
return new MessageListenerAdapter(listener, "receiveMessage"); 
} 
… 
PersonListener: 
public void receiveMessage(Map<Integer, Person> message)
Building: Sample 
Address Publisher
Deploying 
Automation 
• Simple sample application: 5 servlet containers, 1 messaging queue 
• Configure a deployment pipeline 
• Use deployment automation from the start 
• Consider a PaaS 
– Cloud Foundry, OpenShift, ...
Efficiently
Efficiently 
Synchronous vs Asynchronous 
• Decide early 
• Rule of thumb 
– Reading: synchronous 
– Updating: asynchronous
Decentralised governance 
Service templating 
• Microservices are language agnostic 
– But don’t change technology because you can. Change because it makes sense. 
• Start with a common technology stack 
Modularity 
• Services can be modules of the system 
– Own life cycle 
– Independently deployable 
– But .. “Options” in regard to re-use
Deploying 
DevOps 
• Own your service 
– Eat your own dog food 
• Monitor the monitoring .. 
– Use the monitoring to make the service self-operational 
• Log everything
Efficiently 
Tracking 
• Microservices will be using other microservices 
• Keep track of 
– a correlation id between services 
– The ‘age’ of the data / response
Efficiently 
Tracking: CorrelationId 
Publisher: 
protected Message createMessage(Object object, MessageProperties 
messageProperties) throws MessageConversionException { 
messageProperties.setCorrelationId(correlationId.getBytes()); 
return super.createMessage(object, messageProperties); 
} 
Listener: 
protected Object extractMessage(Message message) throws Exception { 
byte[] correlationId = message.getMessageProperties().getCorrelationId();
Efficiently 
Free Lunch? 
• Complexity 
• DRY 
• Latency and marshalling 
• Versioning 
• API Interface 
• Architect security in from the beginning 
http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
Thank you

Mais conteúdo relacionado

Mais procurados

Cloud migration strategies
Cloud migration strategiesCloud migration strategies
Cloud migration strategies
SogetiLabs
 
The future of scaling forrester research - GigaSpaces Road Show 2011
The future of scaling forrester research - GigaSpaces Road Show 2011The future of scaling forrester research - GigaSpaces Road Show 2011
The future of scaling forrester research - GigaSpaces Road Show 2011
Nati Shalom
 
Citrix - Open Elastic Platform for the Private Cloud
Citrix -  Open Elastic Platform for the Private CloudCitrix -  Open Elastic Platform for the Private Cloud
Citrix - Open Elastic Platform for the Private Cloud
Nati Shalom
 
Hyper Stratus Migrating Applications to the Cloud
Hyper Stratus Migrating Applications to the CloudHyper Stratus Migrating Applications to the Cloud
Hyper Stratus Migrating Applications to the Cloud
bhgolden
 

Mais procurados (20)

Cloud Migration Patterns: A Multi-Cloud Architectural Perspective
Cloud Migration Patterns: A Multi-Cloud Architectural PerspectiveCloud Migration Patterns: A Multi-Cloud Architectural Perspective
Cloud Migration Patterns: A Multi-Cloud Architectural Perspective
 
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
 
Migrating Traditional Apps from On-Premises to the Hybrid Cloud
Migrating Traditional Apps from On-Premises to the Hybrid CloudMigrating Traditional Apps from On-Premises to the Hybrid Cloud
Migrating Traditional Apps from On-Premises to the Hybrid Cloud
 
AWS Partner Webcast - Data Center Migration to the AWS Cloud
AWS Partner Webcast - Data Center Migration to the AWS CloudAWS Partner Webcast - Data Center Migration to the AWS Cloud
AWS Partner Webcast - Data Center Migration to the AWS Cloud
 
Cloud Migration Strategy and Best Practices
Cloud Migration Strategy and Best PracticesCloud Migration Strategy and Best Practices
Cloud Migration Strategy and Best Practices
 
Cloud migration strategies
Cloud migration strategiesCloud migration strategies
Cloud migration strategies
 
Closer Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesCloser Look at Cloud Centric Architectures
Closer Look at Cloud Centric Architectures
 
Plan Your IaaS Environment for Optimal Performance
Plan Your IaaS Environment for Optimal PerformancePlan Your IaaS Environment for Optimal Performance
Plan Your IaaS Environment for Optimal Performance
 
Hybrid Cloud Orchestration: How SuperChoice Does It
Hybrid Cloud Orchestration: How SuperChoice Does ItHybrid Cloud Orchestration: How SuperChoice Does It
Hybrid Cloud Orchestration: How SuperChoice Does It
 
Savig cost using application level virtualization
Savig cost using application level virtualizationSavig cost using application level virtualization
Savig cost using application level virtualization
 
Cloud Migration Strategy
Cloud Migration StrategyCloud Migration Strategy
Cloud Migration Strategy
 
Troubleshooting App Health and Performance with PCF Metrics 1.2
Troubleshooting App Health and Performance with PCF Metrics 1.2Troubleshooting App Health and Performance with PCF Metrics 1.2
Troubleshooting App Health and Performance with PCF Metrics 1.2
 
The future of scaling forrester research - GigaSpaces Road Show 2011
The future of scaling forrester research - GigaSpaces Road Show 2011The future of scaling forrester research - GigaSpaces Road Show 2011
The future of scaling forrester research - GigaSpaces Road Show 2011
 
Hybrid Cloud : Database-as-a-Service: OOW 16
Hybrid Cloud : Database-as-a-Service: OOW 16 Hybrid Cloud : Database-as-a-Service: OOW 16
Hybrid Cloud : Database-as-a-Service: OOW 16
 
Citrix - Open Elastic Platform for the Private Cloud
Citrix -  Open Elastic Platform for the Private CloudCitrix -  Open Elastic Platform for the Private Cloud
Citrix - Open Elastic Platform for the Private Cloud
 
The Future of Services: Building Asynchronous, Resilient and Elastic Systems
The Future of Services: Building Asynchronous, Resilient and Elastic SystemsThe Future of Services: Building Asynchronous, Resilient and Elastic Systems
The Future of Services: Building Asynchronous, Resilient and Elastic Systems
 
DR in the Cloud: Finding the Right Tool for the Job
DR in the Cloud: Finding the Right Tool for the JobDR in the Cloud: Finding the Right Tool for the Job
DR in the Cloud: Finding the Right Tool for the Job
 
Manatee to Dolphin: Transitioning to a Startup Mentality
Manatee to Dolphin: Transitioning to a Startup MentalityManatee to Dolphin: Transitioning to a Startup Mentality
Manatee to Dolphin: Transitioning to a Startup Mentality
 
Migration Tools: The True Cost of Free
Migration Tools: The True Cost of FreeMigration Tools: The True Cost of Free
Migration Tools: The True Cost of Free
 
Hyper Stratus Migrating Applications to the Cloud
Hyper Stratus Migrating Applications to the CloudHyper Stratus Migrating Applications to the Cloud
Hyper Stratus Migrating Applications to the Cloud
 

Destaque

Destaque (20)

Von Null auf Hundert mit Microservices
Von Null auf Hundert mit Microservices Von Null auf Hundert mit Microservices
Von Null auf Hundert mit Microservices
 
Microservices - stress-free and without increased heart-attack risk - Uwe Fri...
Microservices - stress-free and without increased heart-attack risk - Uwe Fri...Microservices - stress-free and without increased heart-attack risk - Uwe Fri...
Microservices - stress-free and without increased heart-attack risk - Uwe Fri...
 
Top 10 real life WebSocket use cases & experiences - Devoxx UK 2015
Top 10 real life WebSocket use cases & experiences - Devoxx UK 2015Top 10 real life WebSocket use cases & experiences - Devoxx UK 2015
Top 10 real life WebSocket use cases & experiences - Devoxx UK 2015
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
Pragmatic Architecture, Today (v2)
Pragmatic Architecture, Today (v2)Pragmatic Architecture, Today (v2)
Pragmatic Architecture, Today (v2)
 
DevoxxUK 2015 "The Seven Deadly Sins of Microservices (Full Version)"
DevoxxUK 2015 "The Seven Deadly Sins of Microservices (Full Version)"DevoxxUK 2015 "The Seven Deadly Sins of Microservices (Full Version)"
DevoxxUK 2015 "The Seven Deadly Sins of Microservices (Full Version)"
 
Android Basic PPT
Android Basic PPTAndroid Basic PPT
Android Basic PPT
 
How Small Can Java Microservices Be?
How Small Can Java Microservices Be?How Small Can Java Microservices Be?
How Small Can Java Microservices Be?
 
Java Microservices with Netflix OSS & Spring
Java Microservices with Netflix OSS & Spring Java Microservices with Netflix OSS & Spring
Java Microservices with Netflix OSS & Spring
 
Open Educational Resources Initiative in Macedonia
Open Educational Resources Initiative in MacedoniaOpen Educational Resources Initiative in Macedonia
Open Educational Resources Initiative in Macedonia
 
Testing The Legacy: Making Existing Applications Testable Without Epic Efforts
Testing The Legacy: Making Existing Applications Testable Without Epic EffortsTesting The Legacy: Making Existing Applications Testable Without Epic Efforts
Testing The Legacy: Making Existing Applications Testable Without Epic Efforts
 
Does agile mean having even less time for testing?!
Does agile mean having even less time for testing?!Does agile mean having even less time for testing?!
Does agile mean having even less time for testing?!
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.
 
Being Agile and Seeing Big Picture
Being Agile and Seeing Big PictureBeing Agile and Seeing Big Picture
Being Agile and Seeing Big Picture
 
Microservice Architecture JavaCro 2015
Microservice Architecture JavaCro 2015Microservice Architecture JavaCro 2015
Microservice Architecture JavaCro 2015
 
Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)
 
Apache Spark Introduction
Apache Spark IntroductionApache Spark Introduction
Apache Spark Introduction
 
Usability In Mobile Applications
Usability In Mobile ApplicationsUsability In Mobile Applications
Usability In Mobile Applications
 

Semelhante a JavaOne: Efficiently building and deploying microservices

Microservices, Spring Cloud & Cloud Foundry
Microservices, Spring Cloud & Cloud FoundryMicroservices, Spring Cloud & Cloud Foundry
Microservices, Spring Cloud & Cloud Foundry
Emilio Garcia
 

Semelhante a JavaOne: Efficiently building and deploying microservices (20)

Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
 
Microservices Design and Best Practices on AWS
Microservices Design and Best Practices on AWSMicroservices Design and Best Practices on AWS
Microservices Design and Best Practices on AWS
 
Concurrency at Scale: Evolution to Micro-Services
Concurrency at Scale:  Evolution to Micro-ServicesConcurrency at Scale:  Evolution to Micro-Services
Concurrency at Scale: Evolution to Micro-Services
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Should i break it?
Should i break it?Should i break it?
Should i break it?
 
The Overview of Microservices Architecture
The Overview of Microservices ArchitectureThe Overview of Microservices Architecture
The Overview of Microservices Architecture
 
building microservices
building microservicesbuilding microservices
building microservices
 
A microservices journey - Round 2
A microservices journey - Round 2A microservices journey - Round 2
A microservices journey - Round 2
 
Using AWS To Build A Scalable Machine Data Analytics Service
Using AWS To Build A Scalable Machine Data Analytics ServiceUsing AWS To Build A Scalable Machine Data Analytics Service
Using AWS To Build A Scalable Machine Data Analytics Service
 
Give your microservices a bus ride with MassTransit
Give your microservices a bus ride with MassTransitGive your microservices a bus ride with MassTransit
Give your microservices a bus ride with MassTransit
 
Building Cloud Native Software
Building Cloud Native SoftwareBuilding Cloud Native Software
Building Cloud Native Software
 
Bol.com Tech lab September 2017 - Microservices in action at the Dutch Nation...
Bol.com Tech lab September 2017 - Microservices in action at the Dutch Nation...Bol.com Tech lab September 2017 - Microservices in action at the Dutch Nation...
Bol.com Tech lab September 2017 - Microservices in action at the Dutch Nation...
 
Microservices, Spring Cloud & Cloud Foundry
Microservices, Spring Cloud & Cloud FoundryMicroservices, Spring Cloud & Cloud Foundry
Microservices, Spring Cloud & Cloud Foundry
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservice
Developing Enterprise Applications for the Cloud, from Monolith to MicroserviceDeveloping Enterprise Applications for the Cloud, from Monolith to Microservice
Developing Enterprise Applications for the Cloud, from Monolith to Microservice
 
IT Talk «Microservices & Serverless Architectures», Alexander Chichenin (Solu...
IT Talk «Microservices & Serverless Architectures», Alexander Chichenin (Solu...IT Talk «Microservices & Serverless Architectures», Alexander Chichenin (Solu...
IT Talk «Microservices & Serverless Architectures», Alexander Chichenin (Solu...
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
 
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National PoliceDevoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National Police
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 

Mais de Bart Blommaerts

Mais de Bart Blommaerts (14)

Cloud-Native Architecture
Cloud-Native ArchitectureCloud-Native Architecture
Cloud-Native Architecture
 
Innovation Without Asking Permission
Innovation Without Asking PermissionInnovation Without Asking Permission
Innovation Without Asking Permission
 
JavaDay 2017: 10 tips to become an awesome technical lead (v4)
JavaDay 2017: 10 tips to become an awesome technical lead (v4)JavaDay 2017: 10 tips to become an awesome technical lead (v4)
JavaDay 2017: 10 tips to become an awesome technical lead (v4)
 
JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)
JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)
JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)
 
10 tips to become an awesome Technical Lead v2 (Devoxx PL)
10 tips to become an awesome Technical Lead v2 (Devoxx PL)10 tips to become an awesome Technical Lead v2 (Devoxx PL)
10 tips to become an awesome Technical Lead v2 (Devoxx PL)
 
10 tips to become an awesome technical lead
10 tips to become an awesome technical lead10 tips to become an awesome technical lead
10 tips to become an awesome technical lead
 
Pragmatic Architecture (SATURN 2017)
Pragmatic Architecture (SATURN 2017)Pragmatic Architecture (SATURN 2017)
Pragmatic Architecture (SATURN 2017)
 
Serverless as a Collaborative Economy Enabler
Serverless as a Collaborative Economy EnablerServerless as a Collaborative Economy Enabler
Serverless as a Collaborative Economy Enabler
 
Pragmatic Architecture, Today.
Pragmatic Architecture, Today.Pragmatic Architecture, Today.
Pragmatic Architecture, Today.
 
The Serverless Cloud @ JAX London 2016
The Serverless Cloud @ JAX London 2016The Serverless Cloud @ JAX London 2016
The Serverless Cloud @ JAX London 2016
 
The Collaborative Economy
The Collaborative EconomyThe Collaborative Economy
The Collaborative Economy
 
e-IB Bouwstenen: Magda
e-IB Bouwstenen: Magdae-IB Bouwstenen: Magda
e-IB Bouwstenen: Magda
 
Java security
Java securityJava security
Java security
 
Code Quality Assurance
Code Quality AssuranceCode Quality Assurance
Code Quality Assurance
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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 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...
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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...
 
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...
 
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
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

JavaOne: Efficiently building and deploying microservices

  • 1. Efficiently building and deploying MICROSERVICES
  • 2. Bart Blommaerts Me • bart.blommaerts@hp.com • @DaggieBe HP Enterprise Services • EMEA Java SME • Technical Lead at Flemish Government Web • https://github.com/bart-blommaerts/ • http://www.daggie.be
  • 4. Why? Monoliths … • Don’t scale easily • Are difficult – To understand – To maintain – To test – To deploy • Make it difficult to adopt new technology A monolithic application is like a house of cards ...
  • 5. Small Do 1 thing well • 1 responsibility • About use case / business capability Not about LOC Stateless
  • 6. Small Decomposition • A monolitic application has disadvantages • Decompose the monolith into microservices
  • 7. Smart endpoints and dumb pipes Loosely coupled • Make the service smart. Keep the communication dumb. • Favor coarse-grained over fine-grained communication.
  • 8. Smart endpoints and dumb pipes Synchronous • HTTP request / response
  • 9. Smart endpoints and dumb pipes Synchronous • HTTP request / response
  • 10. Smart endpoints and dumb pipes Asynchronous • Lightweight messaging
  • 11. Smart endpoints and dumb pipes Asynchronous • Event-driven
  • 12. Decentralized governance API interface • Language agnostic • Multiple versions allowed / encouraged • Publish anything of interest. Don’t wait to be asked. • Evolutionary Disposable
  • 13. Decentralized data management Polyglot persistence • Each service owns it’s data storage
  • 14. Decentralized data management Eventual consistency • Transactions impose coupling • Synchronizing databases might be needed Do 1 thing
  • 15. Design for failure Self-monitoring • Application will use services as components: many moving parts • Any service can fail (or be unreachable): – Detect quickly – Restore automatically (if possible)
  • 16. Automation Infrastructure (deployment) • Large number of services will require automation – Use existing solutions (eg. Jenkins, Bamboo, ..) • Automation as an enabler for microservices
  • 17. Recap Small Smart endpoints and dumb pipes Decentralised governance Decentralised data management Design for failure Automation
  • 19. Building: Synchronous Person • Spring Boot • Tomcat @ComponentScan @EnableAutoConfiguration public class PersonApplication { public static void main(String[] args) { SpringApplication.run(PersonApplication.class, args); } }
  • 20. Building: Synchronous Address • DropWizard • Jetty @Override public void run(AddressConfiguration configuration, Environment environment) { final AddressResource resource = new AddressResource(); final AddressHealthCheck addressHealthCheck = new AddressHealthCheck(); environment.healthChecks().register("address", addressHealthCheck); environment.jersey().register(resource); }
  • 21. Building: Synchronous PersonAddress • DropWizard • Jetty • Calling Person and Address service, using Jersey. @Override public void run(PersAddrConfiguration configuration, Environment environment) { final Client client = new JerseyClientBuilder(environment).using( configuration.getJerseyClientConfiguration()).build(getName()); final PersonAddressResource resource = new PersonAddressResource(client); …
  • 22. Building: Asynchronous Person Publisher • Spring Boot • Tomcat • Rabbit MQ @Autowired RabbitTemplate rabbitTemplate; … rabbitTemplate.convertAndSend(QUEUE_NAME, repository.getAllPersons()); …
  • 23. Building: Asynchronous: Person Publisher @Bean Queue queue() { return new Queue(QUEUE_NAME, false); } @Bean TopicExchange exchange() { return new TopicExchange(TOPIC_EXCHANGE); } @Bean Binding binding(Queue queue, TopicExchange exchange) { return BindingBuilder.bind(queue).to(exchange).with(QUEUE_NAME); }
  • 24. Building: Asynchronous Person Listener • Spring Boot • Tomcat • Rabbit MQ Application: @Bean private MessageListenerAdapter listenerAdapter(PersonListener listener) { return new MessageListenerAdapter(listener, "receiveMessage"); } … PersonListener: public void receiveMessage(Map<Integer, Person> message)
  • 26. Deploying Automation • Simple sample application: 5 servlet containers, 1 messaging queue • Configure a deployment pipeline • Use deployment automation from the start • Consider a PaaS – Cloud Foundry, OpenShift, ...
  • 28. Efficiently Synchronous vs Asynchronous • Decide early • Rule of thumb – Reading: synchronous – Updating: asynchronous
  • 29. Decentralised governance Service templating • Microservices are language agnostic – But don’t change technology because you can. Change because it makes sense. • Start with a common technology stack Modularity • Services can be modules of the system – Own life cycle – Independently deployable – But .. “Options” in regard to re-use
  • 30. Deploying DevOps • Own your service – Eat your own dog food • Monitor the monitoring .. – Use the monitoring to make the service self-operational • Log everything
  • 31. Efficiently Tracking • Microservices will be using other microservices • Keep track of – a correlation id between services – The ‘age’ of the data / response
  • 32. Efficiently Tracking: CorrelationId Publisher: protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException { messageProperties.setCorrelationId(correlationId.getBytes()); return super.createMessage(object, messageProperties); } Listener: protected Object extractMessage(Message message) throws Exception { byte[] correlationId = message.getMessageProperties().getCorrelationId();
  • 33. Efficiently Free Lunch? • Complexity • DRY • Latency and marshalling • Versioning • API Interface • Architect security in from the beginning http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html