Microservices
ThoughtWorks
Scott Shaw	

@scottwshaw
Sam Newman
@samnewman
Schedule
• 09:00 - 10:30 Session 1 	

• 10:30 - 10:45 Break	

• 10:45 - 12:00 Session 2 	

• 12:00 - 13:15 Lunch	

• 13:15...
09:00 - 10:30 Session 1
• Introduction	

• Icebreaker	

• Why Services	

• Principes & Constraints	

• Evolutionary Archit...
10:45 - 12:00 Session 2
• Integration
13:15 - 15:00 Session 3
• Splitting Services	

• CAP & Transactions	

• Testing & CDCs	

• Operational Concerns
15:00 - 15:30 Session 4
• Deploying	

• UI & Mobile	

• Conway’s Law	

• Security
http://www.flickr.com/photos/55255903@N07/6835060992
http://www.flickr.com/photos/22154104@N00/3466383400
http://www.flickr.com/photos/sailbit/3409405778/
Why Services?
or: are we building systems that are too big?
90% of the TCO of an application is incurred post launch
IT  project-­related  losses  are  an  embarrassment  for  the  industry  fund  backers  –  Australian​Super,  Cbus,  HOST...
we have to rewrite entire ecosystems every few years
we have to rewrite entire ecosystems every few years
this doesn’t make many CFO’s happy
scary story
Retail	

Site
Departure	

Control
Retail	

Site
Departure	

Control
Retail	

Site
Departure	

Control
Retail	

Site
Departure	

Control
48 Cores	

!
256 GB RAM (NUMA)	

!
~ $1 x 106 per machine
22
Airline
Tightly coupled
“Golden Hammer Syndrome”
Single point of failure
Expensive to scale
High operational cost
High cos...
24
Airline
Retail	

Site
Departure	

Control
Airline
Retail	

Site
Departure	

Control
Airline
Retail	

Site
Departure	

Control
Airline
Retail	

Site
Departure	

Control
X
scary story
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
The stovepipe enterprise
Stovepipes)are)“systems)procured)and)developed)to)solve)a)specific)problem,)
characterized)by)a)li...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
V1
V2
Go
JVM
NodeJS
Ruby
Go
JVM
NodeJS
Ruby
Go
NodeJS
Ruby
Clojure!
Why now?
standing on the
shoulders of giants
Engineering for: 	

reliability and availability
Devops
circuit breakers, health checks,
status pages
Strategic Design
Bounded Contexts
“town planning”
web integration
application protocols
HATEOAS
infrastructure
automation
patterns for push
button deployments
the lean software
value stream
Summary
We understand more about building reliable distributed systems
cloud compute and programmable infrastructure has m...
Evolutionary
Architecture
“Just enough
architecture”
towns are zoned
heavy industrial
commercial
light residential
Would you build a playground
next to a power station?
Would you build a playground
next to a power station?
Would you build a playground
next to a power station?
a sewage works next to Macy’s?
Towns share utilities
Everyone uses 240V DC right?
and it would be a bad idea not to use the same language
for stop signs...
emergent design is within the zones
emergent design is within the zones
evolutionary architecture is in the gaps
emergent design is within the zones
evolutionary architecture is in the gaps
emergent design is within the zones
• Things to think about:	

• Concentrate on the business capabilities	

• technical acronyms make us think the
wrong way	
...
it can be a single system and its
component parts or chunking
up to how your systems
integrate with others
and if you can’...
Summary
do just enough up front
evolutionary architecture is in the gaps
emergent design is in the boxes
Bounded Contexts
What makes a good
service?
High Cohesion
Loose Coupling
The Trifle
The Trifle
Musik Web
The Trifle
Musik Web
Persistence
The Trifle
Musik Web
Persistence
The Trifle
Musik Web
Persistence
The Trifle
Musik Web
Persistence
“A set of capabilities on an
endpoint”
Bounded Context
"The delimited applicability of a
particular model. BOUNDING
CONTEXTS gives team members a
clear and shared understanding ...
A specific responsibility
enforced by explicit
boundaries
!
http://www.sapiensworks.com/blog/post/
2012/04/17/DDD-The-Bound...
Add to cart
Add to cart
Checkout
Add to cart
Checkout
View Latest 	

Releases
Add to cart
Checkout
View Latest 	

Releases
Search
Add to cart
Checkout
View Latest 	

Releases
Search
Listen To Previews
Add to cart
Checkout
View Latest 	

Releases
Search
Listen To Previews
Add to cart
Checkout
View Latest 	

Releases
Search
Listen To Previews
Shopping Cart Catalog
Music Library
Hexagonal Architectures
83
bounded contexts all the way down (and back up
again)
Object
Object
Object
Object
Object
James’ conjecture
“objects should be no bigger than my head”
Object
Object
Object
Object
Object
as we chunk up domains of abstraction, each
domain should be small enough to fit in my head
93
in this case, it meant 100’s of lines of code per application
Architecture Principles
to build systems is to make trade-offs
to build systems is to make trade-offs
throughput vs cost
to build systems is to make trade-offs
throughput vs cost
to build systems is to make trade-offs
throughput vs cost
portability vs deployability
to build systems is to make trade-offs
throughput vs cost
portability vs deployability
to build systems is to make trade-offs
throughput vs cost
portability vs deployability
replacability vs maintainability
to build systems is to make trade-offs
throughput vs cost
portability vs deployability
replacability vs maintainability
evo...
you want to maximise the degrees of
freedom of your system
The idea of architecture principles is
to try and balance these tradeoffs
to try and balance short term gain with longer term strategic goals
The idea of architecture principles is
to try and bala...
to try and balance short term gain with longer term strategic goals
The idea of architecture principles is
to try and bala...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
to try and balance short term gain with longer term strategic goals
Where trade offs have to be made they should be done s...
and if you don’t know what your business goals are...
and if you don’t know what your business goals are...
may we respectfully suggest that you go and
find them out!
The idea of constraints is to allow your teams the freedom to make decisions
within a consistent framework
The idea of constraints is to allow your teams the freedom to make decisions
within a consistent framework
The idea of constraints is to allow your teams the freedom to make decisions
within a consistent framework
this is not abo...
The idea of constraints is to allow your teams the freedom to make decisions
within a consistent framework
this is not abo...
The idea of constraints is to allow your teams the freedom to make decisions
within a consistent framework
this is not abo...
The idea of constraints is to allow your teams the freedom to make decisions
within a consistent framework
this is not abo...
http://www.12factor.net/
Heroku’s 12 factors are a mixture of principles and
constraints
http://www.12factor.net/
never return directly from a POST
favour choreography over orchestration
never return directly from a POST
favour choreography over orchestration
don’t share domain code (and physically separate the
codebases to ensure this)
neve...
favour choreography over orchestration
don’t share domain code (and physically separate the
codebases to ensure this)
scal...
favour choreography over orchestration
don’t share domain code (and physically separate the
codebases to ensure this)
scal...
Integration
or…
Avoiding Babel
Two Key Attributes Of A
Good Service
1. High Cohesion
!
2. Loose Coupling
1. High Cohesion
!
2. Loose Coupling
© 2013 Electronic Arts Inc.
Otherwise…
http://www.flickr.com/photos/mikecogh/4472054494/
Integration Styles
An Evolutionary View
Data Oriented
Procedure
Oriented
Document
Oriented
Resource
Oriented
Databases
DB
MusikShopMono
DB Schema
Recomendation 	

Service
MusicShopMono
DB Schema
Recomendation 	

ServiceMusicShopMono
DB Schema
Recomendation 	

ServiceMusicShopMono
DB Schema
Recomendation 	

ServiceMusicShopMono
No loose coupling!
DB Schema
Recomendation 	

Service
MusicShopMono
DB Schema
Magic ETL
which is ok until...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
External
Data
Read ...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
External
Data
Read ...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
UI
Views of
external
Data
Read ...
systems like this are brittle
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ad-hoc
UIUI
UI
Finance
U...
systems like this are brittle
difficult to reason aboutHR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
canned reports cubes / ...
systems like this are brittle
difficult to reason about
difficult to change
HR
UI
"Middleware DB"
? ? ?
Data Warehouse
?
can...
systems like this are brittle
difficult to reason about
difficult to change
difficult to maintain
HR
UI
"Middleware DB"
? ? ?...
Next!
RPC
method calls across a
process boundary
consider a client invoking the createUser endpoint
consider a client invoking the createUser endpoint
createUser(id, !
firstName, !
lastName,!
address)
consider a client invoking the createUser endpoint
other clients can use the same call as the first
createUser(id, !
firstName, !
lastName,!
address)
other clients can use the same call as the first
createUser(id, !
firstName, !
lastName,!
address)
so far so good
but what happens when you want to change
how one of the clients calls your service?
but what happens when you want to change
how one of the clients calls your service?
maybe I don’t want to use first name
an...
I want to use the ‘fullname’
createUser(id, !
firstName, !
lastName,!
address)
createUserByFullname(!
id, !
fullName,!
add...
or I want to specify address individually
createUser(id, !
firstName, !
lastName,!
address)
createUserByFullname(!
id, !
f...
one of two things tends to happen with
systems of this type
one of two things tends to happen with
systems of this type
1. you end up with very long service definitions
one of two things tends to happen with
systems of this type
1. you end up with very long service definitions
2. coordinatio...
1. specifications quickly become very very
long and a nightmare to maintain
1. specifications quickly become very very
long and a nightmare to maintain
createUserWithFullname(...)
1. specifications quickly become very very
long and a nightmare to maintain
createUserWithFullname(...)
createUser(...)
1. specifications quickly become very very
long and a nightmare to maintain
createUserWithFullname(...)
createUser(...)
cre...
1. specifications quickly become very very
long and a nightmare to maintain
createUserWithFullname(...)
createUser(...)
cre...
1. specifications quickly become very very
long and a nightmare to maintain
createUserWithFullname(...)
createUser(...)
cre...
2. you have to coordinate the release
cycles of your clients
createUser(id, !
firstName, !
lastName,!
address)
createUser(id, !
firstName, !
lastName,!
address)
createUser(id, !
fullname, !
address)
@deprecated
2. you have to coordin...
createUser(id, !
firstName, !
lastName,!
address)
createUser(id, !
fullname, !
address)
@deprecated
and if you have many c...
A Brief Aside…
Who can tell me
about RFC 761?
Postel’s Law:
“Be liberal in what you do,
conservative in what you
expect”
Practical impact of this
- only bind to what you
need to reduce
breaking service
consumption
Service B
Service A
Shared Lib v1
Shared Lib v1
Service B
Service A
Shared Lib v1
Shared Lib v1
Service B
Service A
Shared Lib v1
Shared Lib v1
Service B
Service A
Shared Lib v1
Shared Lib v1
Shared Lib v2
Service B
Service A
Shared Lib v1
Shared Lib v1
Shared Lib v2
Beware of shared
serialization protocols
Service B
Service A
Shared Lib v1
Shared Lib v1
Shared Lib v2
Beware of shared
serialization protocols
WSDL-binding
Service B
Service A
Shared Lib v1
Shared Lib v1
Shared Lib v2
Beware of shared
serialization protocols
WSDL-binding
JAXB
Service B
Service A
Shared Lib v1
Shared Lib v1
Shared Lib v2
Beware of shared
serialization protocols
WSDL-binding
JAXB
J...
Messaging
(AMC / Associated Press)
a bit like going back to the 50’s enterprise
(AMC / Associated Press)
a bit like going back to the 50’s enterprise
except without the smoking and the rampant misogyny
(AMC / Associated Press)
back in the day, if you wanted to book a
holiday, you didn’t go onto your
corporate intranet to do it right?
back in the day, if you wanted to book a
holiday, you didn’t go onto your
corporate intranet to do it right?
you went to t...
back in the day, if you wanted to book a
holiday, you didn’t go onto your
corporate intranet to do it right?
you went to t...
back in the day, if you wanted to book a
holiday, you didn’t go onto your
corporate intranet to do it right?
you went to t...
james’ holiday request
form
and then you sent it to the HR department
james’ holiday request
form
and then you sent it to the HR department
where it was processed, and eventually you got
anoth...
and messaging is a bit like that
and messaging is a bit like that
asynchronous
and messaging is a bit like that
asynchronous
after all, you wouldn’t want to block waiting for internal mail right?
incidentally, I wasn’t actually there in the 50’s. I just have this on good
authority
and messaging is a bit like that
asy...
generally you create a message composed of a document
and you push it onto some kind of queue
and you push it onto some kind of queue
systems interested in your documents can pop those
documents and act on them
systems interested in your documents can pop those
documents and act on them
and return them should that be the semantics of the
exchange
the documents allowed additive changes to
be made without breaking existing clients
the documents allowed additive changes to
be made without breaking existing clients
If you want to add a field, you can do ...
the documents allowed additive changes to
be made without breaking existing clients
If you want to add a field, you can do ...
and the asynchronous nature decouples the
applications from each other
and the asynchronous nature decouples the
applications from each other
and the asynchronous nature decouples the
applications from each other
you can change this
and the asynchronous nature decouples the
applications from each other
you can change this
without breaking this
of course, there is a teensy bit
more to it than that...
Channel Adapter
Channel
Datatype
Channel
Dead Letter
Channel
Guaranteed
Delivery
!
Invalid Message
Channel
Message
Bus
Mes...
Getting async comms
right can be hard!
And can require the
dreaded ‘middleware’
The ESB!
So when to use it?
So when to use it?
Long-running jobs
So when to use it?
Long-running jobs
Alternative scaling
So when to use it?
Long-running jobs
Alternative scaling
Resiliency
So when to use it?
Long-running jobs
Alternative scaling
Resiliency
Broadcast
So when to use it?
Long-running jobs
Alternative scaling
Resiliency
Broadcast
Low-latency
Next!
Let’s take a look at the world’s most
successful, distributed, scalable
computing system for some tips
The Web
http://www.flickr.com/photos/photophilde/4527076709/
Client cache
Proxy cache CDN Infrastructure	

caches
Reverse proxy	

cache
HTTP -> REST!
Leonard Richardson’s maturity
heuristic
Leonard Richardson’s maturity
heuristic
http://martinfowler.com/articles/richardsonMaturityModel.html
Level 0 - POX single service endpoint, many
methods
createUserWithFullname(...)
Level 0 - POX single service endpoint, many
methods
createUserWithFullname(...)
createUser(...)
Level 0 - POX single service endpoint, many
methods
createUserWithFullname(...)
createUser(...)
updateUserById(...)
Level 0 - POX single service endpoint, many
methods
createUserWithFullname(...)
createUser(...)
updateUserById(...)
updateUserByFullName(...)
Level 0 - POX single service end...
createUserWithFullname(...)
createUser(...)
updateUserById(...)
updateUserByFullName(...)
deleteUserById(...)
Level 0 - PO...
createUserWithFullname(...)
createUser(...)
updateUserById(...)
updateUserByFullName(...)
deleteUserById(...)
Level 0 - PO...
• Level 1 tackles the question of handling complexity
by using divide and conquer, breaking a large
service endpoint down ...
Level 1 - resources
Level 1 - resources
!
!
• Level 2 introduces a standard set of verbs so that
we handle similar situations in the same way,
removing unnecessar...
Level 2 - HTTP verbs
Level 2 - HTTP verbs
getUserById(...)
Level 2 - HTTP verbs
getUserById(...)
GET /users/f3c2ac
• Level 3 introduces discoverability, providing a
way of making a protocol more self-documenting.
Basket!
What if consumers of a service
could act in the same way?
scottwshaw / gist:ee875a6018e1676b36ad
Last active 22 minutes ago
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var	
  jsonpath	
  =...
A non-breaking change to the
service contract
scottwshaw / gist:d531a3f35de01ea45644
Last active 20 minutes ago
1
2
3
4
5
...
In practice most people end up here
Aim high!
This stuff is hard to change later - so do
your research and pick principles that
make sense for you
Go read more!
http://martinfowler.com/articles/richardsonMaturityModel.html
http://www.crummy.com/writing/speaking/2008-QC...
Summary
• REST over HTTP is best - aim high!
• Messaging is cool, but can be hard
• Whatever you do, think lazy binding!
How To Split Services
Add to cart
Add to cart
Checkout
Add to cart
Checkout
View Latest 	

Releases
Add to cart
Checkout
View Latest 	

Releases
Search
Add to cart
Checkout
View Latest 	

Releases
Search
Listen To Previews
Add to cart
Checkout
View Latest 	

Releases
Search
Listen To Previews
Add to cart
Checkout
View Latest 	

Releases
Search
Listen To Previews
Shopping Cart Catalog
Music Library
MusikShopMono
MusikShopMono
Warehouse Finance
Catalog Recommendation
That was the easy bit
Enter the DB
DB
MusikShopMono
DB Schema
Recomendation 	

Service
MusicShopMono
DB Schema
Recomendation 	

ServiceMusicShopMono
DB Schema
Recomendation 	

ServiceMusicShopMono
DB
MusikShopMono
Warehouse Finance
Catalog Recommendation
Repository
DB
MusikShopMono
Warehouse Finance
Catalog Recommendation
Catalog
MusikShopMono
Catalog
Line Items
MusikShopMono
Catalog Finance
Line Items
MusikShopMono
Catalog Finance
Line Items Ledger
MusikShopMono
Catalog Finance
Line Items Ledger
MusikShopMono
Catalog Finance
Line Items Ledger
MusikShopMono
Catalog Finance
Line Items Ledger
MusikShopMono
Catalog Finance
Line Items Ledger
MusikShopMono
MusikShop
System
Finance ServiceCatalog Service
MusikShop
System
Finance ServiceCatalog Service
MusikShop
System
Line Items
Finance ServiceCatalog Service
MusikShop
System
Line Items Ledger
Finance ServiceCatalog Service
Country Codes
MusikShopMono
Finance
Warehouse
Catalog
Catalog
Finance
Warehouse
Country Codes
Country Codes
Country Codes
MusikShopMono
Catalog
Finance
Warehouse
MusikShopMono
Finance Warehouse
Customer Record
MusikShopMono
reify
Finance Warehouse
Customer Record
MusikShop
Finance Warehouse
Customer Record
Customer
MusikShop
Warehouse ServiceFinance Service
MusikShop
System
Customer Service
Catalog Warehouse
Item
MusikShop
Catalog Warehouse
Item
MusikShop
Bee Gees Hits | $4.99 | 45
Catalog Warehouse
Item
MusikShop
Bee Gees Hits | $4.99 | 45
Catalog Warehouse
Item
MusikShop
Bee Gees Hits | $4.99 | 45
Catalog Warehouse
Catalog Item
MusikShop
Stock Levels
DB
DB
Cost Of Change
@samnewman
Summary
• Split around bounded contexts	

• Make small, incremental changes	

• Split inside the process bounda...
CAP Theory
http://www.flickr.com/photos/76578519@N00/4695658106
What is CAP theory?
It is impossible for a distributed computer system
to simultaneously provide all three of the following
guarantees:
http:/...
Partition Tolerance
The system continues to operate despite arbitrary message
loss or failure of part of the system
Typica...
Node 1
Inventory Service
Master DB
dc1
Node 2
Slave DB
dc2
Load Balancer
Node 1
Inventory Service
Master DB
dc1
Node 2
Slave DB
dc2
Load Balancer
Option 1: Keep Node 2 serving traffic
Node 1
Master DB
Node 2
Slave DB
Load Balancer
Inventory Service
Option 1: Keep Node 2 serving traffic
Data is potentially
stale, but, we keep
Node 2 up Node 1
Master DB
Node 2
Slave DB
Lo...
Option 1: Keep Node 2 serving traffic
Data is potentially
stale, but, we keep
Node 2 up
We have
sacrificed
consistency for
a...
Option 2: Remove Node 2 from service
Node 1
Master DB
Node 2
Slave DB
Load Balancer
Inventory Service
Option 2: Remove Node 2 from service
Node 1
Master DB
Node 2
Slave DB
Load BalancerNow we have
had to degrade
availability...
Which is right?
What about sacrificing
Partition Tolerance?
Node 1
Inventory Service
Master DB
dc1
Node 2
Slave DB
dc2
Load Balancer
Node 1
Inventory Service
Master DB
dc1
Node 2
Slave DB
dc2
Load Balancer
So in general, we talk
about CP or AP systems
And now, Eventual
Consistency
Node 1 Node 1
Catalog
Service
Web Shop
Node 1 & 2 will have the
same catalog ‘eventually’
Node 1 Node 1
Catalog
Service
Web Shop
ttl: 5 mins
12:00
Node 1 & 2 will have the
same catalog ‘eventually’
Node 1 Node 1
Catalog
Service
Web Shop
ttl: 5 mins
12:00
Update12:02
Node 1 & 2 will have the
same catalog ‘eventually’
Node 1 Node 1
Catalog
Service
Web Shop
ttl: 5 mins
12:00
Update12:02
ttl: 5 mins
12:03
Node 1 & 2 will have the
same catal...
http://nathanmarz.com/blog/how-to-beat-the-cap-theorem.html
You can’t beat CAP
Theory
It’s Maths
http://lpd.epfl.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf
http://ferd.ca/beating-the-cap-theorem-checklist.html
You entire system
doesn’t need to be CP
or AP!
Catalog
Web Shop
Payment
ttl: 5 mins
Customer
Catalog
Web Shop
Payment
ttl: 5 mins
Customer
Catalog
Web Shop
Payment
ttl: 5 mins
Customer
Catalog
Web Shop
Payment
ttl: 5 mins
Customer
Catalog
Web Shop
Payment
ttl: 5 mins
Customer
Scary Thought
Web Shop
Master DB
* - http://blogs.msdn.com/b/pathelland/archive/2007/05/15/memories-guesses-and-apologies.aspx
Web Shop
Master DB
Let us consider a read
* - http://blogs.msdn.com/b/pathelland/archive/2007/05/15/memories-guesses-and-a...
Web Shop
Master DB
Let us consider a read
* - http://blogs.msdn.com/b/pathelland/archive/2007/05/15/memories-guesses-and-a...
Web Shop
Master DB
Let us consider a read
* - http://blogs.msdn.com/b/pathelland/archive/2007/05/15/memories-guesses-and-a...
Web Shop
Master DB
Is this ‘consistent’?
Let us consider a read
* - http://blogs.msdn.com/b/pathelland/archive/2007/05/15/...
Web Shop
Master DB
Is this ‘consistent’?
Let us consider a read
* - http://blogs.msdn.com/b/pathelland/archive/2007/05/15/...
Consistency = locks
locks in distributed systems are hard
and they are the enemy of scaling
https://static.googleusercontent.com/external_content/untrusted_dlcp/research.google.com/en//archive/chubby-osdi06.pdf
Web Shop
Inventory
Payment
Gateway
http://www.flickr.com/photos/63702881@N00/5038034651/
Web Shop
Inventory
Payment
Gateway
r
http://www.flickr.com/photos/63702881@N00/5038034651/
Web Shop
Inventory
Payment
Gateway
r
http://www.flickr.com/photos/63702881@N00/5038034651/
Web Shop
Inventory
Payment
Gateway
r
http://www.flickr.com/photos/63702881@N00/5038034651/
Web Shop
Inventory
Payment
Gateway
r
http://www.flickr.com/photos/63702881@N00/5038034651/
Transaction Club
• The first rule is…don’t!	

• If you really, really, really have to, consider
merging services first
Summary
• Understand if consistency or availability is
important - and this is normally a business
decision!	

• It isn’t ...
TESTING &
DEPLOYING
MICROSERVICES
Microservices Workshop
60
61
Accounts
Returns
Invoicing
Shipping
Inventory
Customer
Service
61
Accounts
Returns
Invoicing
Shipping
Inventory
Customer
Service
62
62
62
DB
63
Small
Medium
Large
TEST PYRAMID
Increasing Scope
More Confidence
Faster!
Better Isolation
64
DB
Small
Large
Medium
64
DB
Small
Large
Medium
65
DB
Small
Large
Medium
65
DB
Small
Large
Medium
66
DB
Small
Large
Medium
66
DB
Small
Large
Medium
66
DB
Small
Large
Medium
6767
Small
Medium
Large
TEST SNOWCONE
68
Small
Medium
Large
69
Small
Medium
Large
Build
Tests
Tests
Source
Control
…
BUILD PIPELINE
69
Small
Medium
Large
Build
Tests
Tests
Source
Control
Faster Feedback
…
BUILD PIPELINE
69
Small
Medium
Large
Build
Tests
Tests
Source
Control
Faster Feedback
Binary Artifact(s)
…
BUILD PIPELINE
69
Small
Medium
Large
Build
Tests
Tests
Source
Control
Faster Feedback
Binary Artifact(s)
…
BUILD PIPELINE
70
DB
70
DB
71
S/M TestsBuild Large Tests UAT Prod
71
S/M TestsBuild Large Tests UAT Prod
DB
Machine CI Node
Large Tests Environment
Large Tests
72
S/M TestsBuild Large Tests UAT Prod
DB
Machine
UAT Environment
Machine
73
S/M TestsBuild Large Tests UAT Prod
Master
DB
Machine
Production Environment
Machine Machine Machine
Slave
DB
74
S/M TestsBuild Large Tests UAT Prod
More Production Like
74
S/M TestsBuild Large Tests UAT ProdLarge Tests
More Production Like
74
S/M TestsBuild Large Tests UAT ProdLarge Tests
Faster Feedback
More Production Like
75
Customer Service
75
Customer Service
S/M TestsBuild Large Tests
75
Customer Service
S/M TestsBuild Large Tests
75
Customer Service
S/M TestsBuild Large Tests
76
Customer
Service
Web Shop
Fulfilment
Service
76
Customer
Service
Web Shop
Fulfilment
Service
Large
Medium
Small
77
Customer
Service
Fulfilment
Service
Large
Medium
Small
77
Customer
Service
Fulfilment
Service
Large
Medium
Small
77
Customer
Service
Large
Medium
Small
Fulfilment
Service
Stub
78
Mountebank
http://www.mbtest.org
79
mountebank
:2525
79
mountebank
:2525
79
mountebank
:2525
:5555
79
mountebank
:2525
:5555
Customer
Service
80
S/M TestsBuild Large Tests
80
S/M TestsBuild Large Tests
Customer
Service
Fulfilment
Service
Stub
81
Customer
Service
V1
Web Shop
Fulfilment
Service
81
Web Shop
Customer
Service
v2
Fulfilment
Service
81
Web Shop
Customer
Service
v2
Fulfilment
Service
81
Web Shop
Customer
Service
v2
Fulfilment
Service
82
S/M TestsBuild Large Tests
Customer
Service
Customer
Service
v1
Web Shop
v1
Production
82
S/M TestsBuild Large Tests Integration Test
Customer
Service
Customer
Service
v1
Web Shop
v1
Production
82
S/M TestsBuild Large Tests Integration Test
Customer
Service
Customer
Service
v1
Web Shop
v1
Production
Customer
Servic...
83
Customer
Service
v1
Web Shop
v1
Production
83
Customer
Service
v1
Web Shop
v1
Production
S/M TestsBuild Large Tests Integration Test
Customer
Service
Customer
Servic...
83
S/M TestsBuild Large TestsWeb Shop
Customer
Service
v1
Web Shop
v1
Production
S/M TestsBuild Large Tests Integration Te...
83
S/M TestsBuild Large TestsWeb Shop
Customer
Service
v1
Web Shop
v1
Production
S/M TestsBuild Large Tests Integration Te...
83
S/M TestsBuild Large TestsWeb Shop
Customer
Service
v1
Web Shop
v1
Production
S/M TestsBuild Large Tests Integration Te...
84
S/M TestsBuild Large TestsWeb Shop
S/M TestsBuild Large Tests
Customer
Service
84
S/M TestsBuild Large TestsWeb Shop
S/M TestsBuild Large Tests
Customer
Service
Integration Test
84
S/M TestsBuild Large TestsWeb Shop
S/M TestsBuild Large Tests
Customer
Service
Integration Test
S/M TestsBuild Large Te...
84
S/M TestsBuild Large TestsWeb Shop
S/M TestsBuild Large Tests
Customer
Service
Integration Test
S/M TestsBuild Large Te...
84
S/M TestsBuild Large TestsWeb Shop
S/M TestsBuild Large Tests
Customer
Service
Integration Test
S/M TestsBuild Large Te...
85
85
Browsers
85
Timing
Browsers
85
Provisioning of Environments
Timing
Browsers
85
Provisioning of Environments
Networks
Timing
Browsers
85
Deployment
Provisioning of Environments
Networks
Timing
Browsers
85
Deployment
Provisioning of Environments
Networks
Timing
Browsers Diagnosis
86
86
Integration Test
86
Integration Test Prod…
86
Integration Test Prod…
86
Integration Test Prod…
86
Integration Test Prod…
87
87
88
John Allspaw: “Ops Metametrics” http://slidesha.re/dsSZIr
88
John Allspaw: “Ops Metametrics” http://slidesha.re/dsSZIr
89
Integration Test Prod…
v1v2
v6
v4 = v10
89
Integration Test Prod…
v1v2
v6
v4 = v10
90
Danger Will Robinson!
91
Show Tangle
92
Golden Rule:
Get good at releasing services independently
93
SO NO INTEGRATION TESTS?
94
94
94
SEMANTIC MONITORING
95
Customer
Service
Web Shop
95
Customer
Service
Web Shop
Small
Medium
Large
95
Customer
Service
Web Shop
Small
Medium
Large
95
Customer
Service
Web Shop
Small
Medium
Large
Consumer Driven Contracts
96
Customer
Service
Web Shop
96
Customer
Service
Web Shop
Expectations
96
Customer
Service
Web Shop
Expectations
96
Customer
Service
Web Shop
Expectations
Prod
96
Customer
Service
Web Shop
Expectations
Prod
97
97
https://github.com/realestate-com-au/pact
98
Prod
Prod
Prod
Prod
98
Prod
Prod
Prod
Prod
98
Prod
Prod
Prod
Prod
QA
98
Prod
Prod
Prod
Prod
QA
Good Monitoring
98
Prod
Prod
Prod
Prod
QA
Good Monitoring
Fast Remediation
98
Prod
Prod
Prod
Prod
QA
Good Monitoring
Fast Remediation
99
S/M TestsBuild Large Tests UAT ProdLarge Tests
Faster Feedback
More Production Like
99
S/M TestsBuild Large Tests UAT ProdLarge Tests
Faster Feedback
More Production Like
99
S/M TestsBuild Large Tests UAT ProdLarge Tests
Faster Feedback
More Production Like
100
DB
Machine CI Node
Large Tests Environment
S/M TestsBuild Large Tests UAT ProdLarge TestsLarge Tests
100
DB
Machine CI Node
Large Tests Environment
DB
Machine
UAT Environment
Machine
S/M TestsBuild Large Tests UAT ProdLarge...
100
DB
Machine CI Node
Large Tests Environment
DB
Machine
UAT Environment
Machine
Master
DB
Machine
Production Environment...
101
Faster Feedback
More Production Like
S/M TestsBuild Large Tests UAT ProdLarge Tests
101
Faster Feedback
More Production Like
S/M TestsBuild Large Tests UAT ProdLarge Tests
102
103
104
Ansible
Puppet
Chef
104
Ansible
Puppet
Chef
104
Ansible
Puppet
Chef
AWS
104
Ansible
Puppet
Chef
AWS
Digital Ocean
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
Vagrant
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
Vagrant
Immutable Servers
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
Vagrant
Immutable Servers
Fast Spin-up
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
Vagrant
Immutable Servers
Fast Spin-up
Provider Agnostic
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
Vagrant
Immutable Servers
Fast Spin-up
Provider Agnostic
Feedba...
104
Ansible
Puppet
Chef
AWS
Digital Ocean
OpenStack
VMWare
Vagrant
Immutable Servers
Fast Spin-up
Provider Agnostic
Feedba...
105
Prod
Prod
Prod
Prod
105
Prod
Prod
Prod
Prod
Packer Images
105
Prod
Prod
Prod
Prod
“Machine”
Service
Packer Images
105
Prod
Prod
Prod
Prod
“Machine”
Service
“Machine”
Service Service
Packer Images
105
Prod
Prod
Prod
Prod
“Machine”
Service
“Machine”
Service Service
Packer Images
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
AWS
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
AWS
VMWare
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
AWS
VMWare
Vagrant
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
AWS
VMWare
Vagrant
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
AWS
VMWare
Vagrant
106
S/M TestsBuild Large Tests UAT ProdLarge Tests
AWS
VMWare
Vagrant
107
“Machine”
Service
107
“Machine”
Service
Much Easier To Reason About
107
“Machine”
Service
Much Easier To Reason About
Easier To Provision (Or Decommission)
107
“Machine”
Service
Much Easier To Reason About
Easier To Provision (Or Decommission)
Fewer Side-effects
107
“Machine”
Service
Much Easier To Reason About
Easier To Provision (Or Decommission)
Fewer Side-effects
Cost & Managemen...
107
“Machine”
Service
Much Easier To Reason About
Easier To Provision (Or Decommission)
Fewer Side-effects
Cost & Managemen...
107
“Machine”
Service
Much Easier To Reason About
Easier To Provision (Or Decommission)
Fewer Side-effects
Cost & Managemen...
108
STANDARD VIRTUALISATION
108
Machine
STANDARD VIRTUALISATION
108
Machine
Base OS
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
VM
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
VM
OS
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
VM
OS
Apps
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
VM
OS
Apps
Packer Image
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
VM
OS
Apps
VM
OS
Apps
Packer Image
STANDARD VIRTUALISATION
108
Machine
Base OS
Hypervisor
VM
OS
Apps
VM
OS
Apps
VM
OS
Apps
Packer Image
STANDARD VIRTUALISATION
109
110
CONTAINER VIRTUALISATION
110
Machine
CONTAINER VIRTUALISATION
110
Machine
Base OS
CONTAINER VIRTUALISATION
110
Machine
Base OS
Container
CONTAINER VIRTUALISATION
110
Machine
Base OS
Container
OS
CONTAINER VIRTUALISATION
110
Machine
Base OS
Container
OS
Apps
CONTAINER VIRTUALISATION
110
Machine
Base OS
Container
OS
Apps
Container
OS
Apps
CONTAINER VIRTUALISATION
110
Machine
Base OS
Container
OS
Apps
Container
OS
Apps
Container
OS
Apps
CONTAINER VIRTUALISATION
110
Machine
Base OS
Container
OS
Apps
Container
OS
Apps
Container
OS
Apps
CONTAINER VIRTUALISATION
Linux Only
110
Machine
Base OS
Container
OS
Apps
Container
OS
Apps
Container
OS
Apps
CONTAINER VIRTUALISATION
Same Kernel
Linux Only
110
Machine
Base OS
Container
OS
Apps
Container
OS
Apps
Container
OS
Apps
CONTAINER VIRTUALISATION
Same Kernel
Linux OnlyF...
110
Machine
Base OS
Container
OS
Apps
Container
OS
Apps
Container
OS
Apps
CONTAINER VIRTUALISATION
Same Kernel
Linux OnlyF...
111
112
DOCKER
112
DOCKER
Machine
112
DOCKER
Machine
Base OS
112
DOCKER
Machine
Base OS
Docker
112
DOCKER
Machine
Base OS
Docker
Apps
112
DOCKER
Machine
Base OS
Docker
Apps Apps
112
DOCKER
Machine
Base OS
Docker
Apps Apps Apps
112
DOCKER
Machine
Base OS
Docker
Apps Apps Apps
Docker Image Registry
112
DOCKER
Machine
Base OS
Docker
Apps Apps Apps
Docker Image Registry
113
113
114
S/M TestsBuild Large Tests UAT ProdLarge Tests
114
S/M TestsBuild Large Tests UAT ProdLarge Tests
Docker Image
114
S/M TestsBuild Large Tests UAT ProdLarge Tests
Docker Image Registry
Docker Image
114
S/M TestsBuild Large Tests UAT ProdLarge Tests
Docker Image Registry
Docker Image
114
S/M TestsBuild Large Tests UAT ProdLarge Tests
Docker Image Registry
Docker Image
115
115
Be aware of - and balance - your test Pyramid
115
Be aware of - and balance - your test Pyramid
Understand the balance between testing & rapid remediation
115
Be aware of - and balance - your test Pyramid
Understand the balance between testing & rapid remediation
Deploy one th...
115
Be aware of - and balance - your test Pyramid
Understand the balance between testing & rapid remediation
Deploy one th...
115
Be aware of - and balance - your test Pyramid
Understand the balance between testing & rapid remediation
Deploy one th...
Operational
Complexity
Alert!!!
UP
DOWN
DOWN
DOWN
Too slow?
UP?
UP? DOWN?
UP? DOWN?
Too slow? Where is the problem?
“it pushes the accidental complexity into the infrastructure”
Martin Fowler
“it pushes the accidental complexity into the infrastructure”
Martin Fowler
monitoring and logging are essential
Architectural Safety
Measures
“Every socket, process, pipe, or remote
procedure call can and will hang. Even
database calls [...]”	

M. Nygard,“Release ...
Cascading Failures
• Happen when a problem in a service causes
a problem in one or more consumers of
that service	

• Beco...
Failure Types
• Rejected connections	

• Dropped ACKs	

• Slow responses (these are the nasty ones!)
Defense Mechanisms
• Resource pools	

• Timeouts	

• Circuit breakers	

• Bulkheads	

• Fail fast
Circuit Breakers
• If a service consistently fails, stop calling it
for a while!
MusikShop v1
Rekomender
v124
www.MusikShop
Take That
Queens Of The
Stone Age
Snoop Dogg
We Rekomend ‘The
Brakes’!
MusikShop v1
Rekomender
v124
www.MusikShop
Take That
Queens Of The
Stone Age
Snoop Dogg
We Rekomend ‘The
Brakes’!
MusikShop v1
Rekomender
v124
www.MusikShop
Take That
Queens Of The
Stone Age
Snoop Dogg
We Rekomend ‘The
Brakes’!
We Can’t...
MusikShop v1
Rekomender
v124
www.MusikShop
Take That
Queens Of The
Stone Age
Snoop Dogg
We Rekomend ‘The
Brakes’!
We Can’t...
MusikShop v1
Rekomender
v124
www.MusikShop
Take That
Queens Of The
Stone Age
Snoop Dogg
We Rekomend ‘The
Brakes’!
Bulkheads
• = Damage containment	

• Separate resource pools	

• Partitioned servers
Fail Fast
• Check (and perhaps reserve) required
resources before processing a request	

• Reject immediately if, say, a c...
Monitoring
Response time tracking
Response time tracking
Log aggregation
Response time tracking
Log aggregation
Monitor down-stream 	

dependencies
Response time tracking
Log aggregation
Monitor down-stream 	

dependencies
Response time tracking
Log aggregation
Monitor down-stream 	

dependencies
UP?
DOWN?
Track health
For every instance of
every service…
For every instance of
every service…
And you want to
standardize
For every instance of
every service…
And you want to
standardize
…needs to be status
aware
source: https://github.com/Netflix/Hystrix/wiki/Dashboard
remember hystrix?
aggregated dashboards
Logstash &
Kibana
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
ID 123
Correlation IDs
Synthetic Transactions
How Small?
This might be the
wrong question
How many >> size
So how many is too
many?
From an architectural &
operations view...
How many >> how small
From an architectural &
operations view...
Pain?
Pain? Pain?
http://www.flickr.com/photos/oufoufsworld/1233382476/
Summary
• Complexity doesn’t vanish, but with help it
can be more evident	

• Monitoring & architectural safety measures
a...
Organisational
Structures & Conway’s
Law
"organizations which design systems ... are
constrained to produce designs which are
copies of the communication structure...
“If seven people create a compiler, you get a
seven pass compiler”
- Dan North, not quite a dude
http://www.flickr.com/photos/chijs/2869992728/
http://www.flickr.com/photos/noodlepie/7256072798/
High change
frequency
Fine-grained
High change
frequency
Fine-grained
High change
frequency
Fine-grained
Low change
frequency
Coarse-grained
= Pain!
http://www.flickr.com/photos/a_ninjamonkey/3565672226/
#123
As a despot when I
press the big red
button I want...
#123
As a despot when I
press the big red
button I want...
Splitting Stories
• When splitting, try and synchronise the
work	

• Consider re-assigning service ownership
temporarily	
...
Conway’s law!
#123
As a despot when I
press the big red
button I want...
#123
As a despot when I
press the big red
button I want...
Problems:
#123
As a despot when I
press the big red
button I want...
Consistency of XD
Problems:
#123
As a despot when I
press the big red
button I want...
Consistency of XD
Sequencing
Problems:
#123
As a despot when I
press the big red
button I want...
Consistency of XD
Sequencing
Bottlenecks
Problems:
#123
As a despot when I
press the big red
button I want...
Consistency of XD
Sequencing
Bottlenecks
Testing
Problems:
#123
As a despot when I
press the big red
button I want...
Consistency of XD
Sequencing
Bottlenecks
TL, QA,
PM
Testing
Pro...
Summary
• In general assign services to team...	

• ...where team means a co-located group of
people	

• Strongly splittin...
Security
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
Authentication
• Starting point: HTTP Basic
Authentication + SSL/TLS	

• It gives us:	

• Confidentiality and Integrity
gua...
Why start here?
• Simple and secure	

• Stable standards with implementations that
have been battle hardened	

• Straightf...
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
SSL everywhere?
Exception 1
• Scenario:All data is 100% public
information	

• No need for strict authentication or crypto	

• Use API key...
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
Exception 2
• Scenario: I must have strong crypto
guarantees for my authentication	

• Use SSL/TLS with client certificates...
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
Exception 3
• Scenario: Some/all of the APIs will be
consumed by native mobile applications	

• Consider OAuth 2.0 + SSL/T...
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
OAuth 2.0 drawbacks
• It’s a “framework”, not a protocol	

• Interop isn't guaranteed as not all
implementations support a...
At vs inside perimeter
• Services that are only consumed by
services inside the firewall don’t have to
use the same mechani...
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
Form AuthOAuthAPI Ke...
Confused deputy
• Fool downstream service into accessing
resource the user shouldn’t have access to	

• Harder when lots o...
Catalog
service
Music
Web Shop
Recommend
service
Royalty
service
Mobile
app
Web
browsers
User
service
What about SAML?
• Over-complicated	

• SOAP focused*	

• Some interop problems	

• Workable if your organisation already ...
OpenID Connect
• Builds on OAuth 2.0, adds an identity layer	

• Reinvents SAML, but HTTP friendly	

• Tokens are no longe...
What about S3 Auth?
• HMAC-based, uses “secret key”	

• HTTP Authorization header/status code	

• Benefit: No server-side s...
CONCLUSIONS
Microservices Workshop
190
191
http://martinfowler.com/articles/microservices.html
192
Sam Newman
Building
Microservices
DESIGNING FINE-GRAINED SYSTEMS
193
194
https://www.flickr.com/photos/futurowoman/2923992303
195
Monitoring
Deployment
Testing
Organisational Structure
Integration
Architectural Safety
196
Go Incremental
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Agile Australia 2014: Workshop - Design and Implementation of Microservices
Upcoming SlideShare
Loading in …5
×

Agile Australia 2014: Workshop - Design and Implementation of Microservices

1,225 views

Published on

Design and Implementation of Microservices
Sam Newman - Technical Consultant, ThoughtWorks
Scott Shaw - Head of Technology, ThoughtWorks

Discover a consistent and reinforcing set of tools and practices rooted in the philosophy of small and simple; this can help you move towards a microservice architecture.

Published in: Business, Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,225
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
89
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

Agile Australia 2014: Workshop - Design and Implementation of Microservices

  1. 1. Microservices ThoughtWorks
  2. 2. Scott Shaw @scottwshaw Sam Newman @samnewman
  3. 3. Schedule • 09:00 - 10:30 Session 1 • 10:30 - 10:45 Break • 10:45 - 12:00 Session 2 • 12:00 - 13:15 Lunch • 13:15 - 15:00 Session 3 • 15:00 - 15:30 Break • 15:30 - 17:00 Session 4
  4. 4. 09:00 - 10:30 Session 1 • Introduction • Icebreaker • Why Services • Principes & Constraints • Evolutionary Architecture
  5. 5. 10:45 - 12:00 Session 2 • Integration
  6. 6. 13:15 - 15:00 Session 3 • Splitting Services • CAP & Transactions • Testing & CDCs • Operational Concerns
  7. 7. 15:00 - 15:30 Session 4 • Deploying • UI & Mobile • Conway’s Law • Security
  8. 8. http://www.flickr.com/photos/55255903@N07/6835060992
  9. 9. http://www.flickr.com/photos/22154104@N00/3466383400
  10. 10. http://www.flickr.com/photos/sailbit/3409405778/
  11. 11. Why Services?
  12. 12. or: are we building systems that are too big?
  13. 13. 90% of the TCO of an application is incurred post launch
  14. 14. IT  project-­related  losses  are  an  embarrassment  for  the  industry  fund  backers  –  Australian​Super,  Cbus,  HOSTPLUS,  HESTA  and  MTAA  Super  – which  pride  themselves  on  low  fees  and  improving  member  services.   Illustration:  Karl  Hilzinger A group of industry superannuation funds has revealed in accounts lodged with the Australian Securities and Investments Commission that the cost of implementing a key IT project has blown out by another $43 million. This means that a project that started in 2008 and was meant to be completed by 2010 will cost super fund members at least $250 million and will be delivered at least four years late. Superpartners, a super administration company owned by five industry retirement schemes, posted a $7.4 million loss on revenues of $257 million for the 12 months ended June 30, after being forced to take a $20.4 million impairment Superpartners’ botched IT project costs industry super funds millions Published  26  November  2013  01:17,  Updated  27  November  2013  07:46 Sally  Patten
  15. 15. we have to rewrite entire ecosystems every few years
  16. 16. we have to rewrite entire ecosystems every few years this doesn’t make many CFO’s happy
  17. 17. scary story
  18. 18. Retail Site Departure Control
  19. 19. Retail Site Departure Control
  20. 20. Retail Site Departure Control
  21. 21. Retail Site Departure Control 48 Cores ! 256 GB RAM (NUMA) ! ~ $1 x 106 per machine
  22. 22. 22
  23. 23. Airline Tightly coupled “Golden Hammer Syndrome” Single point of failure Expensive to scale High operational cost High cost of failure
  24. 24. 24
  25. 25. Airline Retail Site Departure Control
  26. 26. Airline Retail Site Departure Control
  27. 27. Airline Retail Site Departure Control
  28. 28. Airline Retail Site Departure Control X
  29. 29. scary story
  30. 30. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  31. 31. The stovepipe enterprise Stovepipes)are)“systems)procured)and)developed)to)solve)a)specific)problem,) characterized)by)a)limited)focus)and)func:onality,)and)containing)data)that) cannot)be)easily)shared)with)other)systems.”)(DOE)1999)) DOE.%Commi*ee%to%Assess%the%Policies%and%Prac7ces%of%the%Department%of%Energy,%Improving%Project% Management%in%the%Department%of%Energy,%Na7onal%Academy%Press,%Washington,%D.C.,%1999,%page%133.%
  32. 32. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  33. 33. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  34. 34. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access ? HR UI "Middleware DB" ? ? ? UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access UI / Service Direct db access Direct db access HR UI "Middleware DB" ? ? ? UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access UI / Service Direct db access Direct db access HR UI "Middleware DB" ? ? ? UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access UI / Service Direct db access Direct db access HR UI "Middleware DB" ? ? ? Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access UI / Service Direct db access
  35. 35. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? Logic scattered all over the place Data scattered all over the place Difficult to predict the effect of changes Which system is right? BI / MI almost impossible to get at
  36. 36. V1
  37. 37. V2
  38. 38. Go JVM NodeJS Ruby
  39. 39. Go JVM NodeJS Ruby
  40. 40. Go NodeJS Ruby Clojure!
  41. 41. Why now?
  42. 42. standing on the shoulders of giants
  43. 43. Engineering for: reliability and availability Devops circuit breakers, health checks, status pages
  44. 44. Strategic Design Bounded Contexts “town planning”
  45. 45. web integration application protocols HATEOAS
  46. 46. infrastructure automation patterns for push button deployments the lean software value stream
  47. 47. Summary We understand more about building reliable distributed systems cloud compute and programmable infrastructure has matured organisations need to adapt and change quickly to survive we spend too much money on building monoliths
  48. 48. Evolutionary Architecture
  49. 49. “Just enough architecture”
  50. 50. towns are zoned
  51. 51. heavy industrial
  52. 52. commercial
  53. 53. light residential
  54. 54. Would you build a playground next to a power station?
  55. 55. Would you build a playground next to a power station?
  56. 56. Would you build a playground next to a power station? a sewage works next to Macy’s?
  57. 57. Towns share utilities
  58. 58. Everyone uses 240V DC right?
  59. 59. and it would be a bad idea not to use the same language for stop signs...
  60. 60. emergent design is within the zones
  61. 61. emergent design is within the zones
  62. 62. evolutionary architecture is in the gaps emergent design is within the zones
  63. 63. evolutionary architecture is in the gaps emergent design is within the zones
  64. 64. • Things to think about: • Concentrate on the business capabilities • technical acronyms make us think the wrong way • What are the common features? Integration methods? • What different types of data live where?
  65. 65. it can be a single system and its component parts or chunking up to how your systems integrate with others and if you can’t remember thats ok too, we don’t want perfect, just something to work with
  66. 66. Summary do just enough up front evolutionary architecture is in the gaps emergent design is in the boxes
  67. 67. Bounded Contexts
  68. 68. What makes a good service?
  69. 69. High Cohesion
  70. 70. Loose Coupling
  71. 71. The Trifle
  72. 72. The Trifle Musik Web
  73. 73. The Trifle Musik Web Persistence
  74. 74. The Trifle Musik Web Persistence
  75. 75. The Trifle Musik Web Persistence
  76. 76. The Trifle Musik Web Persistence
  77. 77. “A set of capabilities on an endpoint”
  78. 78. Bounded Context
  79. 79. "The delimited applicability of a particular model. BOUNDING CONTEXTS gives team members a clear and shared understanding of what has to be consistent and what can develop independently."
  80. 80. A specific responsibility enforced by explicit boundaries ! http://www.sapiensworks.com/blog/post/ 2012/04/17/DDD-The-Bounded-Context- Explained.aspx
  81. 81. Add to cart
  82. 82. Add to cart Checkout
  83. 83. Add to cart Checkout View Latest Releases
  84. 84. Add to cart Checkout View Latest Releases Search
  85. 85. Add to cart Checkout View Latest Releases Search Listen To Previews
  86. 86. Add to cart Checkout View Latest Releases Search Listen To Previews
  87. 87. Add to cart Checkout View Latest Releases Search Listen To Previews Shopping Cart Catalog Music Library
  88. 88. Hexagonal Architectures 83 bounded contexts all the way down (and back up again)
  89. 89. Object Object Object Object
  90. 90. Object James’ conjecture “objects should be no bigger than my head”
  91. 91. Object
  92. 92. Object Object Object Object
  93. 93. as we chunk up domains of abstraction, each domain should be small enough to fit in my head
  94. 94. 93 in this case, it meant 100’s of lines of code per application
  95. 95. Architecture Principles
  96. 96. to build systems is to make trade-offs
  97. 97. to build systems is to make trade-offs throughput vs cost
  98. 98. to build systems is to make trade-offs throughput vs cost
  99. 99. to build systems is to make trade-offs throughput vs cost portability vs deployability
  100. 100. to build systems is to make trade-offs throughput vs cost portability vs deployability
  101. 101. to build systems is to make trade-offs throughput vs cost portability vs deployability replacability vs maintainability
  102. 102. to build systems is to make trade-offs throughput vs cost portability vs deployability replacability vs maintainability evolutionary architecture and emergent design are approaches that maximise flex
  103. 103. you want to maximise the degrees of freedom of your system
  104. 104. The idea of architecture principles is to try and balance these tradeoffs
  105. 105. to try and balance short term gain with longer term strategic goals The idea of architecture principles is to try and balance these tradeoffs
  106. 106. to try and balance short term gain with longer term strategic goals The idea of architecture principles is to try and balance these tradeoffs
  107. 107. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously The idea of architecture principles is to try and balance these tradeoffs
  108. 108. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously The idea of architecture principles is to try and balance these tradeoffs
  109. 109. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously They should move you towards a state where the tradeoffs don’t happen so often or have such large impact The idea of architecture principles is to try and balance these tradeoffs
  110. 110. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously They should move you towards a state where the tradeoffs don’t happen so often or have such large impact The idea of architecture principles is to try and balance these tradeoffs They should be driven by the goals of the business
  111. 111. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously They should move you towards a state where the tradeoffs don’t happen so often or have such large impact The idea of architecture principles is to try and balance these tradeoffs They should be driven by the goals of the business
  112. 112. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously They should move you towards a state where the tradeoffs don’t happen so often or have such large impact The idea of architecture principles is to try and balance these tradeoffs They should be driven by the goals of the business for the next 18-24 months
  113. 113. to try and balance short term gain with longer term strategic goals Where trade offs have to be made they should be done so visibility and consciously They should move you towards a state where the tradeoffs don’t happen so often or have such large impact The idea of architecture principles is to try and balance these tradeoffs They should be driven by the goals of the business for the next 18-24 months any longer and you are only fooling yourself
  114. 114. and if you don’t know what your business goals are...
  115. 115. and if you don’t know what your business goals are... may we respectfully suggest that you go and find them out!
  116. 116. The idea of constraints is to allow your teams the freedom to make decisions within a consistent framework
  117. 117. The idea of constraints is to allow your teams the freedom to make decisions within a consistent framework
  118. 118. The idea of constraints is to allow your teams the freedom to make decisions within a consistent framework this is not about “not allowed to break them”, this is about having a conversation
  119. 119. The idea of constraints is to allow your teams the freedom to make decisions within a consistent framework this is not about “not allowed to break them”, this is about having a conversation
  120. 120. The idea of constraints is to allow your teams the freedom to make decisions within a consistent framework this is not about “not allowed to break them”, this is about having a conversation these work best when backed up by tooling that makes it easy to do the right thing
  121. 121. The idea of constraints is to allow your teams the freedom to make decisions within a consistent framework this is not about “not allowed to break them”, this is about having a conversation these work best when backed up by tooling that makes it easy to do the right thing shall we take a look at some examples?
  122. 122. http://www.12factor.net/
  123. 123. Heroku’s 12 factors are a mixture of principles and constraints http://www.12factor.net/
  124. 124. never return directly from a POST
  125. 125. favour choreography over orchestration never return directly from a POST
  126. 126. favour choreography over orchestration don’t share domain code (and physically separate the codebases to ensure this) never return directly from a POST
  127. 127. favour choreography over orchestration don’t share domain code (and physically separate the codebases to ensure this) scale using processes, not threads never return directly from a POST
  128. 128. favour choreography over orchestration don’t share domain code (and physically separate the codebases to ensure this) scale using processes, not threads don’t use session state never return directly from a POST
  129. 129. Integration
  130. 130. or…
  131. 131. Avoiding Babel
  132. 132. Two Key Attributes Of A Good Service
  133. 133. 1. High Cohesion ! 2. Loose Coupling
  134. 134. 1. High Cohesion ! 2. Loose Coupling
  135. 135. © 2013 Electronic Arts Inc.
  136. 136. Otherwise… http://www.flickr.com/photos/mikecogh/4472054494/
  137. 137. Integration Styles An Evolutionary View Data Oriented Procedure Oriented Document Oriented Resource Oriented
  138. 138. Databases
  139. 139. DB MusikShopMono
  140. 140. DB Schema Recomendation Service MusicShopMono
  141. 141. DB Schema Recomendation ServiceMusicShopMono
  142. 142. DB Schema Recomendation ServiceMusicShopMono
  143. 143. DB Schema Recomendation ServiceMusicShopMono No loose coupling!
  144. 144. DB Schema Recomendation Service MusicShopMono DB Schema Magic ETL
  145. 145. which is ok until...
  146. 146. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of External Data Read only data Read only data Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access which is ok until... and yes, this is a real world example...
  147. 147. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of External Data Read only data Read only data Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access changing anything is really really hard
  148. 148. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ? different types of data are smeared about
  149. 149. HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  150. 150. systems like this are brittle HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  151. 151. systems like this are brittle difficult to reason aboutHR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  152. 152. systems like this are brittle difficult to reason about difficult to change HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  153. 153. systems like this are brittle difficult to reason about difficult to change difficult to maintain HR UI "Middleware DB" ? ? ? Data Warehouse ? canned reports cubes / ad-hoc UIUI UI Finance UI Views of external Data Read only external data Read only external dataDirect db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access Direct db access SSO UI / Service AD Direct db access Direct db access ?
  154. 154. Next!
  155. 155. RPC
  156. 156. method calls across a process boundary
  157. 157. consider a client invoking the createUser endpoint
  158. 158. consider a client invoking the createUser endpoint
  159. 159. createUser(id, ! firstName, ! lastName,! address) consider a client invoking the createUser endpoint
  160. 160. other clients can use the same call as the first createUser(id, ! firstName, ! lastName,! address)
  161. 161. other clients can use the same call as the first createUser(id, ! firstName, ! lastName,! address) so far so good
  162. 162. but what happens when you want to change how one of the clients calls your service?
  163. 163. but what happens when you want to change how one of the clients calls your service? maybe I don’t want to use first name and last name anymore
  164. 164. I want to use the ‘fullname’ createUser(id, ! firstName, ! lastName,! address) createUserByFullname(! id, ! fullName,! address)
  165. 165. or I want to specify address individually createUser(id, ! firstName, ! lastName,! address) createUserByFullname(! id, ! fullName,! address) createUserByFullnameAnd Address(! id, ! fullName,! street1,! street2,! zipcode)
  166. 166. one of two things tends to happen with systems of this type
  167. 167. one of two things tends to happen with systems of this type 1. you end up with very long service definitions
  168. 168. one of two things tends to happen with systems of this type 1. you end up with very long service definitions 2. coordination of changes to clients becomes difficult
  169. 169. 1. specifications quickly become very very long and a nightmare to maintain
  170. 170. 1. specifications quickly become very very long and a nightmare to maintain createUserWithFullname(...)
  171. 171. 1. specifications quickly become very very long and a nightmare to maintain createUserWithFullname(...) createUser(...)
  172. 172. 1. specifications quickly become very very long and a nightmare to maintain createUserWithFullname(...) createUser(...) createUserWithFullnameAndAddress (...)
  173. 173. 1. specifications quickly become very very long and a nightmare to maintain createUserWithFullname(...) createUser(...) createUserWithFullnameAndAddress (...) createUserWithAddress(...)
  174. 174. 1. specifications quickly become very very long and a nightmare to maintain createUserWithFullname(...) createUser(...) createUserWithFullnameAndAddress (...) createUserWithAddress(...) every time I want to change some logic, I have to change every method call
  175. 175. 2. you have to coordinate the release cycles of your clients createUser(id, ! firstName, ! lastName,! address)
  176. 176. createUser(id, ! firstName, ! lastName,! address) createUser(id, ! fullname, ! address) @deprecated 2. you have to coordinate the release cycles of your clients
  177. 177. createUser(id, ! firstName, ! lastName,! address) createUser(id, ! fullname, ! address) @deprecated and if you have many clients, thats no easy task 2. you have to coordinate the release cycles of your clients
  178. 178. A Brief Aside…
  179. 179. Who can tell me about RFC 761?
  180. 180. Postel’s Law: “Be liberal in what you do, conservative in what you expect”
  181. 181. Practical impact of this - only bind to what you need to reduce breaking service consumption
  182. 182. Service B Service A Shared Lib v1 Shared Lib v1
  183. 183. Service B Service A Shared Lib v1 Shared Lib v1
  184. 184. Service B Service A Shared Lib v1 Shared Lib v1
  185. 185. Service B Service A Shared Lib v1 Shared Lib v1 Shared Lib v2
  186. 186. Service B Service A Shared Lib v1 Shared Lib v1 Shared Lib v2 Beware of shared serialization protocols
  187. 187. Service B Service A Shared Lib v1 Shared Lib v1 Shared Lib v2 Beware of shared serialization protocols WSDL-binding
  188. 188. Service B Service A Shared Lib v1 Shared Lib v1 Shared Lib v2 Beware of shared serialization protocols WSDL-binding JAXB
  189. 189. Service B Service A Shared Lib v1 Shared Lib v1 Shared Lib v2 Beware of shared serialization protocols WSDL-binding JAXB Java Serialization
  190. 190. Messaging
  191. 191. (AMC / Associated Press)
  192. 192. a bit like going back to the 50’s enterprise (AMC / Associated Press)
  193. 193. a bit like going back to the 50’s enterprise except without the smoking and the rampant misogyny (AMC / Associated Press)
  194. 194. back in the day, if you wanted to book a holiday, you didn’t go onto your corporate intranet to do it right?
  195. 195. back in the day, if you wanted to book a holiday, you didn’t go onto your corporate intranet to do it right? you went to the cupboard
  196. 196. back in the day, if you wanted to book a holiday, you didn’t go onto your corporate intranet to do it right? you went to the cupboard and you pulled out one of these
  197. 197. back in the day, if you wanted to book a holiday, you didn’t go onto your corporate intranet to do it right? you went to the cupboard and you pulled out one of these and you filled it in
  198. 198. james’ holiday request form and then you sent it to the HR department
  199. 199. james’ holiday request form and then you sent it to the HR department where it was processed, and eventually you got another envelope back containing the approval
  200. 200. and messaging is a bit like that
  201. 201. and messaging is a bit like that asynchronous
  202. 202. and messaging is a bit like that asynchronous after all, you wouldn’t want to block waiting for internal mail right?
  203. 203. incidentally, I wasn’t actually there in the 50’s. I just have this on good authority and messaging is a bit like that asynchronous after all, you wouldn’t want to block waiting for internal mail right?
  204. 204. generally you create a message composed of a document
  205. 205. and you push it onto some kind of queue
  206. 206. and you push it onto some kind of queue
  207. 207. systems interested in your documents can pop those documents and act on them
  208. 208. systems interested in your documents can pop those documents and act on them
  209. 209. and return them should that be the semantics of the exchange
  210. 210. the documents allowed additive changes to be made without breaking existing clients
  211. 211. the documents allowed additive changes to be made without breaking existing clients If you want to add a field, you can do so as long as clients are late bound to the documents
  212. 212. the documents allowed additive changes to be made without breaking existing clients If you want to add a field, you can do so as long as clients are late bound to the documents and if you want to rename something, you can do that easily too (add another one with the same name)
  213. 213. and the asynchronous nature decouples the applications from each other
  214. 214. and the asynchronous nature decouples the applications from each other
  215. 215. and the asynchronous nature decouples the applications from each other you can change this
  216. 216. and the asynchronous nature decouples the applications from each other you can change this without breaking this
  217. 217. of course, there is a teensy bit more to it than that...
  218. 218. Channel Adapter Channel Datatype Channel Dead Letter Channel Guaranteed Delivery ! Invalid Message Channel Message Bus Messaging Bridge Publish Subscribe Channel Aggregator Content Based Router Composed Message Message FIlter Message Router Recipient List Process Manager Splitter Routing SlipResequencer Competing Consumers Message Endpoint Durable Subscriber Event-Driven Consumer Message Dispatcher ? Selective Consumer Service Activator Polling Consumer Transactional Client Messaging Gateway quite a lot more to be perfectly frank
  219. 219. Getting async comms right can be hard!
  220. 220. And can require the dreaded ‘middleware’
  221. 221. The ESB!
  222. 222. So when to use it?
  223. 223. So when to use it? Long-running jobs
  224. 224. So when to use it? Long-running jobs Alternative scaling
  225. 225. So when to use it? Long-running jobs Alternative scaling Resiliency
  226. 226. So when to use it? Long-running jobs Alternative scaling Resiliency Broadcast
  227. 227. So when to use it? Long-running jobs Alternative scaling Resiliency Broadcast Low-latency
  228. 228. Next!
  229. 229. Let’s take a look at the world’s most successful, distributed, scalable computing system for some tips
  230. 230. The Web http://www.flickr.com/photos/photophilde/4527076709/
  231. 231. Client cache Proxy cache CDN Infrastructure caches Reverse proxy cache
  232. 232. HTTP -> REST!
  233. 233. Leonard Richardson’s maturity heuristic
  234. 234. Leonard Richardson’s maturity heuristic http://martinfowler.com/articles/richardsonMaturityModel.html
  235. 235. Level 0 - POX single service endpoint, many methods
  236. 236. createUserWithFullname(...) Level 0 - POX single service endpoint, many methods
  237. 237. createUserWithFullname(...) createUser(...) Level 0 - POX single service endpoint, many methods
  238. 238. createUserWithFullname(...) createUser(...) updateUserById(...) Level 0 - POX single service endpoint, many methods
  239. 239. createUserWithFullname(...) createUser(...) updateUserById(...) updateUserByFullName(...) Level 0 - POX single service endpoint, many methods
  240. 240. createUserWithFullname(...) createUser(...) updateUserById(...) updateUserByFullName(...) deleteUserById(...) Level 0 - POX single service endpoint, many methods
  241. 241. createUserWithFullname(...) createUser(...) updateUserById(...) updateUserByFullName(...) deleteUserById(...) Level 0 - POX single service endpoint, many methods fi