Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microservices and pineapple on pizza what do they have in common - dos and don'ts

67 views

Published on

Microservices è una delle buzzword del momento. Sembra quasi che un'architettura a microservices sia fondamentale. È veramente così? Faremo un tortuoso viaggio tra le buzzword del momento cercando di districarci tra cosa è bene e cosa è meno bene, ma soprattutto perché. Obiettivo è quello di comprendere quali sono i limiti di certe scelte architetturali e quali gli errori da non commettere. Il tutto nell'ottica di garantire ai nostri sistemi 'lunga vita e prosperità' (cit.)

Published in: Technology
  • Be the first to comment

Microservices and pineapple on pizza what do they have in common - dos and don'ts

  1. 1. @mauroservienti microservices and pineapple on pizza what do they have in common? dos and don'ts
  2. 2. @mauroservienti All I wanna do when I wake up in the morning is… Rosanna, Toto. Toto IV
  3. 3. @mauroservienti Buy a "Banana Protector"
  4. 4. @mauroservienti Buy a "Banana Protector"
  5. 5. @mauroservienti Shopping Cart Microservice [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart
  6. 6. @mauroservienti please, welcome the business
  7. 7. @mauroservienti Business requirements (#1)
  8. 8. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price Products
  9. 9. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price Products copy
  10. 10. @mauroservienti Business requirements (#2)
  11. 11. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products
  12. 12. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products copy copy
  13. 13. @mauroservienti Business requirements (#3)
  14. 14. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products
  15. 15. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products
  16. 16. @mauroservienti Products & Shopping Cart Microservices [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Update XYZ Price
  17. 17. @mauroservienti service boundaries violation
  18. 18. @mauroservienti Products Microservices - Item ID - Price - Inventory Products
  19. 19. @mauroservienti ownership is lost
  20. 20. @mauroservienti Suppliers & Products & Shopping Cart [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… - Supplier ID - Item ID - Purchase Price Suppliers Update XYZ Price Are we selling? New Purchase Price
  21. 21. @mauroservienti autonomy? puff, it’s gone
  22. 22. @mauroservienti HTTP all the rage because it’s the microservices way
  23. 23. @mauroservienti Suppliers & Products & Shopping Cart [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… - Supplier ID - Item ID - Purchase Price Suppliers Update XYZ Price Are we selling? New Purchase Price
  24. 24. @mauroservienti “the microservices way” Shopping CartProducts Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Suppliers Update XYZ Price Are we selling? New Purchase Price • Incoming “external” HTTP Post • HTTP Query from Suppliers to Products • HTTP Post from Suppliers to Products • HTTP Query from Products to Shopping Cart • HTTP Post from Products to Shopping Cart
  25. 25. @mauroservienti Hops 1 2 3 4 10 Latency 100ms 200ms 300ms 400ms 1 second “the microservices way” Does not count any processing time! …
  26. 26. @mauroservienti Latency Matters http://highscalability.com/blog/2009/7/25/latency-is-everywhere-and-it-costs-you-sales-how-to-crush-it.html Amazon found every 100ms of latency cost them 1% in sales. Google found an extra .5 seconds in search page generation time dropped traffic by 20%. A broker could lose $4 million in revenues per millisecond if their electronic trading platform is 5 milliseconds behind the competition. “
  27. 27. @mauroservienti The snowball effect [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… - Supplier ID - Item ID - Purchase Price Suppliers Update XYZ Price Are we selling? New Purchase Price Ooops...
  28. 28. @mauroservienti temporal coupling anyone?
  29. 29. @mauroservienti distributed transactions over HTTP
  30. 30. @mauroservienti
  31. 31. @mauroservienti Messaging temporal coupling and distributed transactions
  32. 32. @mauroservienti The snowball effect [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… - Supplier ID - Item ID - Purchase Price Suppliers Update XYZ Price Are we selling? New Purchase Price Ooops...
  33. 33. @mauroservienti The snowball effect [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products - Supplier ID - Item ID - Purchase Price Suppliers New Purchase Price + new price details Business Logic Purchase Price Changed + new price details Business Logic Sell Price Changed MovetoSavedfor…
  34. 34. @mauroservienti The snowball effect [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart + new price details Business Logic Sell Price Changed MovetoSavedfor… Ooops...
  35. 35. @mauroservienti palliative alleviates the symptoms
  36. 36. @mauroservienti Queries are still a thing: Add item to cart. [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products copy price copy inventory
  37. 37. @mauroservienti Data sharing is still a thing [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart + new price details Business Logic Sell Price Changed MovetoSavedfor…
  38. 38. @mauroservienti We’re flooding the system… Shopping CartProducts Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Update XYZ inventory Update XYZ Price Update XYZ Inventory Over and over, and over, and over…
  39. 39. @mauroservientihttp://montages.no/2009/09/begrepet-grafisk-likhet/
  40. 40. @mauroservienti
  41. 41. @mauroservienti User mental model is misleading [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price - Inventory Products - Supplier ID - Item ID - Purchase Price Suppliers
  42. 42. @mauroservienti Let’s focus on the Shopping Cart [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description - Etc… Shopping Cart
  43. 43. @mauroservienti Sales shopping cart [ list-of ] - Item ID - Quantity - Inventory - Name - Description - Delivery Est. Shopping Cart - Item ID - Price Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity
  44. 44. @mauroservienti - Item ID - Price Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity Warehouse shopping cart [ list-of ] - Item ID - Quantity - Name - Description - Delivery Est. Shopping Cart [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory
  45. 45. @mauroservienti Shipping shopping cart [ list-of ] - Item ID - Quantity - Name - Description Shopping Cart [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  46. 46. @mauroservienti Marketing tends to be stable [ list-of ] - Item ID - Quantity Shopping Cart [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  47. 47. @mauroservienti Do we need the Shopping Cart at all? [ list-of ] - Item ID - Quantity Shopping Cart [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  48. 48. @mauroservienti Can Sales be responsible for that concept? [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales Cart ID [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  49. 49. @mauroservienti We followed the coupling [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales Cart ID [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  50. 50. @mauroservienti What a (micro)service is not • A service that has only functionality is a function: • Like calculation, validation, etc. • A service that has only data is a database: • Like [create, read, update, delete] entity • HTTP/WSDL doesn’t change logical responsibility
  51. 51. @mauroservienti What a (micro)service is the technical authority for a specific business capability All business rules (& data) reside within the service
  52. 52. @mauroservienti Full Vertical Slices MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data
  53. 53. @mauroservienti Full Vertical Slices MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data UI & ViewModel Composition UI & ViewModel Composition UI & ViewModel Composition UI & ViewModel Composition
  54. 54. @mauroservienti Full Vertical Slices MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data UI & ViewModel Composition UI & ViewModel Composition UI & ViewModel Composition UI & ViewModel Composition Dedicated Technology / FX Dedicated Technology / FX Dedicated Technology / FX Dedicated Technology / FX
  55. 55. @mauroservienti
  56. 56. @mauroservienti services need to communicate
  57. 57. @mauroservienti Business requirements (#4) • Annoy Notify users of 1 week stale carts • Wipe 1 month stale carts
  58. 58. @mauroservienti Services communication channel MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition
  59. 59. @mauroservienti Services communication channel MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart
  60. 60. @mauroservienti Services communication channel MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout
  61. 61. @mauroservienti Services communication channel MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout
  62. 62. @mauroservienti 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout Cart Got Stale
  63. 63. @mauroservienti 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout busCart Got Stale
  64. 64. @mauroservienti 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Cart Got Stale
  65. 65. @mauroservienti 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & data behavior & data ViewModel Composition ViewModel Composition ViewModel Composition ViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Notify User Cart Got Stale
  66. 66. @mauroservienti 1 month later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Cart Expired
  67. 67. @mauroservienti busCart Expired 1 month later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout Cart Expired
  68. 68. @mauroservienti 1 month later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout busCart Expired Cart Expired
  69. 69. @mauroservienti 1 month later MarketingSales Warehouse Shipping behavior & databehavior & data behavior & data behavior & data ViewModel Composition ViewModel Composition ViewModel Composition ViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Wipe cart Wipe cart Cart Expired Cart Expired
  70. 70. @mauroservienti cross services events can be as thin as event name and identifiers
  71. 71. @mauroservienti time tyranny Demo bit.ly/aperitech-dos-donts
  72. 72. @mauroservienti Takeaways • Boundaries are key to success • Do not bring in more technology to solve non- technical problems
  73. 73. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Users/Business analysts tend to think in term of data presentation
  74. 74. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Do not name things prematurely • Premature names stick and drive data aggregation
  75. 75. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Do not name things prematurely • Behaviors define how to aggregate data • Group data that change together and that influence each other • Use anti-requirements techniques to validate data grouping • Follow the coupling
  76. 76. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Do not name things prematurely • Behaviors define how to aggregate data • Use messaging to temporally decouple services
  77. 77. @mauroservienti you don’t need a distributed system first rule of distributed systems
  78. 78. @mauroservienti Mauro Servienti Solution Architect @ Particular Software the makers of NServiceBus mauro.servienti@particular.net @mauroservienti //milestone.topics.it
  79. 79. @mauroservienti microservices pineapple on pizza sucks… ;)
  80. 80. @mauroservienti Thank you!

×