Slide 1

Slide 1 text

Dissecting our Legacy The Strangler Fig Pattern with Apache Kafka, Debezium and MongoDB Hans-Peter Grahsl Technical Trainer @hpgrahsl Gunnar Morling Software Engineer @gunnarmorling

Slide 2

Slide 2 text

@gunnarmorling @hpgrahsl

Slide 3

Slide 3 text

@gunnarmorling @hpgrahsl ● Technical Trainer at NETCONOMY ● Independent Consultant & Engineer ● Confluent Community Catalyst ● MongoDB Champion Hans-Peter Grahsl

Slide 4

Slide 4 text

@gunnarmorling @hpgrahsl ● Open source software engineer at Red Hat ○ Debezium ○ Quarkus ● Spec Lead for Bean Validation 2.0 ● Java Champion Gunnar Morling

Slide 5

Slide 5 text

@gunnarmorling @hpgrahsl system migrations are challenging @hpgrahsl

Slide 6

Slide 6 text

@gunnarmorling @hpgrahsl hard cut-overs are very risky @gunnarmorling

Slide 7

Slide 7 text

@gunnarmorling @hpgrahsl BIG BANG migrations often doomed to failure @hpgrahsl

Slide 8

Slide 8 text

@gunnarmorling @hpgrahsl strangler fig pattern to the rescue @gunnarmorling

Slide 9

Slide 9 text

@gunnarmorling @hpgrahsl 3 Strangler Fig Phases Eliminate Extract Co-Exist

Slide 10

Slide 10 text

@gunnarmorling @hpgrahsl System Migration Goal ● gradually evolve from old into new ● support temporary coexistence ● avoid big bang cut-over @hpgrahsl

Slide 11

Slide 11 text

@gunnarmorling @hpgrahsl Open-Source Change-Data-Capture With Debezium ● Captures INSERT/UPDATE/DELETE events by tapping into DB’s TX log ● Changes propagated via Apache Kafka & Kafka Connect

Slide 12

Slide 12 text

@gunnarmorling @hpgrahsl Debezium in a Nutshell ● Feature-rich CDC Platform ○ Based on transaction logs ○ Snapshotting, filtering, etc. ○ Outbox support ○ Web-based UI ● Very active OSS community ● Large production deployments

Slide 13

Slide 13 text

@gunnarmorling @hpgrahsl Debezium Connectors ● Stable ○ MySQL ○ Postgres ○ MongoDB ○ SQL Server ○ Db2 ○ Oracle ● Incubating ○ Vitess ○ Cassandra

Slide 14

Slide 14 text

@gunnarmorling @hpgrahsl Debezium – Deployment Alternatives

Slide 15

Slide 15 text

@gunnarmorling @hpgrahsl Debezium – Data Change Events ● Message Key: table PK ● Message Value: ○ Old and new row state ○ Metadata on table, TX id, etc. ○ Operation type, timestamp ● Serialized as JSON, Avro, etc.

Slide 16

Slide 16 text

@gunnarmorling @hpgrahsl Debezium – Data Change Events ● Message Key: table PK ● Message Value: ○ Old and new row state ○ Metadata on table, TX id, etc. ○ Operation type, timestamp ● Serialized as JSON, Avro, etc.

Slide 17

Slide 17 text

@gunnarmorling @hpgrahsl ● Message Key: table PK ● Message Value: ○ Old and new row state ○ Metadata on table, TX id, etc. ○ Operation type, timestamp ● Serialized as JSON, Avro, etc. Debezium – Data Change Events

Slide 18

Slide 18 text

@gunnarmorling @hpgrahsl

Slide 19

Slide 19 text

@gunnarmorling @hpgrahsl CDC-based Strangler Fig Pattern

Slide 20

Slide 20 text

@gunnarmorling @hpgrahsl CDC-based Strangler Fig Pattern

Slide 21

Slide 21 text

@gunnarmorling @hpgrahsl CDC-based Strangler Fig Pattern

Slide 22

Slide 22 text

@gunnarmorling @hpgrahsl CDC-based Strangler Fig Pattern

Slide 23

Slide 23 text

@gunnarmorling @hpgrahsl CDC-based Strangler Fig Pattern

Slide 24

Slide 24 text

@gunnarmorling @hpgrahsl CDC-based Strangler Fig Pattern

Slide 25

Slide 25 text

@gunnarmorling @hpgrahsl CDC Pipeline Considerations ● data model leaking from monolith ? ● “1:1 replication” → building aggregates ? ● transactional boundaries in the monolith ? @hpgrahsl

Slide 26

Slide 26 text

@gunnarmorling @hpgrahsl Enhanced CDC Pipelines

Slide 27

Slide 27 text

@gunnarmorling @hpgrahsl Enhanced CDC Pipelines

Slide 28

Slide 28 text

@gunnarmorling @hpgrahsl Enhanced CDC Pipelines

Slide 29

Slide 29 text

@hpgrahsl @gunnarmorling

Slide 30

Slide 30 text

@gunnarmorling @hpgrahsl Wrapping Up Strangler Fig Pattern Benefits ● incremental migration → “baby steps” ● pause or stop without losing spent efforts ● extraction steps ideally reversible ● rationale: ⚠ minimize risk ⚠ @hpgrahsl

Slide 31

Slide 31 text

@gunnarmorling @hpgrahsl Resources ● Debezium Website: https://debezium.io/ ● MongoDB Connector for Apache Kafka: https://www.mongodb.com/kafka-connector ● Debezium Example Repositories: https://github.com/debezium/debezium-examples ● Demo Repository: https://bit.ly/vdr21-sfp-demo

Slide 32

Slide 32 text

Hans-Peter Grahsl Technical Trainer @hpgrahsl Gunnar Morling Software Engineer @gunnarmorling

Slide 33

Slide 33 text

@gunnarmorling @hpgrahsl Image Credits in order of appearance: @davidclode https://unsplash.com/photos/T49WTav4LgU @mparzuchowski https://unsplash.com/photos/geNNFqfvw48 @florianolv https://unsplash.com/photos/ca7tJ48YD64 @mischievous_penguins https://unsplash.com/photos/wqAuyugJIeU @jernejcic https://unsplash.com/photos/Oi31uKsnM1Q @ahmad_elsafty https://unsplash.com/photos/x97saLWeMNI @anniespratt https://unsplash.com/photos/t3IYuQZRDNE @janoschphotos https://unsplash.com/photos/w9rYOScXf6E @morvanic https://unsplash.com/photos/GiUJ02Yj_io