● Define authoritative sources
● Compose at the edge
● Use lifecycle events when necessary
The problems
Eventual consistency
Slide 24
Slide 24 text
The problems
Too many stacks
Slide 25
Slide 25 text
● Standardize RPC and async mechanisms
● Provide support levels for different tech stacks
The problems
Too many stacks
Slide 26
Slide 26 text
The problems
Protecting against API changes
Slide 27
Slide 27 text
● Tolerant readers
● Consumer driven contracts
The problems
Protecting against API changes
Slide 28
Slide 28 text
The problems
Increased chattiness
Slide 29
Slide 29 text
● API Gateway
● BFF
The problems
Increased chattiness
Slide 30
Slide 30 text
Our architecture
Slide 31
Slide 31 text
Our architecture
High level overview
Slide 32
Slide 32 text
Our architecture
Layers
Slide 33
Slide 33 text
Extracting services
Slide 34
Slide 34 text
Identify a candidate
Does this feature need many changes? Is this feature causing technical risk?
Choose an integration approach
How to integrate the extracted service?
Choose a migration strategy for data
How to move the data to its own storage?
Extracting services
The process
1
2
3
Slide 35
Slide 35 text
Identify a candidate
Does this feature need many changes? Is this feature causing technical risk?
Choose an integration approach
How to integrate the extracted service?
Choose a migration strategy for data
How to move the data to its own storage?
Extracting services
The process
1
2
3
Slide 36
Slide 36 text
Choose an integration approach
Monolith as gateway
BEFO
R
E
Monolith
Slide 37
Slide 37 text
Choose an integration approach
Monolith as gateway
Monolith
Service Service
AFTER
Slide 38
Slide 38 text
Introduce a service layer for the feature
If you don’t have it already
Add an alternate path under a feature flag
Beware that in-memory joins than may be needed
Switch the traffic
Now the code can be cleaned up
Monolith as a gateway
The process
2.1
2.2
2.3
Slide 39
Slide 39 text
def index
likes = user_likes_service.public_track_likes(
@user, pagination)
respond collection_for(likes)
end
Monolith as a gateway
Introduce a service layer for the feature
Slide 40
Slide 40 text
Introduce a service layer for the feature
If you don’t have it already
Add an alternate path under a feature flag
Beware that in-memory joins than may be needed
Switch the traffic
Now the code can be cleaned up
Monolith as a gateway
The process
2.1
2.2
2.3
Slide 41
Slide 41 text
def public_track_likes(user, pagination)
if $feature.active?(:use_likes_service, user)
…
else
…
end
end
Monolith as a gateway
Add an alternate path under a feature flag
Slide 42
Slide 42 text
Introduce a service layer for the feature
If you don’t have it already
Add an alternate path under a feature flag
Beware that in-memory joins than may be needed
Switch the traffic
Now the code can be cleaned up
Monolith as a gateway
The process
2.1
2.2
2.3
Slide 43
Slide 43 text
Choose an integration approach
Strangler
Monolith
BEFO
R
E
Slide 44
Slide 44 text
Choose an integration approach
Strangler
Strangler
STR
AN
G
LIN
G
Monolith
Slide 45
Slide 45 text
Choose an integration approach
Strangler
Strangler
Service Monolith
AFTER
Slide 46
Slide 46 text
Choose an integration approach
Strangler
Strangler
Service Service
SO
M
E
D
AY...
Service Service
Slide 47
Slide 47 text
Introduce handlers for the paths
This allows for intervention
Add an alternate path under a feature flag
This may imply invoking not only the new service
Switch the traffic
Now the code can be cleaned up
Strangler
The process
2.1
2.2
2.3
Slide 48
Slide 48 text
def index
handle(request)
end
Strangler
Introduce handlers for the paths
Slide 49
Slide 49 text
Introduce handlers for the paths
This allows for intervention
Add an alternate path under a feature flag
This may imply invoking not only the new service
Switch the traffic
Now the code can be cleaned up
Strangler
The process
2.1
2.2
2.3
Slide 50
Slide 50 text
def index
if $feature.active?(:use_likes_service, @current_user)
…
else
handle(request)
end
end
Strangler
Add an alternate path under a feature flag
Slide 51
Slide 51 text
Introduce handlers for the paths
This allows for intervention
Add an alternate path under a feature flag
This may imply invoking not only the new service
Switch the traffic
Now the code can be cleaned up
Strangler
The process
2.1
2.2
2.3
Slide 52
Slide 52 text
Identify a candidate
Does this feature need many changes? Is this feature causing technical risk?
Choose an integration approach
How to integrate the extracted service?
Choose a migration strategy for data
How to move the data to its own storage?
Extracting services
The process
1
2
3
Slide 53
Slide 53 text
Choose a migration strategy for data
New schema
Monolith
BEFO
R
E
Slide 54
Slide 54 text
Choose a migration strategy for data
New schema
Monolith
M
IG
R
ATIO
N
A
Service
B
Slide 55
Slide 55 text
Choose a migration strategy for data
New schema
AFTER
Monolith
A
Service
B
Slide 56
Slide 56 text
● Allows changing the storage engine
● Adds risk to the migration project
● I haven’t used it personally, more suitable for services extracted for feature changes.
Choose a migration strategy for data
New schema
Slide 57
Slide 57 text
Choose a migration strategy for data
Same schema
Monolith
BEFO
R
E
Slide 58
Slide 58 text
Choose a migration strategy for data
Same schema
Monolith
M
IG
R
ATIO
N
A
Service
A’
Slide 59
Slide 59 text
Choose a migration strategy for data
Same schema
AFTER
Monolith
A
Service
A’
Slide 60
Slide 60 text
● Low risk migration
● We usually move the reads slowly and then do a quick write path cut-over
● We’ve chosen this approach for services extracted due to technical risk
Choose a migration strategy for data
Same schema
Slide 61
Slide 61 text
● Systems that were reading directly from the DB
● How to cut-over writes
● Migrating events from the monolith to the service
● Outages
Extracting services
Some details I omitted
Slide 62
Slide 62 text
Conclusions
Slide 63
Slide 63 text
Small focused teams Delivering features faster
Conclusions
Reasons to migrate
Slide 64
Slide 64 text
Fast provisioning Monitoring Deployment pipeline
Conclusions
Requisites for migrating (Fowler)
Slide 65
Slide 65 text
More moving parts
Conclusions
The problem you introduce
Slide 66
Slide 66 text
One feature at a time When you need it Don’t stop delivering!
Conclusions
How to break your monolith
Slide 67
Slide 67 text
It’s all about trade-offs!
Conclusions
Should you do it?