SlideShare a Scribd company logo
Microservices for
Java Architects
Derek C. Ashmore
©2015, All Rights Reserved
Who am I?
 Professional Geek since 1987
 Java/J2EE/Java EE since 1999
 Author of “The Java EE Architect’s Handbook, Second Edition”
 Roles include:
• Developer
• Architect
• Project Manager
• DBA
• System Admin
Discussion Resources
 This slide deck
• http://www.slideshare.net/derekashmore
 Sample code on my Github
• https://github.com/Derek-Ashmore/
 Sample Java Microservice (Moneta)
• https://github.com/Derek-Ashmore/moneta
 Slide deck has hyper-links!
• Don’t bother writing down URLs
Agenda
What are Microservices?
 No concrete definition
 Common microservice traits
• Single functional purpose
 Most/all changes only impact one service
 Not dependent on execution context
• “loosely coupled”
 Independent process/jvm
 Standard Interface (typically Web Service/REST)
 Analogy: Stereo system, Linux utilities
Traditional Java EE Application Architecture
 Like a layer cake
 Highly cohesive
 Defined dependencies
 Deployed as one unit
(war/ear)
 Limited Scalability
• Code Size
What is a Monolith?
 Hard to change
• QA test cycles are long
• Change causes unintended consequences
 Hard to onboard new developers
 Married to your technical stack
 Harder to diagnose bottlenecks and memory issues
Refactoring into Microservices
 Databases physically
separated
 What to do with
common data needs?
• Service call or
• Data copy
No Technical Stack Lock-in
 Platform agnostic
• Freedom to choose database platform
• Freedom to choose languages / frameworks
 Fewer dependency conflicts
 Still have cross-cutting concerns
• “Toll” for first app
 Still have support concerns
• Others need to be able to support your work
• Don’t go ‘crazy’ with your choices
Easier Management / Higher Throughput
 Easier to manage large numbers of developers
• Concentrate on intelligently drawing service boundaries
• Manage/enforce service contracts
 Each service team works independently
 Team independence leads to higher development throughput
Isn’t this SOA?
 Yes – More or less
 No concrete definitions
 SOA == dumb endpoints and smart routes
• ESB routes using Mule, Camel, etc.
• Transformations en route
 MS == dumb routes and smart end-points
• Simple routes
 Usually REST or Soap calls via http(s)
 Persistent queue route at it’s most complex
 Analogy: Electrical supply for Stereo
Agenda
Design considerations
 Service Boundaries (gerrymandering)
 Service call Failure / Unavailability
 Data Integrity
 Performance
Service Boundaries
 Core Services
• Services responsible for maintaining a specific business area data
• Usually named after Nouns
 Service is a system of record for a <blank>
• Student, Course, Classroom, etc.
 Process Services
• Services responsible for performing single complex tasks
• Usually represents an Action or Process
 Service is responsible for processing <blank>
• Student applications, Debt collection, etc.
• These services rely on core services
 Partitioning is an art
• Too few  same drawbacks as traditional architecture
• Too many  excessive network hops
Boundary Sanity Check
 Verbalize a mission statement in one sentence in business terms
• Examples
 This service is the system of record for Student information
 This service registers students for classes
 This service suspends students
 This service records student payments
 This service produces official transcripts
Context Independence Check
 Does your service have multiple consumers?
• Could it?
 Could your service execute as easily in batch as online?
• If ‘No’, then you’re making context assumptions
 Warning Signs
• Spending time analyzing service call flow
 Your services likely make context assumptions
• Agonizing over which service should do a given activity
 Maybe you need a new service
What about Code Base Size?
 Microservices are not about size!
• They are about having a single business purpose
 Microservices ‘happen’ to have a smaller code base
• Results from their single business focus
Designing for Failure
 Dependent services could be down
• Minimize human intervention
• Fail sooner rather than later
• Horizontal scaling / clustering is your first line of defense
• Coding patterns can help as a backup
 Common Patterns:
• Retry
• Circuit Breaker
• Dispatch via Messaging
Retry Pattern
 Best for asynchronous tasks
 Limit the number of tries
 Use sleep interval between tries
 Only addresses temporary outages
 Sample Retry Pattern implementation here.
 Tooling Support:
• Apache CXF supports Retry
• Spring Batch RetryTemplate
• Apache HttpClient (Example here)
Circuit Breaker
Circuit Breaker (continued)
 Objective: Error out sooner
• Conserves resources
• Automatically “recovers” after a time period
 Modeled after home circuit
 Works on thresholds
• Number of errors required to trip circuit
• Amount of time required to attempt retry
 Has Hysterix support
 Best embedded in interface clients / delegates
 More information here.
 Sample Circuit implementation here.
Dispatch via Messaging
 Place work instruction on persistent queue
 If receivers are down, work stacks in queue
 Work throttled by number of receivers
 Queue can be JMS or AMQP
 Tooling Support:
• JMS Api (easy API – many use natively)
• Spring JMSTemplate or RabbitTemplate (producer)
Designing for Performance
 More network traffic
• Make services course-grained
• User Interfaces need a general manager
• Horizontal or Vertical Scaling helps
 Common Patterns:
• Back-ends for Front-ends (a.k.a. API Gateway)
• Dispatch via Messaging
• Expiring Cache
Back-ends for Front-ends
Back-ends for Front-ends (continued)
 Consolidates service calls for the browser
• Enhances performance
 Open web often not as performant as local LAN
 Also known as “API Gateway”
 Implications
• Don’t expose microservices directly to the browser
Expiring Cache
Expiring Cache (continued)
 Look up data once and cache it
• Evict data from the cache after a defined time period
• Sometimes known as “Cache Aside”
• Reduces network calls for data
• Trades memory for speed
• More information here
 When to use
• Only use with static data
• Different clustered nodes “could” have different data for a short time
 Tooling Support:
• I recommend Google Guava
• EHCache, Gemfire, and other tools available
Designing for Integrity
 Services are context independent
• Have no knowledge of how/when they are executed
 One service == One Transaction
• Two-phase commits/rollbacks are a much larger problem
 Common Patterns:
• Custom Rollback
 Write your own reversing transaction
Custom Rollback
Agenda
Packaging Support
 Microservices are deployed as a process
• For Java, embedded containers are easy
• Spring Boot
• Dropwizard
 Docker – standardizes the process deployment and environment
Spring Boot
 Packages Java EE application into *one* deployment jar
• java –jar myApp.jar
 Support for health checks and other admin add ons via ‘Actuator’ add-on
 Supports either Jetty or Tomcat
 Best for ‘Spring-mvc’ apps
• For non-spring apps, it’s swimming upstream
 Required artifacts
• Maven
 spring-boot
 spring-boot-starter-jetty (tomcat is available)
 spring-boot-starter-actuator (optional – health checks, etc.)
• Application class with public static void main()
 Configuration coded (usually into the application class)
 Will read application.properties (app-specific properties)
Dropwizard
 Packages Java EE application into *one* deployment jar
• java –jar myApp.jar server myConfig.yaml
 Provides file configuration options (yaml format)
• Database connection pools
• Logging config
• Port and other container specs
 Provides easy metrics/healthcheck support
 Uses Jetty
 Required artifacts
• Application class (with main())
• Maven: dropwizard-core, maven-shade-plugin
Docker
 Is a “mini VM”
• runs a linux kernal
• Compare to shipping container
• Standard “connections” to outside world
 Supported formally by Oracle, Tomcat, Jboss, and many more
 Docker is Win-Win
• Easier for OPS and system administrators
 All software looks the same
 Standard interface for disk and network resources
• Containers can be “linked”
 Inherently automated
• Easier for developers
 Fewer environment difference issues
 Less to communicate to OPS / system administrators
 Easy to leverage work of others (docker-hub)
• If you haven’t tried Docker yet – you should!
Agenda
Where’s the marketing fluff?
 Easier to manage
• Maybe
 You *must* be good at contract management
 You *must* be good at specifying precisely what a microservice needs to do
 You *must* ensure that services make no assumptions on how they get
invoked
 Easier for developers to “understand” applications
• No – sorry
 It is easier to understand a particular ‘cog’ in the machine (e.g. the function of
one service
 It is *not* easier to understand how microservices fit together to provide a
particular piece of business functionality
Where’s the marketing fluff? (continued)
 Increased Development Throughput
• Maybe
 Harder for business to ‘test’ a business function for a specific combination of microservices
 Developers work on *one* service at a time.
 You *must* be good at error detection (unintended consequences)
 The more assumptions a service makes about its execution context, the more unintended
consequences (e.g. errors) you are likely to have on deployment
 Services become disposable and can be “replaced” instead of “maintained / fixed”.
• Maybe
 It’s more easily replaced than when using traditional architectures
 Requires rigorous contract testing
• Can’t have the “replacement” act any differently than the original (except for the bug being
fixed, of course)
 Requires architecture support for cross-cutting concerns
• Can’t take a lot of time to implement / test
Further Reading
Microservices reading list
http://www.mattstine.com/microservices
Microsoft’s Cloud Design Patterns
https://msdn.microsoft.com/en-us/library/dn600223.aspx
Moneta Java microservice example
https://github.com/Derek-Ashmore/moneta
This slide deck
http://www.slideshare.net/derekashmore
Questions?
Derek Ashmore:
Blog: www.derekashmore.com
LinkedIn: www.linkedin.com/in/derekashmore
Twitter: https://twitter.com/Derek_Ashmore
GitHub: https://github.com/Derek-Ashmore
Book: http://dvtpress.com/

More Related Content

What's hot

CIRCUIT 2015 - Akamai: Caching and Beyond
CIRCUIT 2015 - Akamai:  Caching and BeyondCIRCUIT 2015 - Akamai:  Caching and Beyond
CIRCUIT 2015 - Akamai: Caching and Beyond
ICF CIRCUIT
 
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
Randy Shoup
 
What to consider when monitoring microservices
What to consider when monitoring microservicesWhat to consider when monitoring microservices
What to consider when monitoring microservices
Particular Software
 
Architecting for Failures in micro services: patterns and lessons learned
Architecting for Failures in micro services: patterns and lessons learnedArchitecting for Failures in micro services: patterns and lessons learned
Architecting for Failures in micro services: patterns and lessons learned
Bhakti Mehta
 
Roman Rehak: 24/7 Database Administration + Database Mail Unleashed
Roman Rehak: 24/7 Database Administration + Database Mail UnleashedRoman Rehak: 24/7 Database Administration + Database Mail Unleashed
Roman Rehak: 24/7 Database Administration + Database Mail Unleashed
MSDEVMTL
 
DevCon13 System Administration Basics
DevCon13 System Administration BasicsDevCon13 System Administration Basics
DevCon13 System Administration Basics
sysnickm
 
High Availability Perl DBI + MySQL
High Availability Perl DBI + MySQLHigh Availability Perl DBI + MySQL
High Availability Perl DBI + MySQL
Steve Purkis
 
Cache Optimization with Akamai
Cache Optimization with AkamaiCache Optimization with Akamai
Cache Optimization with Akamai
Blake Crosby
 
Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniques
takinbo
 
Why akka
Why akkaWhy akka
Why akka
Sapardi Sapardi
 
CIRCUIT 2015 - Monitoring AEM
CIRCUIT 2015 - Monitoring AEMCIRCUIT 2015 - Monitoring AEM
CIRCUIT 2015 - Monitoring AEM
ICF CIRCUIT
 
Web Fendamentals
Web FendamentalsWeb Fendamentals
Web Fendamentals
Hiren Mistry
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service Bus
Particular Software
 
Devoxx2017
Devoxx2017Devoxx2017
Devoxx2017
Bhakti Mehta
 
Scaling Confluence Architecture: A Sneak Peek Under the Hood
Scaling Confluence Architecture: A Sneak Peek Under the HoodScaling Confluence Architecture: A Sneak Peek Under the Hood
Scaling Confluence Architecture: A Sneak Peek Under the Hood
Bhakti Mehta
 
Cloud Orchestration is Broken
Cloud Orchestration is BrokenCloud Orchestration is Broken
Cloud Orchestration is Broken
Public Broadcasting Service
 
Designing microservices
Designing microservicesDesigning microservices
Designing microservices
Masashi Narumoto
 
Cloud computing-2 (1)
Cloud computing-2 (1)Cloud computing-2 (1)
Cloud computing-2 (1)
JUDYFLAVIAB
 
CQ5.x Maintenance Webinar 2013
CQ5.x Maintenance Webinar 2013CQ5.x Maintenance Webinar 2013
CQ5.x Maintenance Webinar 2013
Andrew Khoury
 
Pycon2013
Pycon2013Pycon2013

What's hot (20)

CIRCUIT 2015 - Akamai: Caching and Beyond
CIRCUIT 2015 - Akamai:  Caching and BeyondCIRCUIT 2015 - Akamai:  Caching and Beyond
CIRCUIT 2015 - Akamai: Caching and Beyond
 
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
 
What to consider when monitoring microservices
What to consider when monitoring microservicesWhat to consider when monitoring microservices
What to consider when monitoring microservices
 
Architecting for Failures in micro services: patterns and lessons learned
Architecting for Failures in micro services: patterns and lessons learnedArchitecting for Failures in micro services: patterns and lessons learned
Architecting for Failures in micro services: patterns and lessons learned
 
Roman Rehak: 24/7 Database Administration + Database Mail Unleashed
Roman Rehak: 24/7 Database Administration + Database Mail UnleashedRoman Rehak: 24/7 Database Administration + Database Mail Unleashed
Roman Rehak: 24/7 Database Administration + Database Mail Unleashed
 
DevCon13 System Administration Basics
DevCon13 System Administration BasicsDevCon13 System Administration Basics
DevCon13 System Administration Basics
 
High Availability Perl DBI + MySQL
High Availability Perl DBI + MySQLHigh Availability Perl DBI + MySQL
High Availability Perl DBI + MySQL
 
Cache Optimization with Akamai
Cache Optimization with AkamaiCache Optimization with Akamai
Cache Optimization with Akamai
 
Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniques
 
Why akka
Why akkaWhy akka
Why akka
 
CIRCUIT 2015 - Monitoring AEM
CIRCUIT 2015 - Monitoring AEMCIRCUIT 2015 - Monitoring AEM
CIRCUIT 2015 - Monitoring AEM
 
Web Fendamentals
Web FendamentalsWeb Fendamentals
Web Fendamentals
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service Bus
 
Devoxx2017
Devoxx2017Devoxx2017
Devoxx2017
 
Scaling Confluence Architecture: A Sneak Peek Under the Hood
Scaling Confluence Architecture: A Sneak Peek Under the HoodScaling Confluence Architecture: A Sneak Peek Under the Hood
Scaling Confluence Architecture: A Sneak Peek Under the Hood
 
Cloud Orchestration is Broken
Cloud Orchestration is BrokenCloud Orchestration is Broken
Cloud Orchestration is Broken
 
Designing microservices
Designing microservicesDesigning microservices
Designing microservices
 
Cloud computing-2 (1)
Cloud computing-2 (1)Cloud computing-2 (1)
Cloud computing-2 (1)
 
CQ5.x Maintenance Webinar 2013
CQ5.x Maintenance Webinar 2013CQ5.x Maintenance Webinar 2013
CQ5.x Maintenance Webinar 2013
 
Pycon2013
Pycon2013Pycon2013
Pycon2013
 

Viewers also liked

Microservices for Java Architects (Indianapolis, April 15, 2015)
Microservices for Java Architects (Indianapolis, April 15, 2015)Microservices for Java Architects (Indianapolis, April 15, 2015)
Microservices for Java Architects (Indianapolis, April 15, 2015)
Derek Ashmore
 
Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02
Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02
Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02
Derek Ashmore
 
Refactoring Into Microservices 2016-11-06
Refactoring Into Microservices 2016-11-06Refactoring Into Microservices 2016-11-06
Refactoring Into Microservices 2016-11-06
Derek Ashmore
 
Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Aws Lambda for Java Architects CJug-Chicago 2016-08-30Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Derek Ashmore
 
Refactoring Into Microservices 2016-11-08
Refactoring Into Microservices 2016-11-08Refactoring Into Microservices 2016-11-08
Refactoring Into Microservices 2016-11-08
Derek Ashmore
 
Microservices for architects los angeles-2016-07-16
Microservices for architects los angeles-2016-07-16Microservices for architects los angeles-2016-07-16
Microservices for architects los angeles-2016-07-16
Derek Ashmore
 
Aws Lambda for Java Architects - JavaOne -2016-09-19
Aws Lambda for Java Architects - JavaOne -2016-09-19Aws Lambda for Java Architects - JavaOne -2016-09-19
Aws Lambda for Java Architects - JavaOne -2016-09-19
Derek Ashmore
 
AWS Lambda Deployments: Best Practices and Common Mistakes O'Reilly Software...
AWS Lambda Deployments:  Best Practices and Common Mistakes O'Reilly Software...AWS Lambda Deployments:  Best Practices and Common Mistakes O'Reilly Software...
AWS Lambda Deployments: Best Practices and Common Mistakes O'Reilly Software...
Derek Ashmore
 

Viewers also liked (8)

Microservices for Java Architects (Indianapolis, April 15, 2015)
Microservices for Java Architects (Indianapolis, April 15, 2015)Microservices for Java Architects (Indianapolis, April 15, 2015)
Microservices for Java Architects (Indianapolis, April 15, 2015)
 
Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02
Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02
Aws Lambda for Java Architects - Illinois JUG-Northwest -2016-08-02
 
Refactoring Into Microservices 2016-11-06
Refactoring Into Microservices 2016-11-06Refactoring Into Microservices 2016-11-06
Refactoring Into Microservices 2016-11-06
 
Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Aws Lambda for Java Architects CJug-Chicago 2016-08-30Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Aws Lambda for Java Architects CJug-Chicago 2016-08-30
 
Refactoring Into Microservices 2016-11-08
Refactoring Into Microservices 2016-11-08Refactoring Into Microservices 2016-11-08
Refactoring Into Microservices 2016-11-08
 
Microservices for architects los angeles-2016-07-16
Microservices for architects los angeles-2016-07-16Microservices for architects los angeles-2016-07-16
Microservices for architects los angeles-2016-07-16
 
Aws Lambda for Java Architects - JavaOne -2016-09-19
Aws Lambda for Java Architects - JavaOne -2016-09-19Aws Lambda for Java Architects - JavaOne -2016-09-19
Aws Lambda for Java Architects - JavaOne -2016-09-19
 
AWS Lambda Deployments: Best Practices and Common Mistakes O'Reilly Software...
AWS Lambda Deployments:  Best Practices and Common Mistakes O'Reilly Software...AWS Lambda Deployments:  Best Practices and Common Mistakes O'Reilly Software...
AWS Lambda Deployments: Best Practices and Common Mistakes O'Reilly Software...
 

Similar to Microservices for java architects it-symposium-2015-09-15

Scaling Systems: Architectures that grow
Scaling Systems: Architectures that growScaling Systems: Architectures that grow
Scaling Systems: Architectures that grow
Gibraltar Software
 
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
Ivo Andreev
 
Service Architectures at Scale
Service Architectures at ScaleService Architectures at Scale
Service Architectures at Scale
Randy Shoup
 
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
💡 Tomasz Kogut
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolith
Markus Eisele
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
MahmoudZidan41
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
Jeremy Likness
 
Succeding with the Apache SOA stack
Succeding with the Apache SOA stackSucceding with the Apache SOA stack
Succeding with the Apache SOA stack
Johan Edstrom
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Startupfest
 
Paa sing a java ee 6 application kshitiz saxena
Paa sing a java ee 6 application   kshitiz saxenaPaa sing a java ee 6 application   kshitiz saxena
Paa sing a java ee 6 application kshitiz saxena
IndicThreads
 
Resilience planning and how the empire strikes back
Resilience planning and how the empire strikes backResilience planning and how the empire strikes back
Resilience planning and how the empire strikes back
Bhakti Mehta
 
Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Tools. Techniques. Trouble?
Tools. Techniques. Trouble?
Testplant
 
Tech talk microservices debugging
Tech talk microservices debuggingTech talk microservices debugging
Tech talk microservices debugging
Andrey Kolodnitsky
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Lohika_Odessa_TechTalks
 
Java EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolithJava EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolith
Markus Eisele
 
Cloudify workshop at CCCEU 2014
Cloudify workshop at CCCEU 2014 Cloudify workshop at CCCEU 2014
Cloudify workshop at CCCEU 2014
Uri Cohen
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptx
karthiksmart21
 
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Derek Ashmore
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices Architecture
Ashwini Kuntamukkala
 
170215 msa intro
170215 msa intro170215 msa intro
170215 msa intro
Sonic leigh
 

Similar to Microservices for java architects it-symposium-2015-09-15 (20)

Scaling Systems: Architectures that grow
Scaling Systems: Architectures that growScaling Systems: Architectures that grow
Scaling Systems: Architectures that grow
 
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
 
Service Architectures at Scale
Service Architectures at ScaleService Architectures at Scale
Service Architectures at Scale
 
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
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolith
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
 
Succeding with the Apache SOA stack
Succeding with the Apache SOA stackSucceding with the Apache SOA stack
Succeding with the Apache SOA stack
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
 
Paa sing a java ee 6 application kshitiz saxena
Paa sing a java ee 6 application   kshitiz saxenaPaa sing a java ee 6 application   kshitiz saxena
Paa sing a java ee 6 application kshitiz saxena
 
Resilience planning and how the empire strikes back
Resilience planning and how the empire strikes backResilience planning and how the empire strikes back
Resilience planning and how the empire strikes back
 
Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Tools. Techniques. Trouble?
Tools. Techniques. Trouble?
 
Tech talk microservices debugging
Tech talk microservices debuggingTech talk microservices debugging
Tech talk microservices debugging
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...
 
Java EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolithJava EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolith
 
Cloudify workshop at CCCEU 2014
Cloudify workshop at CCCEU 2014 Cloudify workshop at CCCEU 2014
Cloudify workshop at CCCEU 2014
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptx
 
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
Microservices for Java Architects (Madison-Milwaukee, April 28-9, 2015)
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices Architecture
 
170215 msa intro
170215 msa intro170215 msa intro
170215 msa intro
 

Recently uploaded

Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
UiPathCommunity
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
20240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 202420240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 2024
Matthew Sinclair
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
ScyllaDB
 

Recently uploaded (20)

Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
20240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 202420240702 QFM021 Machine Intelligence Reading List June 2024
20240702 QFM021 Machine Intelligence Reading List June 2024
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
 

Microservices for java architects it-symposium-2015-09-15

  • 1. Microservices for Java Architects Derek C. Ashmore ©2015, All Rights Reserved
  • 2. Who am I?  Professional Geek since 1987  Java/J2EE/Java EE since 1999  Author of “The Java EE Architect’s Handbook, Second Edition”  Roles include: • Developer • Architect • Project Manager • DBA • System Admin
  • 3. Discussion Resources  This slide deck • http://www.slideshare.net/derekashmore  Sample code on my Github • https://github.com/Derek-Ashmore/  Sample Java Microservice (Moneta) • https://github.com/Derek-Ashmore/moneta  Slide deck has hyper-links! • Don’t bother writing down URLs
  • 5. What are Microservices?  No concrete definition  Common microservice traits • Single functional purpose  Most/all changes only impact one service  Not dependent on execution context • “loosely coupled”  Independent process/jvm  Standard Interface (typically Web Service/REST)  Analogy: Stereo system, Linux utilities
  • 6. Traditional Java EE Application Architecture  Like a layer cake  Highly cohesive  Defined dependencies  Deployed as one unit (war/ear)  Limited Scalability • Code Size
  • 7. What is a Monolith?  Hard to change • QA test cycles are long • Change causes unintended consequences  Hard to onboard new developers  Married to your technical stack  Harder to diagnose bottlenecks and memory issues
  • 8. Refactoring into Microservices  Databases physically separated  What to do with common data needs? • Service call or • Data copy
  • 9. No Technical Stack Lock-in  Platform agnostic • Freedom to choose database platform • Freedom to choose languages / frameworks  Fewer dependency conflicts  Still have cross-cutting concerns • “Toll” for first app  Still have support concerns • Others need to be able to support your work • Don’t go ‘crazy’ with your choices
  • 10. Easier Management / Higher Throughput  Easier to manage large numbers of developers • Concentrate on intelligently drawing service boundaries • Manage/enforce service contracts  Each service team works independently  Team independence leads to higher development throughput
  • 11. Isn’t this SOA?  Yes – More or less  No concrete definitions  SOA == dumb endpoints and smart routes • ESB routes using Mule, Camel, etc. • Transformations en route  MS == dumb routes and smart end-points • Simple routes  Usually REST or Soap calls via http(s)  Persistent queue route at it’s most complex  Analogy: Electrical supply for Stereo
  • 13. Design considerations  Service Boundaries (gerrymandering)  Service call Failure / Unavailability  Data Integrity  Performance
  • 14. Service Boundaries  Core Services • Services responsible for maintaining a specific business area data • Usually named after Nouns  Service is a system of record for a <blank> • Student, Course, Classroom, etc.  Process Services • Services responsible for performing single complex tasks • Usually represents an Action or Process  Service is responsible for processing <blank> • Student applications, Debt collection, etc. • These services rely on core services  Partitioning is an art • Too few  same drawbacks as traditional architecture • Too many  excessive network hops
  • 15. Boundary Sanity Check  Verbalize a mission statement in one sentence in business terms • Examples  This service is the system of record for Student information  This service registers students for classes  This service suspends students  This service records student payments  This service produces official transcripts
  • 16. Context Independence Check  Does your service have multiple consumers? • Could it?  Could your service execute as easily in batch as online? • If ‘No’, then you’re making context assumptions  Warning Signs • Spending time analyzing service call flow  Your services likely make context assumptions • Agonizing over which service should do a given activity  Maybe you need a new service
  • 17. What about Code Base Size?  Microservices are not about size! • They are about having a single business purpose  Microservices ‘happen’ to have a smaller code base • Results from their single business focus
  • 18. Designing for Failure  Dependent services could be down • Minimize human intervention • Fail sooner rather than later • Horizontal scaling / clustering is your first line of defense • Coding patterns can help as a backup  Common Patterns: • Retry • Circuit Breaker • Dispatch via Messaging
  • 19. Retry Pattern  Best for asynchronous tasks  Limit the number of tries  Use sleep interval between tries  Only addresses temporary outages  Sample Retry Pattern implementation here.  Tooling Support: • Apache CXF supports Retry • Spring Batch RetryTemplate • Apache HttpClient (Example here)
  • 21. Circuit Breaker (continued)  Objective: Error out sooner • Conserves resources • Automatically “recovers” after a time period  Modeled after home circuit  Works on thresholds • Number of errors required to trip circuit • Amount of time required to attempt retry  Has Hysterix support  Best embedded in interface clients / delegates  More information here.  Sample Circuit implementation here.
  • 22. Dispatch via Messaging  Place work instruction on persistent queue  If receivers are down, work stacks in queue  Work throttled by number of receivers  Queue can be JMS or AMQP  Tooling Support: • JMS Api (easy API – many use natively) • Spring JMSTemplate or RabbitTemplate (producer)
  • 23. Designing for Performance  More network traffic • Make services course-grained • User Interfaces need a general manager • Horizontal or Vertical Scaling helps  Common Patterns: • Back-ends for Front-ends (a.k.a. API Gateway) • Dispatch via Messaging • Expiring Cache
  • 25. Back-ends for Front-ends (continued)  Consolidates service calls for the browser • Enhances performance  Open web often not as performant as local LAN  Also known as “API Gateway”  Implications • Don’t expose microservices directly to the browser
  • 27. Expiring Cache (continued)  Look up data once and cache it • Evict data from the cache after a defined time period • Sometimes known as “Cache Aside” • Reduces network calls for data • Trades memory for speed • More information here  When to use • Only use with static data • Different clustered nodes “could” have different data for a short time  Tooling Support: • I recommend Google Guava • EHCache, Gemfire, and other tools available
  • 28. Designing for Integrity  Services are context independent • Have no knowledge of how/when they are executed  One service == One Transaction • Two-phase commits/rollbacks are a much larger problem  Common Patterns: • Custom Rollback  Write your own reversing transaction
  • 31. Packaging Support  Microservices are deployed as a process • For Java, embedded containers are easy • Spring Boot • Dropwizard  Docker – standardizes the process deployment and environment
  • 32. Spring Boot  Packages Java EE application into *one* deployment jar • java –jar myApp.jar  Support for health checks and other admin add ons via ‘Actuator’ add-on  Supports either Jetty or Tomcat  Best for ‘Spring-mvc’ apps • For non-spring apps, it’s swimming upstream  Required artifacts • Maven  spring-boot  spring-boot-starter-jetty (tomcat is available)  spring-boot-starter-actuator (optional – health checks, etc.) • Application class with public static void main()  Configuration coded (usually into the application class)  Will read application.properties (app-specific properties)
  • 33. Dropwizard  Packages Java EE application into *one* deployment jar • java –jar myApp.jar server myConfig.yaml  Provides file configuration options (yaml format) • Database connection pools • Logging config • Port and other container specs  Provides easy metrics/healthcheck support  Uses Jetty  Required artifacts • Application class (with main()) • Maven: dropwizard-core, maven-shade-plugin
  • 34. Docker  Is a “mini VM” • runs a linux kernal • Compare to shipping container • Standard “connections” to outside world  Supported formally by Oracle, Tomcat, Jboss, and many more  Docker is Win-Win • Easier for OPS and system administrators  All software looks the same  Standard interface for disk and network resources • Containers can be “linked”  Inherently automated • Easier for developers  Fewer environment difference issues  Less to communicate to OPS / system administrators  Easy to leverage work of others (docker-hub) • If you haven’t tried Docker yet – you should!
  • 36. Where’s the marketing fluff?  Easier to manage • Maybe  You *must* be good at contract management  You *must* be good at specifying precisely what a microservice needs to do  You *must* ensure that services make no assumptions on how they get invoked  Easier for developers to “understand” applications • No – sorry  It is easier to understand a particular ‘cog’ in the machine (e.g. the function of one service  It is *not* easier to understand how microservices fit together to provide a particular piece of business functionality
  • 37. Where’s the marketing fluff? (continued)  Increased Development Throughput • Maybe  Harder for business to ‘test’ a business function for a specific combination of microservices  Developers work on *one* service at a time.  You *must* be good at error detection (unintended consequences)  The more assumptions a service makes about its execution context, the more unintended consequences (e.g. errors) you are likely to have on deployment  Services become disposable and can be “replaced” instead of “maintained / fixed”. • Maybe  It’s more easily replaced than when using traditional architectures  Requires rigorous contract testing • Can’t have the “replacement” act any differently than the original (except for the bug being fixed, of course)  Requires architecture support for cross-cutting concerns • Can’t take a lot of time to implement / test
  • 38. Further Reading Microservices reading list http://www.mattstine.com/microservices Microsoft’s Cloud Design Patterns https://msdn.microsoft.com/en-us/library/dn600223.aspx Moneta Java microservice example https://github.com/Derek-Ashmore/moneta This slide deck http://www.slideshare.net/derekashmore
  • 39. Questions? Derek Ashmore: Blog: www.derekashmore.com LinkedIn: www.linkedin.com/in/derekashmore Twitter: https://twitter.com/Derek_Ashmore GitHub: https://github.com/Derek-Ashmore Book: http://dvtpress.com/