Deconstructing a Monolith
1 / 105
Deconstructing a Monolith 1 / 105 Introduction I am Peter - - PowerPoint PPT Presentation
Deconstructing a Monolith 1 / 105 Introduction I am Peter (@pjausovec) Software Engineer at Oracle Working on "cloud-native" stu Books: Cloud Native: Using Containers, Functions, and Data to Build Next-Gen Apps SharePoint
1 / 105
I am Peter (@pjausovec) Software Engineer at Oracle Working on "cloud-native" stu Books: Cloud Native: Using Containers, Functions, and Data to Build Next-Gen Apps SharePoint Development VSTO For Dummies Courses: Kubernetes Course (https://startkubernetes.com) Istio Service Mesh Course (https://learnistio.com)
2 / 105
Strangler Pattern Branch by Abstraction Pattern Parallel Run Pattern
Database View Pattern Database Wrapping Service Pattern Database-as-a-Service Pattern Change Data Capture Aggregate Exposing Monolith Change Data Ownership Pattern
3 / 105
4 / 105
5 / 105
6 / 105
7 / 105
Developers getting in each others way changing same piece of code delaying deployments Ownership
8 / 105
Simpler/single deployment Simpler inner loop/development also monitoring and E2E testing Code reuse
9 / 105
10 / 105
11 / 105
Independently deployable Modeled around a business domain Own their own data
12 / 105
a) Scaling (like Netix!) b) Use any tech/language c) Flexibility d) Simpler deployment
13 / 105
14 / 105
Networking Distributed system, CAP theorem and all that It's not server-side only - What about the UIs? Urge to use the latest and greatest Culture change
15 / 105
Monolithic deployment Monoliths can be a good choice Avoid distributed monoliths Microservices oer exibility A lot of network
16 / 105
17 / 105
18 / 105
"Would you tell me, please, which way I ought to go from here?" "That depends a good deal on where you want to get to" "I don't much care where" "Then it doesn't matter which way you go" ...
19 / 105
What are you hoping to achieve? Which alternatives did you consider? How do you know if migration worked?
20 / 105
Improve team autonomy Amazon's two-pizza team Spotify's product squads Reduce time to market Scale and robustness Scale the developers Embrace new tech
21 / 105
22 / 105
23 / 105
24 / 105
Used when doing system rewrites Both systems coexist Allows for incremental changes and pausing/stopping the migration
25 / 105
26 / 105
27 / 105
28 / 105
29 / 105
30 / 105
31 / 105
32 / 105
33 / 105
34 / 105
35 / 105
36 / 105
37 / 105
38 / 105
39 / 105
40 / 105
41 / 105
42 / 105
43 / 105
44 / 105
45 / 105
46 / 105
47 / 105
48 / 105
You can't decide what's shared and what's hidden Goes against one of the microservices characteristics Data control - where is the logic?
49 / 105
50 / 105
51 / 105
52 / 105
53 / 105
54 / 105
55 / 105
56 / 105
Not constrained to a view Ability to create more complex views API for writing requires changes to upstream services
57 / 105
58 / 105
Change data capture Batch process Service events
59 / 105
60 / 105
Database triggers trigger behavior on data changes Transaction log pollers Batch delta copier
61 / 105
62 / 105
63 / 105
64 / 105
65 / 105
66 / 105
67 / 105
68 / 105
69 / 105
70 / 105
71 / 105
72 / 105
73 / 105
74 / 105
75 / 105
76 / 105
77 / 105
78 / 105
79 / 105
Database rst, code second Code rst, database second Both at once
80 / 105
81 / 105
82 / 105
83 / 105
84 / 105
85 / 105
86 / 105
Atomicity Consistency Isolation Durability
87 / 105
88 / 105
89 / 105
90 / 105
Pros: Guarantees an atomic transaction Cons: Slow, depends on the transaction coordinator Database row locking can lead to deadlocks Doesn't scale
91 / 105
92 / 105
Coordinate multiple state changes How to handle long-lived transactions? Break-up the LLT into sub-transactions Short-lived sub-transactions
93 / 105
Online Purchase
94 / 105
Backward recovery Rollback Compensating actions Forward recovery Continue and retry https://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf
95 / 105
Online Purchase
96 / 105
Online Purchase Rollback
(ROLLBACK) Remove the reservation
(ROLLBACK) Return the money back to the user
(ROLLBACK) Notify use that the item is not available
97 / 105
Orchestrated Sagas rely on centralized coordination Choreographed Sagas no centralized coordination more complicated tracking
98 / 105
99 / 105
Pros: Whole business process centralized orchestrator Easier to understand Cons Increased coupling (orchestrator knows about everything) Anemic services (logic in the orchestrator)
100 / 105
101 / 105
102 / 105
Pros: Loose coupling (services react to events) No centralization Cons: Hard to know what's happening Hard to get the state of saga
103 / 105
Books: Monolith to Microservices by Sam Newman Cloud Native: Using Containers, Functions, and Data by Scholl, Swanson, and Jausovec Blogs/Articles: SAGAS by Hector Garcia-Molina and Kenneth Salem Chris Richardson's Blog Martin Fowler's Blog
104 / 105
Contact @pjausovec peterj.dev Slides: https://slides.peterj.dev Demos: https://github.com/peterj/gids-deconstructing-monoliths
105 / 105