Practical Considerations
Of Microservices
Sam Newman
YOW 2013
@samnewman
We’re Hiring!

@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
Web Shop

Shopping
Cart

Registration

Catalog

Finance

Customer

@samnewman
REST over HTTP

@samnewman
REST over HTTP

@samnewman
REST over HTTP

> 1000 lines of code

@samnewman
@samnewman
@samnewman
V1

@samnewman
V2

@samnewman
V2

@samnewman
Go
Ruby

NodeJS
Java

@samnewman
Go
Ruby

NodeJS
Clojure!

@samnewman
Go
Ruby

NodeJS
Clojure!

@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
http://www.flickr.com/photos/booleansplit/4005320314/

Standardised

@samnewman
http://www.flickr.com/photos/booleansplit/4005320314/

Free For All
Standardised

http://www.flickr.com/photos/murplejane/30...
http://www.flickr.com/photos/booleansplit/4005320314/

Free For All
Standardised

Consistency
http://www.flickr.com/photos/m...
http://www.flickr.com/photos/booleansplit/4005320314/

Free For All
Standardised

Consistency
Safety

http://www.flickr.com/...
http://www.flickr.com/photos/booleansplit/4005320314/

Autonomy
Free For All
Standardised

Consistency
Safety

http://www.fl...
http://www.flickr.com/photos/booleansplit/4005320314/

React
Autonomy
Free For All

Standardised

Consistency
Safety

http:...
http://bit.ly/1aJhJ0m

@samnewman
http://bit.ly/1aJhJ0m

Responsiveness

@samnewman
http://bit.ly/1aJhJ0m

Responsiveness

Efficiency

@samnewman
@samnewman
“A paradox has a
resolution, not a solution”
- Xiao Guo

@samnewman
@samnewman
Standardisation

@samnewman
Standardisation

Free For All

@samnewman
Standardisation

Free For All

@samnewman
Standardisation

Free For All

@samnewman
Standardisation
???

Free For All

@samnewman
Where To Standardise?

@samnewman
© 2013 Electronic Arts Inc.

@samnewman
@samnewman
Interfaces

@samnewman
Monitoring

Interfaces

@samnewman
Monitoring

Interfaces

Deployment
@samnewman
Architectural Saftey
@samnewman
@samnewman
Free For All
@samnewman
Standardisation

Free For All
@samnewman
Standardisation
TIP: Standardise in the gaps between services - be
flexible about what happens inside the boxes

Free For A...
Interfaces

@samnewman
@samnewman
@samnewman
@samnewman
Coupling Is Bad

@samnewman
Integration Styles
An Evolutionary View

Data Oriented

Procedure
Oriented

Document
Oriented

Resource
Oriented

@samnewm...
Integration Styles
An Evolutionary View

Data Oriented

Procedure
Oriented

Document
Oriented

Resource
Oriented

@samnewm...
Integration Styles
An Evolutionary View
TIP: Avoid RPC-mechanisms or shared serialisation
Procedure
Document
Resource
Data...
http://www.flickr.com/photos/mikecogh/4472054494/

@samnewman
http://www.flickr.com/photos/mikecogh/4472054494/

TIP: Have one, two or maybe three ways of
integrating, not 20

@samnewma...
@samnewman
@samnewman
TIP: Pick some sensible conventions, and stick with
them

@samnewman
Payment

Inventory

@samnewman
Payment

Inventory

@samnewman
Because CAP Theorem

@samnewman
Because CAP Theorem
TIP: Avoid distributed transactions if at all possible

@samnewman
Monitoring

@samnewman
@samnewman
@samnewman
http://www.flickr.com/photos/kalexanderson/5421517469/
@samnewman
http://www.flickr.com/photos/kalexanderson/5421517469/
@samnewman
http://www.flickr.com/photos/kalexanderson/5421517469/
@samnewman
@samnewman
???

@samnewman
You have to get *much*
better at monitoring

@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
You are not a badass if you
use an SSH Multiplexer

@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
Response Time

Response Time

Response Time

@samnewman
Response Time

Response Time

Response Time

@samnewman
Response Time

Response Time

Response Time

@samnewman
nsclient++
collectd

Graphite

@samnewman
@samnewman
@samnewman
TIP: Capture metrics, and logs, for each node, and
aggregate them to get a rolled up picture

@samnewman
@samnewman
@samnewman
@samnewman
TIP: Use synthetic transactions to test production
systems
@samnewman
@samnewman
@samnewman
@samnewman
ID: 123

@samnewman
ID: 123

ID: 123

ID: 123

@samnewman
ID: 123

ID: 123

ID: 123
TIP: Use correlation IDs to track down nasty bugs
@samnewman
Deployment

@samnewman
@samnewman
@samnewman
@samnewman
!

@samnewman
!
!

@samnewman
!
!
!
@samnewman
!

TIP: Abstract out underlying platform differences to
provide a uniform deployment mechanism

!

!
@samnewman
@samnewman
$ fab deploy
def deploy():
# run things
local(‘cp…’)
@samnewman
Fast Feedback

Dev

QA

Production

More Confidence
@samnewman
fab deploy:dev
def deploy(env):
# run things
local(‘cp…’)
@samnewman
fab deploy:dev
def deploy(env):
# run things
local(‘cp…’)
@samnewman
prod:!
nodes:!
- ami_id: ami-4dad7424!
size:
t1.micro!
credentials_name: us-east-ssh!
aws_key_name : test!
services: [hell...
prod:!
nodes:!
- ami_id: ami-4dad7424!
size:
t1.micro!
credentials_name: us-east-ssh!
aws_key_name : test!
services: [hell...
Customer
Service
V1
"
Customer
Service
V1
" "
Customer
Service
V1
" " "
Customer
Service
V1
" " " "
Customer
Service
V1
" " " "
Customer
Service
V1
Finance

Customer
Service
V1
Finance

Customer
Service
V1

Customer
Service
v2
Finance

Customer
Service
V1

Finance

Customer
Service
v2
Integration Test

Finance

Customer
Service
v2
Finance

Customer
Service
v2
Finance

Consumer written
test

Customer
Service
v2
Finance

Consumer written
test

Customer
Service
v2
Finance

Customer
Service
v2

TIP: Consumer Driven Tests to catch breaking changes

Consumer written
test
Pending…

Prod
Pending…

Prod
Pending…

Prod
Pending…

Prod
Pending…

Prod
Pending…

Prod

TIP: Don’t let changes build up - release as soon as
you can, and preferably one at a time!
Architectural Safety

@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
http://www.flickr.com/photos/louish/5611657857/

@samnewman
@samnewman
TIP: Use timeouts, circuit breakers and bulk-heads to
avoid cascading failure

@samnewman
Special Service Behaviour

@samnewman
Integration

Special Service Behaviour

@samnewman
Integration

Special Service Behaviour

Downstream

@samnewman
Integration

Special Service Behaviour

Metrics

Downstream

@samnewman
Integration

Special Service Behaviour

Metrics

Downstream

@samnewman
Integration

Special Service Behaviour

Metrics

Downstream

@samnewman
Integration

Special Service Behaviour

Metrics

TIP: Consider Service Templates to make it easy to do
the right thing!
Do...
TIP: Standardise in the gaps between services - be
flexible about what happens inside the boxes
TIP: Avoid RPC-mechanisms o...
TIP: Capture metrics, and logs, for each node, and
aggregate them to get a rolled up picture
TIP: Use synthetic transactio...
TIP: Have a single way of deploying services in any
given environment
TIP: Consumer Driven Tests to catch breaking changes...
@samnewman
TIP: Standardise in the gaps between services - be
flexible about what happens inside the boxes

@samnewman
TIP: Standardise in the gaps between services - be
flexible about what happens inside the boxes

@samnewman
TIP: Standardise in the gaps between services - be
flexible about what happens inside the boxes

TIP: Don’t let changes bui...
TIP: Standardise in the gaps between services - be
flexible about what happens inside the boxes

TIP: Don’t let changes bui...
Designing For !
Rapid Release

@samnewman
Designing For !
Rapid Release

From Macro To Micro

@samnewman
Designing For !
Rapid Release

From Macro To Micro

http://lanyrd.com/profile/samnewman/

@samnewman
Thanks!

@samnewman
snewman@thoughtworks.com

@samnewman
Upcoming SlideShare
Loading in...5
×

Practical microservices - YOW 2013

4,082

Published on

The deck for Practical Microservices as presented at YOW 2013 in Brisbane. Minor changes from the Melbourne event.

Bonus point if you can spot the typo!

Published in: Technology, Design

Transcript of "Practical microservices - YOW 2013"

  1. 1. Practical Considerations Of Microservices Sam Newman YOW 2013
  2. 2. @samnewman
  3. 3. We’re Hiring! @samnewman
  4. 4. @samnewman
  5. 5. @samnewman
  6. 6. @samnewman
  7. 7. @samnewman
  8. 8. @samnewman
  9. 9. @samnewman
  10. 10. @samnewman
  11. 11. @samnewman
  12. 12. @samnewman
  13. 13. Web Shop Shopping Cart Registration Catalog Finance Customer @samnewman
  14. 14. REST over HTTP @samnewman
  15. 15. REST over HTTP @samnewman
  16. 16. REST over HTTP > 1000 lines of code @samnewman
  17. 17. @samnewman
  18. 18. @samnewman
  19. 19. V1 @samnewman
  20. 20. V2 @samnewman
  21. 21. V2 @samnewman
  22. 22. Go Ruby NodeJS Java @samnewman
  23. 23. Go Ruby NodeJS Clojure! @samnewman
  24. 24. Go Ruby NodeJS Clojure! @samnewman
  25. 25. @samnewman
  26. 26. @samnewman
  27. 27. @samnewman
  28. 28. @samnewman
  29. 29. http://www.flickr.com/photos/booleansplit/4005320314/ Standardised @samnewman
  30. 30. http://www.flickr.com/photos/booleansplit/4005320314/ Free For All Standardised http://www.flickr.com/photos/murplejane/3097926093/ @samnewman
  31. 31. http://www.flickr.com/photos/booleansplit/4005320314/ Free For All Standardised Consistency http://www.flickr.com/photos/murplejane/3097926093/ @samnewman
  32. 32. http://www.flickr.com/photos/booleansplit/4005320314/ Free For All Standardised Consistency Safety http://www.flickr.com/photos/murplejane/3097926093/ @samnewman
  33. 33. http://www.flickr.com/photos/booleansplit/4005320314/ Autonomy Free For All Standardised Consistency Safety http://www.flickr.com/photos/murplejane/3097926093/ @samnewman
  34. 34. http://www.flickr.com/photos/booleansplit/4005320314/ React Autonomy Free For All Standardised Consistency Safety http://www.flickr.com/photos/murplejane/3097926093/ @samnewman
  35. 35. http://bit.ly/1aJhJ0m @samnewman
  36. 36. http://bit.ly/1aJhJ0m Responsiveness @samnewman
  37. 37. http://bit.ly/1aJhJ0m Responsiveness Efficiency @samnewman
  38. 38. @samnewman
  39. 39. “A paradox has a resolution, not a solution” - Xiao Guo @samnewman
  40. 40. @samnewman
  41. 41. Standardisation @samnewman
  42. 42. Standardisation Free For All @samnewman
  43. 43. Standardisation Free For All @samnewman
  44. 44. Standardisation Free For All @samnewman
  45. 45. Standardisation ??? Free For All @samnewman
  46. 46. Where To Standardise? @samnewman
  47. 47. © 2013 Electronic Arts Inc. @samnewman
  48. 48. @samnewman
  49. 49. Interfaces @samnewman
  50. 50. Monitoring Interfaces @samnewman
  51. 51. Monitoring Interfaces Deployment @samnewman
  52. 52. Architectural Saftey @samnewman
  53. 53. @samnewman
  54. 54. Free For All @samnewman
  55. 55. Standardisation Free For All @samnewman
  56. 56. Standardisation TIP: Standardise in the gaps between services - be flexible about what happens inside the boxes Free For All @samnewman
  57. 57. Interfaces @samnewman
  58. 58. @samnewman
  59. 59. @samnewman
  60. 60. @samnewman
  61. 61. Coupling Is Bad @samnewman
  62. 62. Integration Styles An Evolutionary View Data Oriented Procedure Oriented Document Oriented Resource Oriented @samnewman
  63. 63. Integration Styles An Evolutionary View Data Oriented Procedure Oriented Document Oriented Resource Oriented @samnewman
  64. 64. Integration Styles An Evolutionary View TIP: Avoid RPC-mechanisms or shared serialisation Procedure Document Resource Data protocols to avoid coupling Oriented Oriented Oriented Oriented @samnewman
  65. 65. http://www.flickr.com/photos/mikecogh/4472054494/ @samnewman
  66. 66. http://www.flickr.com/photos/mikecogh/4472054494/ TIP: Have one, two or maybe three ways of integrating, not 20 @samnewman
  67. 67. @samnewman
  68. 68. @samnewman
  69. 69. TIP: Pick some sensible conventions, and stick with them @samnewman
  70. 70. Payment Inventory @samnewman
  71. 71. Payment Inventory @samnewman
  72. 72. Because CAP Theorem @samnewman
  73. 73. Because CAP Theorem TIP: Avoid distributed transactions if at all possible @samnewman
  74. 74. Monitoring @samnewman
  75. 75. @samnewman
  76. 76. @samnewman http://www.flickr.com/photos/kalexanderson/5421517469/
  77. 77. @samnewman http://www.flickr.com/photos/kalexanderson/5421517469/
  78. 78. @samnewman http://www.flickr.com/photos/kalexanderson/5421517469/
  79. 79. @samnewman
  80. 80. @samnewman
  81. 81. ??? @samnewman
  82. 82. You have to get *much* better at monitoring @samnewman
  83. 83. @samnewman
  84. 84. @samnewman
  85. 85. @samnewman
  86. 86. @samnewman
  87. 87. You are not a badass if you use an SSH Multiplexer @samnewman
  88. 88. @samnewman
  89. 89. @samnewman
  90. 90. @samnewman
  91. 91. @samnewman
  92. 92. @samnewman
  93. 93. Response Time Response Time Response Time @samnewman
  94. 94. Response Time Response Time Response Time @samnewman
  95. 95. Response Time Response Time Response Time @samnewman
  96. 96. nsclient++ collectd Graphite @samnewman
  97. 97. @samnewman
  98. 98. @samnewman
  99. 99. TIP: Capture metrics, and logs, for each node, and aggregate them to get a rolled up picture @samnewman
  100. 100. @samnewman
  101. 101. @samnewman
  102. 102. @samnewman
  103. 103. TIP: Use synthetic transactions to test production systems @samnewman
  104. 104. @samnewman
  105. 105. @samnewman
  106. 106. @samnewman
  107. 107. ID: 123 @samnewman
  108. 108. ID: 123 ID: 123 ID: 123 @samnewman
  109. 109. ID: 123 ID: 123 ID: 123 TIP: Use correlation IDs to track down nasty bugs @samnewman
  110. 110. Deployment @samnewman
  111. 111. @samnewman
  112. 112. @samnewman
  113. 113. @samnewman
  114. 114. ! @samnewman
  115. 115. ! ! @samnewman
  116. 116. ! ! ! @samnewman
  117. 117. ! TIP: Abstract out underlying platform differences to provide a uniform deployment mechanism ! ! @samnewman
  118. 118. @samnewman
  119. 119. $ fab deploy def deploy(): # run things local(‘cp…’) @samnewman
  120. 120. Fast Feedback Dev QA Production More Confidence @samnewman
  121. 121. fab deploy:dev def deploy(env): # run things local(‘cp…’) @samnewman
  122. 122. fab deploy:dev def deploy(env): # run things local(‘cp…’) @samnewman
  123. 123. prod:! nodes:! - ami_id: ami-4dad7424! size: t1.micro! credentials_name: us-east-ssh! aws_key_name : test! services: [hello_world]! apache:! security_groups: [ spicy-beef ]! puppet_module_directory : puppet! availability_zone: us-east-1a! puppet_manifest : apache.pp! type: phoenix.providers.aws_provider.AWSNodeDefinition! service_configurator: - ami_id: ami-4dad7424! phoenix.configurators.puppet_service_configurator.PuppetServiceConfigurator! size: t1.micro! connectivity:! credentials_name: us-east-ssh! - protocol: tcp! aws_key_name : test! ports: [ 80 ]! services: [hello_world]! allowed: [ WORLD ]! security_groups: [ spicy-beef ]! availability_zone: us-east-1b! hello_world:! type: phoenix.providers.aws_provider.AWSNodeDefinition! puppet_module_directory : puppet! - ami_id: ami-4dad7424! puppet_manifest : hello_world.pp! size: t1.micro! service_configurator: credentials_name: us-east-ssh! phoenix.configurators.puppet_service_configurator.PuppetServiceConfigurator! aws_key_name : test! connectivity:! services: [apache]! - protocol: tcp! type: phoenix.providers.aws_provider.AWSNodeDefinition! ports: [ 8080, 8081 ]! security_groups: [ spicy-beef ]! allowed: [ WORLD ]! ! ! ! node_provider:! mongo:! class_name: AWSNodeProvider! puppet_module_directory : puppet! public_api_key: {{ aws_public_api_key }}! puppet_manifest private_api_key: {{ aws_private_api_key }} : mongo.pp! service_configurator: phoenix.configurators.puppet_service_configurator.PuppetServiceConfigurator! connectivity:! - protocol: tcp! ports: [ 27017 ]! allowed: [ hello_world ] @samnewman
  124. 124. prod:! nodes:! - ami_id: ami-4dad7424! size: t1.micro! credentials_name: us-east-ssh! aws_key_name : test! services: [hello_world]! apache:! security_groups: [ spicy-beef ]! puppet_module_directory : puppet! availability_zone: us-east-1a! puppet_manifest : apache.pp! type: phoenix.providers.aws_provider.AWSNodeDefinition! service_configurator: - ami_id: ami-4dad7424! phoenix.configurators.puppet_service_configurator.PuppetServiceConfigurator! size: t1.micro! connectivity:! credentials_name: us-east-ssh! - protocol: tcp! aws_key_name : test! ports: [ 80 ]! services: [hello_world]! allowed: [ WORLD ]! security_groups: [ spicy-beef ]! availability_zone: us-east-1b! hello_world:! type: phoenix.providers.aws_provider.AWSNodeDefinition! puppet_module_directory : puppet! - ami_id: ami-4dad7424! puppet_manifest : hello_world.pp! size: t1.micro! service_configurator: credentials_name: us-east-ssh! phoenix.configurators.puppet_service_configurator.PuppetServiceConfigurator! aws_key_name : test! connectivity:! services: [apache]! - protocol: tcp! type: phoenix.providers.aws_provider.AWSNodeDefinition! ports: [ 8080, 8081 ]! security_groups: [ spicy-beef ]! allowed: [ WORLD ]! TIP: Have a single way of deploying services in any given environment ! ! ! node_provider:! mongo:! class_name: AWSNodeProvider! puppet_module_directory : puppet! public_api_key: {{ aws_public_api_key }}! puppet_manifest private_api_key: {{ aws_private_api_key }} : mongo.pp! service_configurator: phoenix.configurators.puppet_service_configurator.PuppetServiceConfigurator! connectivity:! - protocol: tcp! ports: [ 27017 ]! allowed: [ hello_world ] @samnewman
  125. 125. Customer Service V1
  126. 126. " Customer Service V1
  127. 127. " " Customer Service V1
  128. 128. " " " Customer Service V1
  129. 129. " " " " Customer Service V1
  130. 130. " " " " Customer Service V1
  131. 131. Finance Customer Service V1
  132. 132. Finance Customer Service V1 Customer Service v2
  133. 133. Finance Customer Service V1 Finance Customer Service v2
  134. 134. Integration Test Finance Customer Service v2
  135. 135. Finance Customer Service v2
  136. 136. Finance Consumer written test Customer Service v2
  137. 137. Finance Consumer written test Customer Service v2
  138. 138. Finance Customer Service v2 TIP: Consumer Driven Tests to catch breaking changes Consumer written test
  139. 139. Pending… Prod
  140. 140. Pending… Prod
  141. 141. Pending… Prod
  142. 142. Pending… Prod
  143. 143. Pending… Prod
  144. 144. Pending… Prod TIP: Don’t let changes build up - release as soon as you can, and preferably one at a time!
  145. 145. Architectural Safety @samnewman
  146. 146. @samnewman
  147. 147. @samnewman
  148. 148. @samnewman
  149. 149. @samnewman
  150. 150. http://www.flickr.com/photos/louish/5611657857/ @samnewman
  151. 151. @samnewman
  152. 152. TIP: Use timeouts, circuit breakers and bulk-heads to avoid cascading failure @samnewman
  153. 153. Special Service Behaviour @samnewman
  154. 154. Integration Special Service Behaviour @samnewman
  155. 155. Integration Special Service Behaviour Downstream @samnewman
  156. 156. Integration Special Service Behaviour Metrics Downstream @samnewman
  157. 157. Integration Special Service Behaviour Metrics Downstream @samnewman
  158. 158. Integration Special Service Behaviour Metrics Downstream @samnewman
  159. 159. Integration Special Service Behaviour Metrics TIP: Consider Service Templates to make it easy to do the right thing! Downstream @samnewman
  160. 160. TIP: Standardise in the gaps between services - be flexible about what happens inside the boxes TIP: Avoid RPC-mechanisms or shared serialisation protocols to avoid coupling TIP: Have one, two or maybe three ways of integrating, not 20 TIP: Pick some sensible conventions, and stick with them @samnewman
  161. 161. TIP: Capture metrics, and logs, for each node, and aggregate them to get a rolled up picture TIP: Use synthetic transactions to test production systems TIP: Avoid distributed transactions if at all possible TIP: Use correlation IDs to track down nasty bugs TIP: Abstract out underlying platform differences to provide a uniform deployment mechanism @samnewman
  162. 162. TIP: Have a single way of deploying services in any given environment TIP: Consumer Driven Tests to catch breaking changes TIP: Don’t let changes build up - release as soon as you can, and preferably one at a time! TIP: Use timeouts, circuit breakers and bulk-heads to avoid cascading failure TIP: Consider Service Templates to make it easy to do the right thing! @samnewman
  163. 163. @samnewman
  164. 164. TIP: Standardise in the gaps between services - be flexible about what happens inside the boxes @samnewman
  165. 165. TIP: Standardise in the gaps between services - be flexible about what happens inside the boxes @samnewman
  166. 166. TIP: Standardise in the gaps between services - be flexible about what happens inside the boxes TIP: Don’t let changes build up - release as soon as you can, and preferably one at a time! @samnewman
  167. 167. TIP: Standardise in the gaps between services - be flexible about what happens inside the boxes TIP: Don’t let changes build up - release as soon as you can, and preferably one at a time! @samnewman
  168. 168. Designing For ! Rapid Release @samnewman
  169. 169. Designing For ! Rapid Release From Macro To Micro @samnewman
  170. 170. Designing For ! Rapid Release From Macro To Micro http://lanyrd.com/profile/samnewman/ @samnewman
  171. 171. Thanks! @samnewman snewman@thoughtworks.com @samnewman
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×