@crichardson
A pattern language for microservices
Chris Richardson
Founder of the original CloudFoundry.com Author of POJOs in Action @crichardson chris@chrisrichardson.net http://plainoldobjects.com http://microservices.io http://eventuate.io
A pattern language for microservices Chris Richardson Founder of - - PowerPoint PPT Presentation
A pattern language for microservices Chris Richardson Founder of the original CloudFoundry.com Author of POJOs in Action @crichardson chris@chrisrichardson.net http://plainoldobjects.com http://microservices.io http://eventuate.io
@crichardson
Chris Richardson
Founder of the original CloudFoundry.com Author of POJOs in Action @crichardson chris@chrisrichardson.net http://plainoldobjects.com http://microservices.io http://eventuate.io
@crichardson
@crichardson
@crichardson
(http://www.chrisrichardson.net/)
@crichardson
(http://bit.ly/trialeventuate)
@crichardson
https://github.com/cer/event-sourcing-examples http://microservices.io http://plainoldobjects.com/ https://twitter.com/crichardson http://eventuate.io/
@crichardson
Why a pattern language for microservices? Core patterns Deployment patterns Communication patterns
@crichardson
http://en.wikipedia.org/wiki/Fred_Brooks
@crichardson
@crichardson
Spring vs. Java EE JavaScript vs. Java Functional programming vs. Object-oriented
http://nealford.com/memeagora/2009/08/05/suck-rock-dichotomy.html
Containers vs. Virtual Machines
@crichardson
http://upload.wikimedia.org/wikipedia/commons/b/bf/Hype-Cycle-General.png
It’s awesome It’s not awesome Trade-offs understood
@crichardson
Decide using emotions Rationalize with
http://en.wikipedia.org/wiki/Mahout
@crichardson
@crichardson
@crichardson
@crichardson
aka the situation
Name Context Problem
(conflicting) issues etc to address
Forces Solution
@crichardson
Benefits Drawbacks Issues to resolve
@crichardson
Alternative solutions Solutions to problems introduced by this pattern
A collection of related patterns that solve problems in a particular domain Relationships Pattern A results in a context that has a problem solved by Pattern B Patterns A and B solve the same problem Pattern A is a specialization of pattern B
http://en.wikipedia.org/wiki/A_Pattern_Language
Access to Water Promenade Local townhall Intimacy gradient Light on two sides
@crichardson
@crichardson
Monolithic architecture Microservice architecture API gateway Client-side discovery Server-side discovery Service registry Self registration 3rd party registration Multiple Services per host Single Service per Host Service-per- Container Deployment Discovery Core Communication Service-per-VM Partitioning Messaging Remote Procedure Invocation Style Motivating Pattern Solution Pattern Solution A Solution B General Specific
Work in progress
http://microservices.io/
@crichardson
Why a pattern language for microservices? Core patterns Deployment patterns Communication patterns
@crichardson
@crichardson
Browser/ Client SQL Database
Review Service Product Info Service
Recommendation Service
StoreFrontUI Order Service HTML REST/JSON
@crichardson
@crichardson
There is a team of developers that must be productive The application must be easy to understand and modify Do continuous deployment Run multiple instances for scalability and availability Use emerging technologies (frameworks, programming languages, etc)
@crichardson
Tomcat
Browser/ Client
WAR/EAR
MySQL Database
Review Service Product Info Service
Recommendation Service
StoreFrontUI Order Service HTML REST/JSON
develop test deploy
scale
@crichardson
@crichardson
@crichardson
@crichardson
Need to redeploy everything to change one component Interrupts long running background (e.g. Quartz) jobs Increases risk of failure
Fear of change
Updates will happen less often - really long QA cycles e.g. Makes A/B testing UI really difficult
@crichardson
Slows down development
@crichardson
I want to update the UI But the backend is not working yet!
@crichardson
@crichardson
@crichardson
X axis
Z a x i s
a t a p a r t i t i
i n g Y axis - functional decomposition S c a l e b y s p l i t t i n g s i m i l a r t h i n g s Scale by splitting different things
@crichardson
Product Info
Product Info Service Recommendation Service Review Service Order Service Browse Products UI Checkout UI Order management UI Account management UI
@crichardson
http://highscalability.com/amazon-architecture http://techblog.netflix.com/ http://www.addsimplicity.com/downloads/ eBaySDForum2006-11-29.pdf http://queue.acm.org/detail.cfm?id=1394128 ~600 services 100-150 services to build a page
@crichardson
Smaller, simpler apps Easier to understand and develop Less jar/classpath hell - who needs OSGI? Faster to build and deploy Scales development: develop, deploy and scale each service independently Improves fault isolation Eliminates long-term commitment to a single technology stack System level architecture vs. service level architecture Easily and safely experiment with new technologies
@crichardson
Complexity of developing a distributed system Implementing inter-process communication Handling partial failures Implementing business transactions that span multiple databases (without 2PC) Complexity of testing a distributed system Complexity of deploying and operating a distributed system Managing the development and deployment of features that span multiple services
Fortunately solutions exists
@crichardson
@crichardson
How to deploy the services? How do the services communicate? How do clients of the application communicate with the services? How to partition the system into services? How to deal with distributed data management problems? Come to tomorrow’s talk at 9am ….
@crichardson
Why a pattern language for microservices? Core patterns Deployment patterns Communication patterns
@crichardson
@crichardson
Services are written using a variety of languages, frameworks, and framework versions Each service consists of multiple service instances for throughput and availability Building and deploying a service must be fast Service must be deployed and scaled independently Service instances need to be isolated Resources consumed by a service must be constrained Deployment must be cost-effective
@crichardson
@crichardson
Host (Physical or VM) Service-A Instance-1 Service-B Instance-2 Service-C Instance-2 Process WAR OSGI bundle
Benefits Efficient resource utilization Fast deployment Drawbacks Poor/Terrible isolation Poor visibility (with WAR/OSGI deployment) Difficult to limit resource utilization Risk of dependency version conflicts Poor encapsulation of implementation technology
@crichardson
@crichardson
Service VM image VM Service VM Service VM Service
packaged as deployed as
@crichardson
http://techblog.netflix.com/ ~600 services
packer.io is a great tool
Benefits Great isolation Great manageability VM encapsulates implementation technology Leverage AWS infrastructure for Autoscaling/Load balancing Drawbacks Less efficient resource utilization Slow deployment
@crichardson
VM VM
Service Container image Container Service Container Service Container Service
packaged as deployed as
@crichardson
Benefits Great isolation Great manageability Container encapsulates implementation technology Efficient resource utilization Fast deployment Drawbacks Immature infrastructure for deploying containers
@crichardson
Why a pattern language for microservices? Core patterns Deployment patterns Communication patterns
@crichardson
System Client Service A Service B Service C
The System
How do clients of the system interact with the services? How do services within the system interact?
@crichardson
@crichardson
Service Client Service Instance A Service Instance B Service Instance C
10.4.3.1:8756 10.4.3.99:4545 10.4.3.20:333
Client or API gateway Dynamically changing Service Instance A Service Instance B Service Instance C
10.4.3.1:8756 10.4.3.99:4545 10.4.3.20:333
How to load balance? Dynamically assigned
@crichardson
Service Client
Registry- aware HTTP Client
Service Registry Service Instance A Service Instance B Service Instance C
10.4.3.1:8756 10.4.3.99:4545 10.4.3.20:333
register query request load balance
@crichardson
https://github.com/Netflix/eureka/wiki/Eureka-at-a-glance https://github.com/Netflix/ribbon
Benefits Flexible, application-specific load balancing Fewer network hops and moving parts compared to Server-side discovery Drawbacks Couples the client to the Service Registry Need implement client-side discovery and load balancing logic in multiple languages/ frameworks Service Registry is yet another moving part to setup and operate - highly available
@crichardson
Service Client
Router
Service Registry Service Instance A Service Instance B Service Instance C
10.4.3.1:8756 10.4.3.99:4545 10.4.3.20:333
register query request
request load balance
@crichardson
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/ DeveloperGuide/vpc-loadbalancer-types.html
Internal ELB Internal ELB Public ELB
Benefits Simpler client code Built-in to some cloud/ container environments, e.g. AWS ELB, Kubernetes, Marathon Drawbacks Limited to (generic) load balancing algorithms provided by router More network hops Router and Service Registry is yet another moving part to setup and operate - highly available
@crichardson
Think about technology Discuss technology Apply technology
@crichardson
Think about microservices Discuss microservices Apply microservices (or not)
@crichardson
@crichardson chris@chrisrichardson.net http://bit.ly/trialeventuate http://plainoldobjects.com http://microservices.io