SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Shattering
The
Monolith(s)
Adventures in Kafka Adoption and Legacy Code
Martin Kess, Software Engineer @ Lyft
Meet Namely
● NYC startup
● All-in-one HR platform for midsized business.
● Originally just HRIS.
● Acquired Payroll Company in ~2015.
… and now there are TWO monoliths.
This talk is about unifying these monoliths
using Kafka.
Monolith Isn't A Four Letter Word!
● Monoliths aren't bad.
● Duplicated core domain.
● Changes don't flow between systems.
● Unnecessary work for engineering,
operations, clients.
Why Is Kafka A Good Match?
● HR domain is naturally event driven.
● History of a domain entity is interesting.
● Customers demand rich reporting.
● Auditing requirements are strict.
● A lot of systems to integrate.
We Want Domain Events
Commands are requests for state change. Commands can fail.
CreateCompany (Please)
Domain Events are facts about changes to Domain Entities as
a result of Commands.
CompanyCreated
Events can't fail - they already happened!
Kafka As The Source Of Truth
Kafka is a log of Domain Events.
One Kafka topic per type of Domain Entity.
Other services create Views of Domain Events.
Domain Event data wrapped in Envelope with metadata.
Reader
Reader
Building Kafka-First Services
Domain Service gets Command (RPC), validates and
produces one or more Domain Events.
Readers consume events and (usually) provide read API.
Domain
Service
(API)
ReadersKafka
CompanyCreatedRPC
Events Give Reporting + Auditing
Big advantage: rich reporting.
● How many people work here?
● How much is payroll projected to be next cycle?
● How much would it cost to open a new office in SF and
hire 20 engineers over 6 months?
● Who approved that bonus payment?
Challenges We Faced
1. Tooling Is Essential
2. Schema Evolution
3. Eventual Consistency
4. Error Handling
5. Data Migration
Tooling Is Essential
Need tools!
● Developer Self Service
● KSQL
● Lenses.io
● Libraries and templates
Schema Evolution
Data is forever. Want to make sure it's useful.
Schema backward compatibility: old messages should be
readable by newer readers. Use Avro for this.
Data backward compatibility: old messages should be
meaningful to newer readers. Populate deprecated fields (i.e.
name and first_name/last_name) until migration.
Eventual Consistency
How to read your writes with Kafka. User saves - page shows
old data until they refresh.
Writer does validation before emitting event. UI updates
state on successful write, without hitting reader.
Reader
Reader
Writer ReadersKafka
CompanyCreated
Consumer Error Handling
Transient: can't write to database or call other service
because it's unavailable (5xx). Just retry.
Permanent: Can't deserialize message/message doesn't make
sense. Stop!
Need metrics, and give services flags to skip permanent
failures (or use etcd to push configs).
Transient failures are expected.
Permanent failures are bugs.
Migration
Would be great if we were building a brand new system…
But we have existing data in several databases, and a lot of
software that relies on that data.
Legacy
DB
#1
Legacy
DB
#2
Legacy
DB
#3
Migration - APIs
First, create a write API proxy for the services.
Migrate all of the places that wrote to legacy system to use this proxy
API.
Proxy API just a pass through layer for
your legacy systems. Legacy
DB
#1
Legacy
DB
#3
Legacy
DB
#2
Proxy
API
Migration - Domain Events
Challenge with this is multiple writes - what if write to third system
fails?
Retry idempotently, but need to store that info somewhere. So have
the API proxy (no longer a proxy) write it to
Kafka as a Domain Event.
Then use that Domain Event to populate
the legacy system.
Legacy
DB
#1
Legacy
DB
#3
Legacy
DB
#2
Proxy
API
Kafka
Migration - Backfillers
Backfillers read Kafka topic and populate legacy system. One
backfiller per legacy system. Legacy DBs augmented with
link to new world record.
Legacy
DB
#1
Legacy
DB
#3
Domain
Service
Kafka
CompanyCreated
Legacy
DB
#2
Backfiller
Backfiller
Backfiller
Migration - Existing Data
Services have flag-enabled migration path that takes legacy
data from databases, and writes to their Kafka topic. That way
write logic is reused.
Domain
Service
Kafka
Legacy
DB
#1
Backfiller
If migrate flag is set, reads from legacy DB to
generate initial set of Domain Events in Kafka.
CompanyCreated
Migration - Existing Data Pt. 2
Not always so easy!
What if data in one legacy system doesn't agree with the
other (i.e. different name in each).
What if data in one system can't be represented in another?
You will find lots of fun and exciting things about your data!
Migration - Push Ops To Clients
Push your operations away from engineering and toward the
clients.
Build tooling and features to help clients and operations
teams clean up data (i.e. ask client to input name when a
disagreement is detected that can't be reconciled).
Build tooling to support the migration (enable new feature →
give data cleanup workflow to client or operations).
Migration - Insights
1. Start with new clients only.
2. Plan for migration of existing clients from the start.
3. Push operations toward customer!
4. Consolidate data into one legacy system first if
possible.
Summary
● Know your domain - find your aggregates.
● Buy and build tooling.
● Eventual consistency is hard. It takes time to understand.
● Plan for migration.
● Separate feature development from migration.
● Push operations away from engineering toward
customer.
● Embrace eventual consistency.
Q&A
@mdkess
Services Own Domain Events
Typical flow:
1. Command (RPC) to change entity.
2. Domain Service validates command makes sense.
3. Domain Service writes one or more Domain Events to
Kafka topic(s).
4. Other systems read Domain Events, possibly storing
them.

Contenu connexe

Tendances

Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020
Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020
Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020
HostedbyConfluent
 
Stream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data Platform
Stream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data PlatformStream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data Platform
Stream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data Platform
confluent
 
Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...
Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...
Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...
HostedbyConfluent
 

Tendances (20)

Gwen Shapira, Confluent | Kafka Summit 2020 Keynote | Kafka’s New Architecture
Gwen Shapira, Confluent | Kafka Summit 2020 Keynote | Kafka’s New ArchitectureGwen Shapira, Confluent | Kafka Summit 2020 Keynote | Kafka’s New Architecture
Gwen Shapira, Confluent | Kafka Summit 2020 Keynote | Kafka’s New Architecture
 
Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020
Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020
Kafka Lag Monitoring For Human Beings (Elad Leev, AppsFlyer) Kafka Summit 2020
 
How to over-engineer things and have fun? | Oto Brglez, OPALAB
How to over-engineer things and have fun? | Oto Brglez, OPALABHow to over-engineer things and have fun? | Oto Brglez, OPALAB
How to over-engineer things and have fun? | Oto Brglez, OPALAB
 
Common Patterns of Multi Data-Center Architectures with Apache Kafka
Common Patterns of Multi Data-Center Architectures with Apache KafkaCommon Patterns of Multi Data-Center Architectures with Apache Kafka
Common Patterns of Multi Data-Center Architectures with Apache Kafka
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
 
Kafka Streams for Java enthusiasts
Kafka Streams for Java enthusiastsKafka Streams for Java enthusiasts
Kafka Streams for Java enthusiasts
 
Streaming all over the world Real life use cases with Kafka Streams
Streaming all over the world  Real life use cases with Kafka StreamsStreaming all over the world  Real life use cases with Kafka Streams
Streaming all over the world Real life use cases with Kafka Streams
 
Stream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data Platform
Stream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data PlatformStream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data Platform
Stream Me Up, Scotty: Transitioning to the Cloud Using a Streaming Data Platform
 
Monitoring and Resiliency Testing our Apache Kafka Clusters at Goldman Sachs ...
Monitoring and Resiliency Testing our Apache Kafka Clusters at Goldman Sachs ...Monitoring and Resiliency Testing our Apache Kafka Clusters at Goldman Sachs ...
Monitoring and Resiliency Testing our Apache Kafka Clusters at Goldman Sachs ...
 
Data integration with Apache Kafka
Data integration with Apache KafkaData integration with Apache Kafka
Data integration with Apache Kafka
 
Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...
Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...
Kafka as your Data Lake - is it Feasible? (Guido Schmutz, Trivadis) Kafka Sum...
 
Westpac Bank Tech Talk 1: Dive into Apache Kafka
Westpac Bank Tech Talk 1: Dive into Apache KafkaWestpac Bank Tech Talk 1: Dive into Apache Kafka
Westpac Bank Tech Talk 1: Dive into Apache Kafka
 
Utilizing Kafka Connect to Integrate Classic Monoliths into Modern Microservi...
Utilizing Kafka Connect to Integrate Classic Monoliths into Modern Microservi...Utilizing Kafka Connect to Integrate Classic Monoliths into Modern Microservi...
Utilizing Kafka Connect to Integrate Classic Monoliths into Modern Microservi...
 
How did we move the mountain? - Migrating 1 trillion+ messages per day across...
How did we move the mountain? - Migrating 1 trillion+ messages per day across...How did we move the mountain? - Migrating 1 trillion+ messages per day across...
How did we move the mountain? - Migrating 1 trillion+ messages per day across...
 
Kafka Summit SF 2017 - Database Streaming at WePay
Kafka Summit SF 2017 - Database Streaming at WePayKafka Summit SF 2017 - Database Streaming at WePay
Kafka Summit SF 2017 - Database Streaming at WePay
 
Spring Kafka beyond the basics - Lessons learned on our Kafka journey (Tim va...
Spring Kafka beyond the basics - Lessons learned on our Kafka journey (Tim va...Spring Kafka beyond the basics - Lessons learned on our Kafka journey (Tim va...
Spring Kafka beyond the basics - Lessons learned on our Kafka journey (Tim va...
 
Developing a custom Kafka connector? Make it shine! | Igor Buzatović, Porsche...
Developing a custom Kafka connector? Make it shine! | Igor Buzatović, Porsche...Developing a custom Kafka connector? Make it shine! | Igor Buzatović, Porsche...
Developing a custom Kafka connector? Make it shine! | Igor Buzatović, Porsche...
 
Capture the Streams of Database Changes
Capture the Streams of Database ChangesCapture the Streams of Database Changes
Capture the Streams of Database Changes
 
So You’ve Inherited Kafka? Now What? (Alon Gavra, AppsFlyer) Kafka Summit Lon...
So You’ve Inherited Kafka? Now What? (Alon Gavra, AppsFlyer) Kafka Summit Lon...So You’ve Inherited Kafka? Now What? (Alon Gavra, AppsFlyer) Kafka Summit Lon...
So You’ve Inherited Kafka? Now What? (Alon Gavra, AppsFlyer) Kafka Summit Lon...
 
Failing to Cross the Streams – Lessons Learned the Hard Way | Philip Schmitt,...
Failing to Cross the Streams – Lessons Learned the Hard Way | Philip Schmitt,...Failing to Cross the Streams – Lessons Learned the Hard Way | Philip Schmitt,...
Failing to Cross the Streams – Lessons Learned the Hard Way | Philip Schmitt,...
 

Similaire à Shattering The Monolith(s) (Martin Kess, Namely) Kafka Summit SF 2019

From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
HostedbyConfluent
 
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Kai Wähner
 
markfinleyResumeMarch2016
markfinleyResumeMarch2016markfinleyResumeMarch2016
markfinleyResumeMarch2016
Mark Finley
 
Тарас Кльоба "ETL — вже не актуальна; тривалі живі потоки із системою Apache...
Тарас Кльоба  "ETL — вже не актуальна; тривалі живі потоки із системою Apache...Тарас Кльоба  "ETL — вже не актуальна; тривалі живі потоки із системою Apache...
Тарас Кльоба "ETL — вже не актуальна; тривалі живі потоки із системою Apache...
Lviv Startup Club
 

Similaire à Shattering The Monolith(s) (Martin Kess, Namely) Kafka Summit SF 2019 (20)

101 mistakes FINN.no has made with Kafka (Baksida meetup)
101 mistakes FINN.no has made with Kafka (Baksida meetup)101 mistakes FINN.no has made with Kafka (Baksida meetup)
101 mistakes FINN.no has made with Kafka (Baksida meetup)
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
 
Microservices on top of kafka
Microservices on top of kafkaMicroservices on top of kafka
Microservices on top of kafka
 
Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !
 
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
From Monoliths to Microservices - A Journey With Confluent With Gayathri Veal...
 
Air traffic controller - Streams Processing meetup
Air traffic controller  - Streams Processing meetupAir traffic controller  - Streams Processing meetup
Air traffic controller - Streams Processing meetup
 
Otimizações de Projetos de Big Data, Dw e AI no Microsoft Azure
Otimizações de Projetos de Big Data, Dw e AI no Microsoft AzureOtimizações de Projetos de Big Data, Dw e AI no Microsoft Azure
Otimizações de Projetos de Big Data, Dw e AI no Microsoft Azure
 
10 Principals for Effective Event-Driven Microservices with Apache Kafka
10 Principals for Effective Event-Driven Microservices with Apache Kafka10 Principals for Effective Event-Driven Microservices with Apache Kafka
10 Principals for Effective Event-Driven Microservices with Apache Kafka
 
10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices
 
Etl is Dead; Long Live Streams
Etl is Dead; Long Live StreamsEtl is Dead; Long Live Streams
Etl is Dead; Long Live Streams
 
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
 
Microservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka EcosystemMicroservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka Ecosystem
 
Typesafe & William Hill: Cassandra, Spark, and Kafka - The New Streaming Data...
Typesafe & William Hill: Cassandra, Spark, and Kafka - The New Streaming Data...Typesafe & William Hill: Cassandra, Spark, and Kafka - The New Streaming Data...
Typesafe & William Hill: Cassandra, Spark, and Kafka - The New Streaming Data...
 
markfinleyResumeMarch2016
markfinleyResumeMarch2016markfinleyResumeMarch2016
markfinleyResumeMarch2016
 
MongoDB World 2019: Streaming ETL on the Shoulders of Giants
MongoDB World 2019: Streaming ETL on the Shoulders of GiantsMongoDB World 2019: Streaming ETL on the Shoulders of Giants
MongoDB World 2019: Streaming ETL on the Shoulders of Giants
 
Hybrid Kafka, Taking Real-time Analytics to the Business (Cody Irwin, Google ...
Hybrid Kafka, Taking Real-time Analytics to the Business (Cody Irwin, Google ...Hybrid Kafka, Taking Real-time Analytics to the Business (Cody Irwin, Google ...
Hybrid Kafka, Taking Real-time Analytics to the Business (Cody Irwin, Google ...
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Spring, Functions, Serverless and You
Spring, Functions, Serverless and YouSpring, Functions, Serverless and You
Spring, Functions, Serverless and You
 
Тарас Кльоба "ETL — вже не актуальна; тривалі живі потоки із системою Apache...
Тарас Кльоба  "ETL — вже не актуальна; тривалі живі потоки із системою Apache...Тарас Кльоба  "ETL — вже не актуальна; тривалі живі потоки із системою Apache...
Тарас Кльоба "ETL — вже не актуальна; тривалі живі потоки із системою Apache...
 
Apache Kafka® and the Data Mesh
Apache Kafka® and the Data MeshApache Kafka® and the Data Mesh
Apache Kafka® and the Data Mesh
 

Plus de confluent

Plus de confluent (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Santander Stream Processing with Apache Flink
Santander Stream Processing with Apache FlinkSantander Stream Processing with Apache Flink
Santander Stream Processing with Apache Flink
 
Unlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insightsUnlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insights
 
Workshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con FlinkWorkshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con Flink
 
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
 
AWS Immersion Day Mapfre - Confluent
AWS Immersion Day Mapfre   -   ConfluentAWS Immersion Day Mapfre   -   Confluent
AWS Immersion Day Mapfre - Confluent
 
Eventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkEventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalk
 
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent CloudQ&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluent
 
Q&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service MeshQ&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service Mesh
 
Citi Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka MicroservicesCiti Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka Microservices
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernization
 
Citi Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataCiti Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time data
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesis
 
The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streams
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Shattering The Monolith(s) (Martin Kess, Namely) Kafka Summit SF 2019

  • 1. Shattering The Monolith(s) Adventures in Kafka Adoption and Legacy Code Martin Kess, Software Engineer @ Lyft
  • 2. Meet Namely ● NYC startup ● All-in-one HR platform for midsized business. ● Originally just HRIS. ● Acquired Payroll Company in ~2015. … and now there are TWO monoliths. This talk is about unifying these monoliths using Kafka.
  • 3. Monolith Isn't A Four Letter Word! ● Monoliths aren't bad. ● Duplicated core domain. ● Changes don't flow between systems. ● Unnecessary work for engineering, operations, clients.
  • 4. Why Is Kafka A Good Match? ● HR domain is naturally event driven. ● History of a domain entity is interesting. ● Customers demand rich reporting. ● Auditing requirements are strict. ● A lot of systems to integrate.
  • 5. We Want Domain Events Commands are requests for state change. Commands can fail. CreateCompany (Please) Domain Events are facts about changes to Domain Entities as a result of Commands. CompanyCreated Events can't fail - they already happened!
  • 6. Kafka As The Source Of Truth Kafka is a log of Domain Events. One Kafka topic per type of Domain Entity. Other services create Views of Domain Events. Domain Event data wrapped in Envelope with metadata.
  • 7. Reader Reader Building Kafka-First Services Domain Service gets Command (RPC), validates and produces one or more Domain Events. Readers consume events and (usually) provide read API. Domain Service (API) ReadersKafka CompanyCreatedRPC
  • 8. Events Give Reporting + Auditing Big advantage: rich reporting. ● How many people work here? ● How much is payroll projected to be next cycle? ● How much would it cost to open a new office in SF and hire 20 engineers over 6 months? ● Who approved that bonus payment?
  • 9. Challenges We Faced 1. Tooling Is Essential 2. Schema Evolution 3. Eventual Consistency 4. Error Handling 5. Data Migration
  • 10. Tooling Is Essential Need tools! ● Developer Self Service ● KSQL ● Lenses.io ● Libraries and templates
  • 11. Schema Evolution Data is forever. Want to make sure it's useful. Schema backward compatibility: old messages should be readable by newer readers. Use Avro for this. Data backward compatibility: old messages should be meaningful to newer readers. Populate deprecated fields (i.e. name and first_name/last_name) until migration.
  • 12. Eventual Consistency How to read your writes with Kafka. User saves - page shows old data until they refresh. Writer does validation before emitting event. UI updates state on successful write, without hitting reader. Reader Reader Writer ReadersKafka CompanyCreated
  • 13. Consumer Error Handling Transient: can't write to database or call other service because it's unavailable (5xx). Just retry. Permanent: Can't deserialize message/message doesn't make sense. Stop! Need metrics, and give services flags to skip permanent failures (or use etcd to push configs). Transient failures are expected. Permanent failures are bugs.
  • 14. Migration Would be great if we were building a brand new system… But we have existing data in several databases, and a lot of software that relies on that data. Legacy DB #1 Legacy DB #2 Legacy DB #3
  • 15. Migration - APIs First, create a write API proxy for the services. Migrate all of the places that wrote to legacy system to use this proxy API. Proxy API just a pass through layer for your legacy systems. Legacy DB #1 Legacy DB #3 Legacy DB #2 Proxy API
  • 16. Migration - Domain Events Challenge with this is multiple writes - what if write to third system fails? Retry idempotently, but need to store that info somewhere. So have the API proxy (no longer a proxy) write it to Kafka as a Domain Event. Then use that Domain Event to populate the legacy system. Legacy DB #1 Legacy DB #3 Legacy DB #2 Proxy API Kafka
  • 17. Migration - Backfillers Backfillers read Kafka topic and populate legacy system. One backfiller per legacy system. Legacy DBs augmented with link to new world record. Legacy DB #1 Legacy DB #3 Domain Service Kafka CompanyCreated Legacy DB #2 Backfiller Backfiller Backfiller
  • 18. Migration - Existing Data Services have flag-enabled migration path that takes legacy data from databases, and writes to their Kafka topic. That way write logic is reused. Domain Service Kafka Legacy DB #1 Backfiller If migrate flag is set, reads from legacy DB to generate initial set of Domain Events in Kafka. CompanyCreated
  • 19. Migration - Existing Data Pt. 2 Not always so easy! What if data in one legacy system doesn't agree with the other (i.e. different name in each). What if data in one system can't be represented in another? You will find lots of fun and exciting things about your data!
  • 20. Migration - Push Ops To Clients Push your operations away from engineering and toward the clients. Build tooling and features to help clients and operations teams clean up data (i.e. ask client to input name when a disagreement is detected that can't be reconciled). Build tooling to support the migration (enable new feature → give data cleanup workflow to client or operations).
  • 21. Migration - Insights 1. Start with new clients only. 2. Plan for migration of existing clients from the start. 3. Push operations toward customer! 4. Consolidate data into one legacy system first if possible.
  • 22. Summary ● Know your domain - find your aggregates. ● Buy and build tooling. ● Eventual consistency is hard. It takes time to understand. ● Plan for migration. ● Separate feature development from migration. ● Push operations away from engineering toward customer. ● Embrace eventual consistency.
  • 24. Services Own Domain Events Typical flow: 1. Command (RPC) to change entity. 2. Domain Service validates command makes sense. 3. Domain Service writes one or more Domain Events to Kafka topic(s). 4. Other systems read Domain Events, possibly storing them.