Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Splitting Your Monolith with Feature Flags: A Guided Tour
Search
Joy Ebertz
September 02, 2021
Technology
0
25
Splitting Your Monolith with Feature Flags: A Guided Tour
The version used Sept 1, 2021 for the SAP event.
Joy Ebertz
September 02, 2021
Tweet
Share
More Decks by Joy Ebertz
See All by Joy Ebertz
How Much Should Staff+ Code? StaffPlus NYC 2023
jkebertz
0
180
Elevate_23_Advanced_FF_Usecases.pdf
jkebertz
0
15
Feature Flag Use Cases You Haven't Heard About Yet
jkebertz
0
32
So You Want to Split Your Monolith: First Steps
jkebertz
0
34
How to Split a Monolith: Service Architecture & Domain-Driven Design (DDD)
jkebertz
0
320
Splitting a Monolith Using Feature Flags
jkebertz
0
79
Other Decks in Technology
See All in Technology
長文から長文を生成するLLMツールをオープンソースで作ってみた。
tomohisa
2
140
OpenTelemetry実践 はじめの一歩
taxin
0
310
既存プロセスからの脱却と変化に適応するために必要なこと
cybozuinsideout
PRO
2
170
ビジネスロジックを「型」で表現するOOPのための関数型DDD / Functional And Type-Safe DDD for OOP
yuitosato
29
12k
Kubeflow Pipelines v2 で変わる機械学習パイプライン開発
asei
4
340
複数の LLM モデルを扱う上で直面した辛みまとめ
kazuyaseki
1
230
技術広報として2023年度に頑張ったこと / What we did well in FY2023 as a DevRel
pauli
5
460
Challenges - Open Farming Hackdays 2024
loleg
0
560
KubeCon EU 2024 : Knative Maintainers Session
salaboy
0
370
沒想過的前端錯誤處理可能比你有做的還多
line_developers_tw
PRO
0
2k
大規模なアジャイル開発の現場と技術負債 / Technical Debt
yoshiitaka
20
4k
エンジニアブランディングチームの KPI / KPI's of engineer branding team
chaspy
1
140
Featured
See All Featured
In The Pink: A Labor of Love
frogandcode
137
21k
How GitHub (no longer) Works
holman
301
140k
Product Roadmaps are Hard
iamctodd
43
9.6k
Mobile First: as difficult as doing things right
swwweet
215
8.5k
Faster Mobile Websites
deanohume
296
30k
Building a Modern Day E-commerce SEO Strategy
aleyda
15
6.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
Large-scale JavaScript Application Architecture
addyosmani
501
110k
Thoughts on Productivity
jonyablonski
57
3.8k
RailsConf 2023
tenderlove
0
510
Designing Experiences People Love
moore
135
23k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
58
14k
Transcript
A Guided Tour Splitting Your Monolith with Feature Flags Joy
Ebertz Sr Staff Engineer
Agenda • Why split a monolith? • Strategies for Splitting
a Monolith • Challenges of Splitting a Monolith • What are feature flags? • How can feature flags help?
Why Should We Split a Monolith?
What do I mean by “Splitting a Monolith?”
None
None
None
None
None
None
Why Split a Monolith? Code Entanglement
None
None
None
None
None
Unclear Ownership
None
None
None
None
Deployment Problems
Build Test Deploy
Build Test Deploy
Build Test Deploy
Build Test Deploy
Build Test Deploy
Build Test Deploy
None
None
None
None
10% 10% 10% Deploy 72% Chance Of Success
10% 10% 10% Deploy 53% Chance Of Success 10% 10%
10%
10% 10% 10% Deploy 28% Chance Of Success 10% 10%
10% 10% 10% 10% 10% 10% 10%
Deploy 1% Chance Of Success
Deploy
Deploy
Deploy
Deploy
Issue Remediation
Deploy
Strategies for Splitting a Monolith
Big Bang Pattern
Big Bang Pattern Old Application
Big Bang Pattern New Application Old Application
Big Bang Pattern New Application Old Application
Big Bang Pattern New Application Old Application
Big Bang Pattern Advantages • Easier to remove features •
Less Transition State Work
Strangler Fig Pattern Martin Fowler
Strangler Fig Pattern Old Application
Strangler Fig Pattern Old Application
Strangler Fig Pattern Old Application
Strangler Fig Pattern Old Application
Strangler Fig Pattern Old Application New Application
Strangler Fig Pattern Advantages • Less Risk • Lower time
to first benefit • Easier to sell
None
None
Where to Start
Service Map
Requests Monolith logic
Requests Monolith logic Interface
Requests Monolith logic New Microservice Interface Interface
Requests Monolith logic New Microservice Interface Interface
Requests Monolith logic New Microservice Interface Interface
What should my first service be?
First Services Edges
First Services BFF (Backend for Frontend) or Application Services
First Services BFF Application Service Application Service Application Service
First Services Problematic Functionality
First Services Infrastructure Services Authentication
First Services Infrastructure Services Authentication Event Bus
First Services Infrastructure Services Authorization Authentication Event Bus
First Services New Features
First Services Things Undergoing Major Changes
First Services • Low Dependencies • Backend for Frontend •
Unusual usage patterns • Infrastructure Components • New Features • Major Remodels
Challenges of Splitting a Monolith
None
Original Code Tangled
None
Entirely Separate Talk
Trying to Replicate Functionality
Entirely New Infrastructure
Entirely New Infrastructure
RISKY
So, how can we mitigate the risks?
What Are Feature Flags?
Other Terms • Feature Toggle • Feature Flip • Feature
Switch • Conditional Feature • Split
Code Branch Controlled by GUI
Code Sample if (Treatments.ON .equals(_splitClient.getTreatment(orgId, Splits.MY_FEATURE.name()))) { // Do Something
} else { // Do Something Else }
None
Code Sample if (Treatments.ON.equals(_splitClient.getTreatment(orgId, Splits.MY_FEATURE.splitName()))) { // Do Something }
else { // Do Something Else }
Main Use-Cases
Main Use-Cases • Releasing features
Main Use-Cases • Releasing features • Production Testing
Main Use-Cases • Releasing features • Production Testing • A/B/C
Testing
Main Use-Cases • Releasing features • Production Testing • A/B/C
Testing • Custom Packages
Main Use-Cases • Releasing features • Production Testing • A/B/C
Testing • Custom Packages • Temporary UI Customization
Main Use-Cases • Releasing features • Production Testing • A/B/C
Testing • Custom Packages • Temporary UI Customization
Releasing Features • Separating Deploy from Release • Canary/Ramped Deployment
• Off Switch
Deploy Release
</>
</> User
Prod User
Prod User
Prod Developer
Prod Developer
Prod User
Prod User Split
Prod User Split OFF OFF
Prod User Split OFF
Prod User Split OFF
Prod Split Product Owner OFF
Prod Split Product Owner ON
Prod User Split ON
Prod User Split ON
Prod User Split ON
Prod User Split ON
Prod Developer
Prod Developer
Prod User Split 10%
Prod User Split 20%
None
None
Using Feature Flags to Split a Monolith
Minimize Move
Remove Dead Code
Why is your code dead?
Why is your code dead? Method no longer referenced
Why is your code dead? Method no longer referenced Endpoint
never called
Why is your code dead? Method no longer referenced Parameter
never has certain values Endpoint never called
None
log.info(“CODE NOT DEAD UID: 12345”);
None
private void logForCleanup(String orgId, String uid) { if (Treatments.ON .equals(_splitClient.getTreatment(orgId,
Splits.CLEANUP.name()))) { String message = String.format(“CODE NOT DEAD UID: %s”, uid); log.info(message); } }
private void logForCleanup(String orgId, String uid) { if (Treatments.ON .equals(_splitClient.getTreatment(orgId,
Splits.CLEANUP.name()))) { String message = String.format(“CODE NOT DEAD UID: %s”, uid); log.info(message); } } Turn on CLEANUP split to 1%
1. Roll out to 1%
1. Roll out to 1% 2. Remove any lines hit
1. Roll out to 1% 2. Remove any lines hit
3. Roll out to 5%
1. Roll out to 1% 2. Remove any lines hit
3. Roll out to 5% 4. Remove any lines hit
1. Roll out to 1% 2. Remove any lines hit
3. Roll out to 5% 4. Remove any lines hit 5. Roll out to 100% (leave here as long as makes you comfortable)
1. Roll out to 1% 2. Remove any lines hit
3. Roll out to 5% 4. Remove any lines hit 5. Roll out to 100% (leave here as long as makes you comfortable) 6. Remove any code that hasn’t been hit
None
Stress Test Your New Systems
None
Requests Monolith logic New Microservice Mirrored Traffic
Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic
Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic
Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic
Verify Parity
Requests New Microservice Feature Flag Parity Check Monolith logic
Requests New Microservice Feature Flag Parity Check Monolith logic
Requests New Microservice Feature Flag Parity Check Monolith logic
Requests New Microservice Feature Flag Parity Check Monolith logic
Requests New Microservice Feature Flag Parity Check Monolith logic Log
if different
Requests New Microservice Feature Flag Parity Check Monolith logic Log
if different
Requests New Microservice Feature Flag Parity Check Monolith logic Log
if different
• Treatments.OLD
• Treatments.OLD • Treatments.NEW
• Treatments.OLD • Treatments.NEW • Treatments.MIRROR
• Treatments.OLD • Treatments.NEW • Treatments.MIRROR • Treatments.PARITY
• Treatments.OLD • Treatments.NEW • Treatments.MIRROR • Treatments.PARITY Default OFF
treatment
Requests New Microservice Monolith logic Treatments.OLD
Requests New Microservice Monolith logic Treatments.NEW
Requests New Microservice Mirrored Traffic Monolith logic Treatments.MIRROR
Requests New Microservice Monolith logic Treatments.PARITY Parity Check
Slowly Roll Over Traffic
Slowly Roll Over Traffic Test Traffic Only
Slowly Roll Over Traffic Internal Users
Slowly Roll Over Traffic 1%
Slowly Roll Over Traffic Free Users
Slowly Roll Over Traffic
Summary • Why split a monolith? • Strategies for Splitting
a Monolith • Challenges of Splitting a Monolith • What are feature flags? • How can feature flags help? • Remove dead code • Load test • Parity check • Gradual roll out/kill switch
What Are Feature Flags? Joy Ebertz @jkebertz Thank You!