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.

Modules or microservices?

2,563 views

Published on

Microservices promise a scalable architecture, increased flexibility, and better performance. But then you find out what’s actually involved in designing, developing, and running a microservices-based architecture. It turns out it’s not that straightforward after all.

Often the discussion around microservices is framed by a false dichotomy between the messy monolith and the lean and mean microservices architecture. Sander Mak explains that there’s a third way: the modularized application. Functional decomposition of your application doesn’t imply that every component has to become its own independent process.

Modularization is about strong encapsulation, well-defined interfaces, and explicit dependencies. Many languages offer in-process modularization features (for example, Java 9 with its upcoming module system), and there’s a strong overlap between the microservices philosophy and development benefits—without incurring the penalty of operational complexity.

Sander explores the right (and wrong) reasons for going with a microservices architecture, as well as what a modularized application entails. You’ll see that splitting up an existing service or application into microservices isn’t always the clear winner. You’ll leave able to choose between the alternatives for the right reasons. There’s a place for both independently deployed microservices and larger applications with a strong internal modular structure. Choose wisely.

Published in: Software

Modules or microservices?

  1. 1. Modules or Microservices? @Sander_Mak
  2. 2. About Sander Fellow, Software Architect @ Luminis Experience in modular development stacks Conference Speaker & Author
  3. 3. @Sander_Mak Modules or Microservices?
  4. 4. @Sander_Mak Modules or Microservices? YES
  5. 5. @Sander_Mak Modules XOR Microservices? YES
  6. 6. @Sander_Mak Modules XOR Microservices? IT DEPENDS
  7. 7. @Sander_Mak Let's Talk About Modularity
  8. 8. Why Modularity?
  9. 9. Why Modularity?
  10. 10. Why Modularity? No. 1 Software Architecture Principle
  11. 11. @Sander_Mak The Three Tenets of Modularity Strong Encapsulation
  12. 12. @Sander_Mak The Three Tenets of Modularity Strong Encapsulation Well-Defined Interfaces
  13. 13. @Sander_Mak The Three Tenets of Modularity Explicit Dependencies Strong Encapsulation Well-Defined Interfaces
  14. 14. @Sander_Mak Modularity is the ultimate Agile Tool
  15. 15. @Sander_Mak Let's Talk About Microservices
  16. 16. @Sander_Mak A Microservice is... Independently deployable Implementing a business capability Doing one thing, and doing it well Communicating over the network
  17. 17. What's This?
  18. 18. What's This? Microservices Devroom
  19. 19. What's This? Microservices Devroom Despair
  20. 20. What's This? Microservices Devroom Despair Praying for a Better Solution
  21. 21. @Sander_Mak Yes, Microservices Are Hard However...
  22. 22. @Sander_Mak Yes, Microservices Are Hard However... Introspection: When (not)
  23. 23. @Sander_Mak Yes, Microservices Are Hard However... Introspection: When (not) Alternative: Modules
  24. 24. @Sander_Mak Why? Manage Complexity Scaling Resilience
  25. 25. @Sander_Mak Why? Manage Complexity Scaling Resilience Modularity In Disguise!
  26. 26. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices
  27. 27. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices Monolith? users studentslearningmaterial shipping courses forecasting attendance
  28. 28. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices Monolith? users studentslearningmaterial shipping courses forecasting attendance
  29. 29. @Sander_Mak Features Cost
  30. 30. @Sander_Mak Messy Monolith Features Cost
  31. 31. @Sander_Mak Messy Monolith Microservices All The Way Features Cost
  32. 32. @Sander_Mak Messy Monolith Microservices All The Way Features Cost
  33. 33. @Sander_Mak Microservices: Distributed system Service Discovery ? ? ? ? users assignments learningmaterial students grading courses attendance
  34. 34. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices: Distributed system Network Fallacies
  35. 35. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices: Distributed system Deployment
  36. 36. @Sander_Mak Microservices: Distributed system Config. Management v1 v2 v3 v2 v3 at least x4 (DTAP) users assignments learningmaterial students grading courses attendance
  37. 37. @Sander_Mak Microservices: Security users assignments learningmaterial students grading courses attendance Distributed system
  38. 38. @Sander_Mak Messy Monolith Microservices All The Way Features Cost
  39. 39. @Sander_Mak Messy Monolith Microservices All The Way Features Cost But... vendors?!
  40. 40. @Sander_Mak Messy Monolith Microservices All The Way Features Cost But... vendors?! Won't magically transform your organization!
  41. 41. @Sander_Mak Let's Talk About Modules
  42. 42. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices
  43. 43. @Sander_Mak users assignments learningmaterial students grading courses attendance Microservices Monolith? users studentslearningmaterial shipping courses forecasting attendance
  44. 44. @Sander_Mak Microservices Modules! users assignments learningmaterial students grading courses attendance Modular app users assignments learningmaterial students grading courses attendance
  45. 45. @Sander_Mak Messy Monolith Microservices All The Way Modular App Features Cost
  46. 46. @Sander_Mak Messy Monolith Microservices All The Way Modular App Features Cost
  47. 47. @Sander_Mak So, Modules. Did You Mean Objects?
  48. 48. @Sander_Mak So, Modules. Did You Mean Objects? Close, but Too Fine-grained.
  49. 49. @Sander_Mak Module Systems
  50. 50. @Sander_Mak Module Systems Java OSGi Java 9
  51. 51. @Sander_Mak Module Systems Java OSGi Java 9 JavaScript ... ES2015 Modules
  52. 52. @Sander_Mak Module Systems Java OSGi Java 9 JavaScript ... ES2015 Modules C++ C++20?
  53. 53. @Sander_Mak Module Systems Java OSGi Java 9 JavaScript ... ES2015 Modules C++ C++20? .Net NuGet .Net Core
  54. 54. @Sander_Mak Explicit Dependencies Strong Encapsulation Well-Defined Interfaces Module Systems Java OSGi Java 9 JavaScript ... ES2015 Modules C++ C++20? .Net NuGet .Net Core
  55. 55. @Sander_Mak Module Systems: Java 9 module attendance { exports attendance.api; requires students; requires courses; }
  56. 56. @Sander_Mak Module Systems: Java 9 module attendance { exports attendance.api; requires students; requires courses; } Strong Encapsulation
  57. 57. @Sander_Mak Module Systems: Java 9 module attendance { exports attendance.api; requires students; requires courses; } Strong Encapsulation Well-Defined Interfaces
  58. 58. @Sander_Mak Module Systems: Java 9 module attendance { exports attendance.api; requires students; requires courses; } Explicit Dependencies Strong Encapsulation Well-Defined Interfaces
  59. 59. @Sander_Mak Module Systems: Java 9 Module Resolution (Reliable Configuration) Increased Security (Hide Platform Internals)
  60. 60. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; }
  61. 61. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } import { sq } from mymodule; console.log("Two squared", sq(2));
  62. 62. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } Strong Encapsulation import { sq } from mymodule; console.log("Two squared", sq(2));
  63. 63. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } Strong Encapsulation Well-Defined Interfaces import { sq } from mymodule; console.log("Two squared", sq(2));
  64. 64. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } Explicit Dependencies Strong Encapsulation Well-Defined Interfaces import { sq } from mymodule; console.log("Two squared", sq(2));
  65. 65. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } import { sq } from mymodule; console.log("Two squared", sq(2)); Consider TypeScript
  66. 66. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } Well-Defined Interfaces import { sq } from mymodule; console.log("Two squared", sq(2)); Consider TypeScript
  67. 67. @Sander_Mak Module Systems: ES2015 export function sq(i) { return secret(i); } function secret(i) { return i * i; } import { sq } from mymodule; console.log("Two squared", sq(2)); (let's not go there...)
  68. 68. @Sander_Mak Module Systems: C++20? module mymodule; export int sq(int i) { return secret(i); } int secret(int i) { return i * i; }
  69. 69. @Sander_Mak Module Systems: C++20? module mymodule; export int sq(int i) { return secret(i); } int secret(int i) { return i * i; } #include <stdio.h> import std.io import mymodule int main() { printf("Two squared %d", sq(2)); return 0; }
  70. 70. @Sander_Mak Module Systems: C++20? module mymodule; export int sq(int i) { return secret(i); } int secret(int i) { return i * i; } #include <stdio.h> import std.io import mymodule int main() { printf("Two squared %d", sq(2)); return 0; } Strong Encapsulation
  71. 71. @Sander_Mak Module Systems: C++20? module mymodule; export int sq(int i) { return secret(i); } int secret(int i) { return i * i; } #include <stdio.h> import std.io import mymodule int main() { printf("Two squared %d", sq(2)); return 0; } Strong Encapsulation Well-Defined Interfaces
  72. 72. @Sander_Mak Module Systems: C++20? module mymodule; export int sq(int i) { return secret(i); } int secret(int i) { return i * i; } #include <stdio.h> import std.io import mymodule int main() { printf("Two squared %d", sq(2)); return 0; } Explicit Dependencies Strong Encapsulation Well-Defined Interfaces
  73. 73. @Sander_Mak So, Modules Everywhere!
  74. 74. @Sander_Mak So, Modules Everywhere! > Objects < Applications
  75. 75. @Sander_Mak users app.users.User app.users.UserInfo app.users.internal.UserImpl app.users.internal.Util; assignments ... ... courses ... ... students ... ... attendance ... ... grading ... ... learningmaterial ... ... Not Just on the Whiteboard
  76. 76. @Sander_Mak users app.users.User app.users.UserInfo app.users.internal.UserImpl app.users.internal.Util; assignments ... ... courses ... ... students ... ... attendance ... ... grading ... ... learningmaterial ... ... Not Just With Discipline
  77. 77. @Sander_Mak Modules or Microservices? IT DEPENDS
  78. 78. @Sander_Mak Manage Complexity Scaling Resilience
  79. 79. @Sander_Mak Manage Complexity Scaling Resilience
  80. 80. @Sander_Mak Manage Complexity Scaling Resilience ? ?
  81. 81. @Sander_Mak Advantages of Modules Ease of Deployment & Management
  82. 82. @Sander_Mak Advantages of Modules Ease of Deployment & Management Modular Application
  83. 83. @Sander_Mak Advantages of Modules Strong but Refactorable Boundaries
  84. 84. @Sander_Mak Advantages of Modules Strong but Refactorable Boundaries https://www.infoq.com/presentations/microservices-future ~1800 microservices
  85. 85. @Sander_Mak Advantages of Modules Strong but Refactorable Boundaries "The [Linux] project is structured so people can work independently, Torvalds explained. "We've been able to really modularize the code and development model so we can do a lot in parallel." - El Reg
  86. 86. @Sander_Mak Advantages of Modules Strongly typed, In-Process Communication
  87. 87. @Sander_Mak Advantages of Modules Strongly typed, In-Process Communication No Serialization or Network Latency
  88. 88. @Sander_Mak Advantages of Modules Strongly typed, In-Process Communication Ever Tried Serializing a Function?
  89. 89. @Sander_Mak Advantages of Modules Strongly typed, In-Process Communication GraphQL or Protobuf > REST
  90. 90. @Sander_Mak Advantages of Modules Strongly typed, In-Process Communication
  91. 91. @Sander_Mak Advantages of Modules Strongly typed, In-Process *Synchronous* Communication
  92. 92. @Sander_Mak Advantages of Modules Eventual Consistency is a Choice
  93. 93. @Sander_Mak Advantages of Modules Eventual Consistency is a Choice It's Still a Good Idea to Partition Data
  94. 94. @Sander_Mak Advantages of Microservices Best Stack for Each Service
  95. 95. @Sander_Mak Advantages of Microservices Best Stack for Each Service learningmaterial students assignments (but is your org ready for this?)
  96. 96. @Sander_Mak Advantages of Microservices Independent Deployment learningmaterial students assignmentsv2 v3 v1
  97. 97. @Sander_Mak Advantages of Microservices Independent Deployment learningmaterial students assignmentsv2 v3 v1 (beware of deployment dependencies!)
  98. 98. @Sander_Mak Advantages of Microservices Independent Deployment learningmaterial students assignmentsv2 v3 v1 Modularized App > Distributed Monolith (beware of deployment dependencies!)
  99. 99. @Sander_Mak Advantages of Microservices Independent Failure learningmaterial students assignments
  100. 100. @Sander_Mak Advantages of Microservices Independent Failure learningmaterial students assignments (when your services are truly autonomous...)
  101. 101. @Sander_Mak Advantages of Microservices Independent Scaling assignments learningmaterial 4x g2.2xlarge 2x t2.medium 1x t2.micro students
  102. 102. @Sander_Mak Advantages of Microservices vs. Uniform Scaling Modular Application 3x t2.large
  103. 103. @Sander_Mak It's Time to Wrap Up
  104. 104. @Sander_Mak
  105. 105. @Sander_Mak At the speed of light, everything changes!
  106. 106. @Sander_Mak At the speed of light, everything changes! Dude, chill. The apple still doesn't fall far from the tree.
  107. 107. @Sander_Mak Don't Solve Problems You Don't Have At the speed of light, everything changes! Dude, chill. The apple still doesn't fall far from the tree.
  108. 108. @Sander_Mak You Are (most likely) Not at Uber or Netflix Scale scale organizations
  109. 109. @Sander_Mak You Are (most likely) Not at Uber or Netflix Scale scale organizations
  110. 110. @Sander_Mak You Are (most likely) Not at Uber or Netflix Scale scale organizations the 80% of us
  111. 111. @Sander_Mak Solve Problems You Do Have In The Simplest Possible Way
  112. 112. @Sander_Mak Solve Problems You Do Have In The Simplest Possible Way At Least Read Up on Modular Development In Your Tech Stack of Choice Explicit Dependencies Strong Encapsulation Well-Defined Interfaces
  113. 113. @Sander_Mak Design as Microservices, Build as Modules You Can Move to (Micro)services Later.
  114. 114. @Sander_Mak Design as Microservices, Build as Modules You Can Move to (Micro)services Later. Modules Enable
 Larger Services!
  115. 115. @Sander_Mak Design as Microservices, Build as Modules Don't worry, you can still do: Reactive NoSQL Cloud DevOps DDD
  116. 116. @Sander_Mak Messy Monolith Microservices All The Way Modular App Features Cost
  117. 117. Thanks. Read More: bit.ly/modularapps bit.ly/java9book @Sander_Mak

×