Grokking Techtalk #39: How to build an event driven architecture with Kafka & Kafka Connect

How to build an event driven architecture
with Kafka & Kafka Connect
Nov 12, 2020
Lợi Nguyễn - Technical Architect @ VeXeRe
1
Vietnam’s largest online bus booking systemvexere.com
Name: Nguyễn Văn Lợi
Company:
● Vexere - #1 Saas based bus ticket platform in Vietnam
● Chotot - #1 Classified Marketplace in Vietnam
● Blue Orchid - A start-up founded by ex-Grab CTO
● Softfoundry - VoIP product
2
Vietnam’s largest online bus booking systemvexere.com
VeXeRe.com is a Vietnamese online bus ticket booking system that operates through
many transportation companies.
3
Vietnam’s largest online bus booking systemvexere.com 4
Vietnam’s largest online bus booking systemvexere.com 5
Vietnam’s largest online bus booking systemvexere.com
● Why event driven architecture?
● What is “Event Driven” architecture?
○ Event-carried State Transfer
○ Event Sourcing
● Event Sourcing in real world
○ What is 2 phase write?
○ MSSQL / transaction log
○ Postgresql / WAL
● What is Kafka & Kafka Connect?
○ Connector/Task/Worker
■ MSSQL Source Connector
○ Transform
○ Kafka and Kafka Connect @ vexere
○ Pros/Cons of Kafka Connect vs Custom Producer
● Use Case/Demo
○ Customer Journey Map Notification
○ Social Proof
○ Event Sourcing + CQRS
○ Data Warehouse
● Experience / Tools / Troubleshoot
○ Tools: (kafka manager, kafka tool)
○ Troubleshoot connector
○ Monitoring
○ Domain Event vs Event Sourcing Event
● Q & A & Discussion
6
Vietnam’s largest online bus booking systemvexere.com 7
Vietnam’s largest online bus booking systemvexere.com 8
Phase Challenges
Launch ● Business Idea Profitability
● Limit resource:
○ Time
○ Technology
○ Money
Growth/Expansion ● Increasing Customers
● Increasing Feature
● Adding New Products/BU
Vietnam’s largest online bus booking systemvexere.com
● Event-carried State Transfer
● Event Sourcing
9
Vietnam’s largest online bus booking systemvexere.com
10
Vietnam’s largest online bus booking systemvexere.com
11
Vietnam’s largest online bus booking systemvexere.com
12
Vietnam’s largest online bus booking systemvexere.com
● Two representation of the world:
○ Application State: the current representation of the world, and
○ log of all the events: that changed that world
● The test definition of Event Sourcing:
○ at any time we can blow away the application state and confidently rebuild it from
the log.
● Benefit:
○ Audits
○ Debugging
13
Vietnam’s largest online bus booking systemvexere.com
● What is “Event Driven” architecture?
○ Event-carried State Transfer
○ Event Sourcing
14
Vietnam’s largest online bus booking systemvexere.com
● Event Sourcing in real world
○ What is 2 phase write?
○ MSSQL / transaction log
○ Postgresql / WAL
15
Vietnam’s largest online bus booking systemvexere.com
16
Insert without WAL
Vietnam’s largest online bus booking systemvexere.com
17
Insertion operations with WAL
Vietnam’s largest online bus booking systemvexere.com
18
Vietnam’s largest online bus booking systemvexere.com
19
Vietnam’s largest online bus booking systemvexere.com
● Event Sourcing in real world
○ What is 2 phase write?
○ MSSQL / transaction log
○ Postgresql / WAL
20
Vietnam’s largest online bus booking systemvexere.com
● What is Kafka & Kafka Connect?
○ Connector/Task/Worker
○ Transform
○ How we use Kafka and Kafka Connect @ vexere
○ Pros/Cons of Kafka Connect vs Custom Producer
21
Vietnam’s largest online bus booking systemvexere.com
● topic
● producer
● consumer
● broker
● partition
● consumer group
22
Vietnam’s largest online bus booking systemvexere.com
23
Vietnam’s largest online bus booking systemvexere.com
24
Vietnam’s largest online bus booking systemvexere.com
25
Vietnam’s largest online bus booking systemvexere.com 26
Vietnam’s largest online bus booking systemvexere.com 27
Vietnam’s largest online bus booking systemvexere.com 28
Vietnam’s largest online bus booking systemvexere.com
Kafka Connect is a framework to stream data into and out of Apache Kafka
● Connectors – the high level abstraction that coordinates data streaming by managing tasks
● Tasks – the implementation of how data is copied to or from Kafka
● Workers – the running processes that execute connectors and tasks
● Converters – the code used to translate data between Connect and the system sending or receiving data
● Transforms – simple logic to alter each message produced by or sent to a connector
● Dead Letter Queue – how Connect handles connector errors
29
Vietnam’s largest online bus booking systemvexere.com
No coding required, just json config:
30
Vietnam’s largest online bus booking systemvexere.com 31
Vietnam’s largest online bus booking systemvexere.com 32
Vietnam’s largest online bus booking systemvexere.com 33
Vietnam’s largest online bus booking systemvexere.com 34
Vietnam’s largest online bus booking systemvexere.com 35
Vietnam’s largest online bus booking systemvexere.com 36
Vietnam’s largest online bus booking systemvexere.com
Pros Cons
● Many Connectors (source/sink)
● No coding required
● Simple transform only
● Hard to customize or write your own
connector
37
Vietnam’s largest online bus booking systemvexere.com
● What is Kafka & Kafka Connect?
○ Connector/Task/Worker
■ MSSQL Source Connector
○ Transform
○ How we use Kafka and Kafka Connect @ vexere
○ Pros/Cons of Kafka Connect vs Custom Producer
38
Vietnam’s largest online bus booking systemvexere.com
● Monitor kafka connect job
● AlwaysOn Cluster Config
● Database schema evolution
39
Vietnam’s largest online bus booking systemvexere.com 40
Vietnam’s largest online bus booking systemvexere.com
In Kafka Connect, task is being killed and will not recover until manually
restarted
Solution:
● Cronjob to monitor task status, then restart task by calling restful to
task api
● Dead Letter Queue to handle error in:
○ Convert
○ Transform
41
Vietnam’s largest online bus booking systemvexere.com 42
Reference: https://debezium.io/documentation/reference/connectors/sqlserver.html#sqlserver-schema-evolution
Vietnam’s largest online bus booking systemvexere.com 43
Vietnam’s largest online bus booking systemvexere.com 44
● NVARCHAR(max) is not supported in CDC table (cannot record before value,
only have after update value)
Vietnam’s largest online bus booking systemvexere.com
● Experience / Tools / Troubleshoot
○ Tools: (kafka manager, kafka tool)
○ Troubleshoot connector
○ Monitoring
45
Vietnam’s largest online bus booking systemvexere.com 46
Reward
Thay đổi thông tin tài xế, biển số xe
Đánh giá sau chuyến điThanh toán
Vietnam’s largest online bus booking systemvexere.com
Calculated from Ticket & Booking event
47
Vietnam’s largest online bus booking systemvexere.com
Separate read & write model
Write model: MSSQL
Read model: Elasticsearch
MSSQL ⇒ Kafka ⇒ Kafka consumer ⇒ Elasticsearch
48
Vietnam’s largest online bus booking systemvexere.com
Example: Real Time sync data from MSSQL ⇒ Stagging Postgres ⇒ Bigquery
Note:
● be careful when backfill data
● If we new column, we have to trigger dummy update to trigger all record event
=> a lot of trash in transaction log ==> need to write your own job
49
Vietnam’s largest online bus booking systemvexere.com
50
Vietnam’s largest online bus booking systemvexere.com 51
Reference: https://www.enterpriseintegrationpatterns.com/patterns/messaging/index.html
Vietnam’s largest online bus booking systemvexere.com
● https://martinfowler.com/articles/201701-event-driven.html
● https://www.confluent.io/blog/announcing-kafka-connect-building-large-scale-low-latenc
y-data-pipelines/
● https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/about-change-
data-capture-sql-server?view=sql-server-2017
● https://docs.confluent.io/current/connect/concepts.html
● https://www.slideshare.net/ConfluentInc/from-zero-to-hero-with-kafka-connect
● https://www.innoq.com/en/blog/domain-events-versus-event-sourcing/#eventsfromeven
tsourcing%E2%89%A0domainevents
52
Vietnam’s largest online bus booking systemvexere.com 53
Vietnam’s largest online bus booking systemvexere.com 54
1 of 54

Recommended

Grokking Techtalk #39: Gossip protocol and applications by
Grokking Techtalk #39: Gossip protocol and applicationsGrokking Techtalk #39: Gossip protocol and applications
Grokking Techtalk #39: Gossip protocol and applicationsGrokking VN
635 views28 slides
Grokking TechTalk #33: High Concurrency Architecture at TIKI by
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking VN
2.6K views23 slides
Grokking Techtalk #37: Software design and refactoring by
 Grokking Techtalk #37: Software design and refactoring Grokking Techtalk #37: Software design and refactoring
Grokking Techtalk #37: Software design and refactoringGrokking VN
856 views76 slides
Grokking Techtalk #40: Consistency and Availability tradeoff in database cluster by
Grokking Techtalk #40: Consistency and Availability tradeoff in database clusterGrokking Techtalk #40: Consistency and Availability tradeoff in database cluster
Grokking Techtalk #40: Consistency and Availability tradeoff in database clusterGrokking VN
1K views35 slides
Asynchronous processing in big system by
Asynchronous processing in big systemAsynchronous processing in big system
Asynchronous processing in big systemNghia Minh
3.1K views26 slides
Grokking TechTalk #31: Asynchronous Communications by
Grokking TechTalk #31: Asynchronous CommunicationsGrokking TechTalk #31: Asynchronous Communications
Grokking TechTalk #31: Asynchronous CommunicationsGrokking VN
5.1K views66 slides

More Related Content

What's hot

Grokking Techtalk #37: Data intensive problem by
 Grokking Techtalk #37: Data intensive problem Grokking Techtalk #37: Data intensive problem
Grokking Techtalk #37: Data intensive problemGrokking VN
823 views45 slides
Grokking Techtalk #38: Escape Analysis in Go compiler by
 Grokking Techtalk #38: Escape Analysis in Go compiler Grokking Techtalk #38: Escape Analysis in Go compiler
Grokking Techtalk #38: Escape Analysis in Go compilerGrokking VN
429 views57 slides
Distributed Transaction in Microservice by
Distributed Transaction in MicroserviceDistributed Transaction in Microservice
Distributed Transaction in MicroserviceNghia Minh
24.4K views40 slides
High Concurrency Architecture at TIKI by
High Concurrency Architecture at TIKIHigh Concurrency Architecture at TIKI
High Concurrency Architecture at TIKINghia Minh
3.3K views23 slides
SOLID & Design Patterns by
SOLID & Design PatternsSOLID & Design Patterns
SOLID & Design PatternsGrokking VN
711 views68 slides
Grokking Techtalk #45: First Principles Thinking by
Grokking Techtalk #45: First Principles ThinkingGrokking Techtalk #45: First Principles Thinking
Grokking Techtalk #45: First Principles ThinkingGrokking VN
276 views97 slides

What's hot(20)

Grokking Techtalk #37: Data intensive problem by Grokking VN
 Grokking Techtalk #37: Data intensive problem Grokking Techtalk #37: Data intensive problem
Grokking Techtalk #37: Data intensive problem
Grokking VN823 views
Grokking Techtalk #38: Escape Analysis in Go compiler by Grokking VN
 Grokking Techtalk #38: Escape Analysis in Go compiler Grokking Techtalk #38: Escape Analysis in Go compiler
Grokking Techtalk #38: Escape Analysis in Go compiler
Grokking VN429 views
Distributed Transaction in Microservice by Nghia Minh
Distributed Transaction in MicroserviceDistributed Transaction in Microservice
Distributed Transaction in Microservice
Nghia Minh24.4K views
High Concurrency Architecture at TIKI by Nghia Minh
High Concurrency Architecture at TIKIHigh Concurrency Architecture at TIKI
High Concurrency Architecture at TIKI
Nghia Minh3.3K views
SOLID & Design Patterns by Grokking VN
SOLID & Design PatternsSOLID & Design Patterns
SOLID & Design Patterns
Grokking VN711 views
Grokking Techtalk #45: First Principles Thinking by Grokking VN
Grokking Techtalk #45: First Principles ThinkingGrokking Techtalk #45: First Principles Thinking
Grokking Techtalk #45: First Principles Thinking
Grokking VN276 views
Introducing Saga Pattern in Microservices with Spring Statemachine by VMware Tanzu
Introducing Saga Pattern in Microservices with Spring StatemachineIntroducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring Statemachine
VMware Tanzu3.9K views
Etl is Dead; Long Live Streams by confluent
Etl is Dead; Long Live StreamsEtl is Dead; Long Live Streams
Etl is Dead; Long Live Streams
confluent4.2K views
Architecture Sustaining LINE Sticker services by LINE Corporation
Architecture Sustaining LINE Sticker servicesArchitecture Sustaining LINE Sticker services
Architecture Sustaining LINE Sticker services
LINE Corporation1.8K views
Kinh nghiệm triển khai Microservices tại Sapo.vn by Dotnet Open Group
Kinh nghiệm triển khai Microservices tại Sapo.vnKinh nghiệm triển khai Microservices tại Sapo.vn
Kinh nghiệm triển khai Microservices tại Sapo.vn
Dotnet Open Group6.8K views
itlchn 20 - Kien truc he thong chung khoan - Phan 2 by IT Expert Club
itlchn 20 - Kien truc he thong chung khoan - Phan 2itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2
IT Expert Club2.4K views
Tiki.vn - How we scale as a tech startup by Tung Ns
Tiki.vn - How we scale as a tech startupTiki.vn - How we scale as a tech startup
Tiki.vn - How we scale as a tech startup
Tung Ns22.5K views
How Orange Financial combat financial frauds over 50M transactions a day usin... by StreamNative
How Orange Financial combat financial frauds over 50M transactions a day usin...How Orange Financial combat financial frauds over 50M transactions a day usin...
How Orange Financial combat financial frauds over 50M transactions a day usin...
StreamNative811 views
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013 by mumrah
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
mumrah61.2K views
Data engineering in 10 years.pdf by Lars Albertsson
Data engineering in 10 years.pdfData engineering in 10 years.pdf
Data engineering in 10 years.pdf
Lars Albertsson840 views
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd by Kai Wähner
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and LinkerdService Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Kai Wähner25.1K views
Reddit/Quora Software System Design by Elia Ahadi
Reddit/Quora Software System DesignReddit/Quora Software System Design
Reddit/Quora Software System Design
Elia Ahadi982 views

Similar to Grokking Techtalk #39: How to build an event driven architecture with Kafka & Kafka Connect

How to build an event driven architecture with kafka and kafka connect by
How to build an event driven architecture with kafka and kafka connectHow to build an event driven architecture with kafka and kafka connect
How to build an event driven architecture with kafka and kafka connectLoi Nguyen
131 views51 slides
Andersen Potfolio by
Andersen PotfolioAndersen Potfolio
Andersen PotfolioIrina Shelest
394 views50 slides
Andersen-Portfolio-Latest Projects ENG by
Andersen-Portfolio-Latest Projects ENGAndersen-Portfolio-Latest Projects ENG
Andersen-Portfolio-Latest Projects ENGВладимир Ничипорович
531 views50 slides
Andersen-Portfolio-Latest Projects by
Andersen-Portfolio-Latest ProjectsAndersen-Portfolio-Latest Projects
Andersen-Portfolio-Latest ProjectsRoman Minin
378 views47 slides
"Payment System: Survival Guide", Oleksandr Tarasenko by
"Payment System: Survival Guide",  Oleksandr Tarasenko"Payment System: Survival Guide",  Oleksandr Tarasenko
"Payment System: Survival Guide", Oleksandr TarasenkoFwdays
241 views45 slides
VictoriaMetrics: Welcome to the Virtual Meet Up March 2023 by
VictoriaMetrics: Welcome to the Virtual Meet Up March 2023VictoriaMetrics: Welcome to the Virtual Meet Up March 2023
VictoriaMetrics: Welcome to the Virtual Meet Up March 2023VictoriaMetrics
123 views68 slides

Similar to Grokking Techtalk #39: How to build an event driven architecture with Kafka & Kafka Connect(20)

How to build an event driven architecture with kafka and kafka connect by Loi Nguyen
How to build an event driven architecture with kafka and kafka connectHow to build an event driven architecture with kafka and kafka connect
How to build an event driven architecture with kafka and kafka connect
Loi Nguyen131 views
Andersen-Portfolio-Latest Projects by Roman Minin
Andersen-Portfolio-Latest ProjectsAndersen-Portfolio-Latest Projects
Andersen-Portfolio-Latest Projects
Roman Minin378 views
"Payment System: Survival Guide", Oleksandr Tarasenko by Fwdays
"Payment System: Survival Guide",  Oleksandr Tarasenko"Payment System: Survival Guide",  Oleksandr Tarasenko
"Payment System: Survival Guide", Oleksandr Tarasenko
Fwdays241 views
VictoriaMetrics: Welcome to the Virtual Meet Up March 2023 by VictoriaMetrics
VictoriaMetrics: Welcome to the Virtual Meet Up March 2023VictoriaMetrics: Welcome to the Virtual Meet Up March 2023
VictoriaMetrics: Welcome to the Virtual Meet Up March 2023
VictoriaMetrics123 views
Flink Forward San Francisco 2018: - Jinkui Shi and Radu Tudoran "Flink real-t... by Flink Forward
Flink Forward San Francisco 2018: - Jinkui Shi and Radu Tudoran "Flink real-t...Flink Forward San Francisco 2018: - Jinkui Shi and Radu Tudoran "Flink real-t...
Flink Forward San Francisco 2018: - Jinkui Shi and Radu Tudoran "Flink real-t...
Flink Forward2.7K views
Improve search optimization engine with ssr in nextjs by Loi Nguyen
Improve search optimization engine with ssr in nextjsImprove search optimization engine with ssr in nextjs
Improve search optimization engine with ssr in nextjs
Loi Nguyen144 views
Grokking Techtalk #43: Payment gateway demystified by Grokking VN
Grokking Techtalk #43: Payment gateway demystifiedGrokking Techtalk #43: Payment gateway demystified
Grokking Techtalk #43: Payment gateway demystified
Grokking VN298 views
Day in the life event-driven workshop by Christina Lin
Day in the life  event-driven workshopDay in the life  event-driven workshop
Day in the life event-driven workshop
Christina Lin217 views
Network Solution by chris20854
Network SolutionNetwork Solution
Network Solution
chris208541.5K views
Open Source Networking Days- Service Mesh by CloudOps2005
Open Source Networking Days- Service MeshOpen Source Networking Days- Service Mesh
Open Source Networking Days- Service Mesh
CloudOps2005152 views
9th docker meetup 2016.07.13 by Amrita Prasad
9th docker meetup 2016.07.139th docker meetup 2016.07.13
9th docker meetup 2016.07.13
Amrita Prasad285 views
Devoxx 2018 - Pivotal and AxonIQ - Quickstart your event driven architecture by Ben Wilcock
Devoxx 2018 -  Pivotal and AxonIQ - Quickstart your event driven architectureDevoxx 2018 -  Pivotal and AxonIQ - Quickstart your event driven architecture
Devoxx 2018 - Pivotal and AxonIQ - Quickstart your event driven architecture
Ben Wilcock347 views
Real-time Fraudulent Trips Detection with Xueyao Jiang by HostedbyConfluent
Real-time Fraudulent Trips Detection with Xueyao JiangReal-time Fraudulent Trips Detection with Xueyao Jiang
Real-time Fraudulent Trips Detection with Xueyao Jiang
HostedbyConfluent183 views
Xpdays: Kubernetes CI-CD Frameworks Case Study by Denys Vasyliev
Xpdays: Kubernetes CI-CD Frameworks Case StudyXpdays: Kubernetes CI-CD Frameworks Case Study
Xpdays: Kubernetes CI-CD Frameworks Case Study
Denys Vasyliev184 views
Webinar: APPSeCONNECT Product Release 2018 - A Sneak Peek at Cloud Integration by APPSeCONNECT
Webinar: APPSeCONNECT Product Release 2018 - A Sneak Peek at Cloud IntegrationWebinar: APPSeCONNECT Product Release 2018 - A Sneak Peek at Cloud Integration
Webinar: APPSeCONNECT Product Release 2018 - A Sneak Peek at Cloud Integration
APPSeCONNECT344 views

More from Grokking VN

Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks by
Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banksGrokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks
Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banksGrokking VN
698 views32 slides
Grokking Techtalk #42: Engineering challenges on building data platform for M... by
Grokking Techtalk #42: Engineering challenges on building data platform for M...Grokking Techtalk #42: Engineering challenges on building data platform for M...
Grokking Techtalk #42: Engineering challenges on building data platform for M...Grokking VN
199 views30 slides
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform by
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platformGrokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platformGrokking VN
581 views25 slides
Grokking TechTalk #35: Efficient spellchecking by
Grokking TechTalk #35: Efficient spellcheckingGrokking TechTalk #35: Efficient spellchecking
Grokking TechTalk #35: Efficient spellcheckingGrokking VN
877 views22 slides
Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer... by
 Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer... Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer...
Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer...Grokking VN
1.1K views27 slides
Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big... by
Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big...Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big...
Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big...Grokking VN
1.3K views60 slides

More from Grokking VN(20)

Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks by Grokking VN
Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banksGrokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks
Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks
Grokking VN698 views
Grokking Techtalk #42: Engineering challenges on building data platform for M... by Grokking VN
Grokking Techtalk #42: Engineering challenges on building data platform for M...Grokking Techtalk #42: Engineering challenges on building data platform for M...
Grokking Techtalk #42: Engineering challenges on building data platform for M...
Grokking VN199 views
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform by Grokking VN
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platformGrokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Grokking VN581 views
Grokking TechTalk #35: Efficient spellchecking by Grokking VN
Grokking TechTalk #35: Efficient spellcheckingGrokking TechTalk #35: Efficient spellchecking
Grokking TechTalk #35: Efficient spellchecking
Grokking VN877 views
Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer... by Grokking VN
 Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer... Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer...
Grokking Techtalk #34: K8S On-premise: Incident & Lesson Learned ZaloPay Mer...
Grokking VN1.1K views
Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big... by Grokking VN
Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big...Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big...
Grokking TechTalk #33: Architecture of AI-First Systems - Engineering for Big...
Grokking VN1.3K views
Grokking TechTalk #30: From App to Ecosystem: Lessons Learned at Scale by Grokking VN
Grokking TechTalk #30: From App to Ecosystem: Lessons Learned at ScaleGrokking TechTalk #30: From App to Ecosystem: Lessons Learned at Scale
Grokking TechTalk #30: From App to Ecosystem: Lessons Learned at Scale
Grokking VN528 views
Grokking TechTalk #29: Building Realtime Metrics Platform at LinkedIn by Grokking VN
Grokking TechTalk #29: Building Realtime Metrics Platform at LinkedInGrokking TechTalk #29: Building Realtime Metrics Platform at LinkedIn
Grokking TechTalk #29: Building Realtime Metrics Platform at LinkedIn
Grokking VN639 views
Grokking TechTalk #27: Optimal Binary Search Tree by Grokking VN
Grokking TechTalk #27: Optimal Binary Search TreeGrokking TechTalk #27: Optimal Binary Search Tree
Grokking TechTalk #27: Optimal Binary Search Tree
Grokking VN2.3K views
Grokking TechTalk #26: Kotlin, Understand the Magic by Grokking VN
Grokking TechTalk #26: Kotlin, Understand the MagicGrokking TechTalk #26: Kotlin, Understand the Magic
Grokking TechTalk #26: Kotlin, Understand the Magic
Grokking VN362 views
Grokking TechTalk #26: Compare ios and android platform by Grokking VN
Grokking TechTalk #26: Compare ios and android platformGrokking TechTalk #26: Compare ios and android platform
Grokking TechTalk #26: Compare ios and android platform
Grokking VN270 views
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos... by Grokking VN
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
Grokking VN519 views
Grokking TechTalk #24: Kafka's principles and protocols by Grokking VN
Grokking TechTalk #24: Kafka's principles and protocolsGrokking TechTalk #24: Kafka's principles and protocols
Grokking TechTalk #24: Kafka's principles and protocols
Grokking VN951 views
Grokking TechTalk #21: Deep Learning in Computer Vision by Grokking VN
Grokking TechTalk #21: Deep Learning in Computer VisionGrokking TechTalk #21: Deep Learning in Computer Vision
Grokking TechTalk #21: Deep Learning in Computer Vision
Grokking VN955 views
Grokking TechTalk #20: PostgreSQL Internals 101 by Grokking VN
Grokking TechTalk #20: PostgreSQL Internals 101Grokking TechTalk #20: PostgreSQL Internals 101
Grokking TechTalk #20: PostgreSQL Internals 101
Grokking VN975 views
Grokking TechTalk #19: Software Development Cycle In The International Moneta... by Grokking VN
Grokking TechTalk #19: Software Development Cycle In The International Moneta...Grokking TechTalk #19: Software Development Cycle In The International Moneta...
Grokking TechTalk #19: Software Development Cycle In The International Moneta...
Grokking VN450 views
Grokking TechTalk #18B: Giới thiệu về Viễn thông Di động by Grokking VN
Grokking TechTalk #18B:  Giới thiệu về Viễn thông Di độngGrokking TechTalk #18B:  Giới thiệu về Viễn thông Di động
Grokking TechTalk #18B: Giới thiệu về Viễn thông Di động
Grokking VN894 views
Grokking TechTalk #18B: VoIP Architecture For Telecommunications by Grokking VN
Grokking TechTalk #18B: VoIP Architecture For TelecommunicationsGrokking TechTalk #18B: VoIP Architecture For Telecommunications
Grokking TechTalk #18B: VoIP Architecture For Telecommunications
Grokking VN790 views
Grokking TechTalk #18A: Vietnamese Sentiment Analysis in a Big Data Scenario:... by Grokking VN
Grokking TechTalk #18A: Vietnamese Sentiment Analysis in a Big Data Scenario:...Grokking TechTalk #18A: Vietnamese Sentiment Analysis in a Big Data Scenario:...
Grokking TechTalk #18A: Vietnamese Sentiment Analysis in a Big Data Scenario:...
Grokking VN1.1K views
Grokking TechTalk #17: Introduction to blockchain by Grokking VN
Grokking TechTalk #17: Introduction to blockchainGrokking TechTalk #17: Introduction to blockchain
Grokking TechTalk #17: Introduction to blockchain
Grokking VN1.4K views

Recently uploaded

13_DVD_Latch-up_prevention.pdf by
13_DVD_Latch-up_prevention.pdf13_DVD_Latch-up_prevention.pdf
13_DVD_Latch-up_prevention.pdfUsha Mehta
10 views16 slides
_MAKRIADI-FOTEINI_diploma thesis.pptx by
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptxfotinimakriadi
6 views32 slides
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...AakashShakya12
57 views115 slides
Electrical Crimping by
Electrical CrimpingElectrical Crimping
Electrical CrimpingIwiss Tools Co.,Ltd
21 views22 slides
Codes and Conventions.pptx by
Codes and Conventions.pptxCodes and Conventions.pptx
Codes and Conventions.pptxIsabellaGraceAnkers
7 views5 slides
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L... by
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...Anowar Hossain
12 views34 slides

Recently uploaded(20)

13_DVD_Latch-up_prevention.pdf by Usha Mehta
13_DVD_Latch-up_prevention.pdf13_DVD_Latch-up_prevention.pdf
13_DVD_Latch-up_prevention.pdf
Usha Mehta10 views
_MAKRIADI-FOTEINI_diploma thesis.pptx by fotinimakriadi
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptx
fotinimakriadi6 views
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by AakashShakya12
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
AakashShakya1257 views
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L... by Anowar Hossain
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
Anowar Hossain12 views
fakenews_DBDA_Mar23.pptx by deepmitra8
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptx
deepmitra812 views
Thermal aware task assignment for multicore processors using genetic algorithm by IJECEIAES
Thermal aware task assignment for multicore processors using genetic algorithm Thermal aware task assignment for multicore processors using genetic algorithm
Thermal aware task assignment for multicore processors using genetic algorithm
IJECEIAES30 views
7_DVD_Combinational_MOS_Logic_Circuits.pdf by Usha Mehta
7_DVD_Combinational_MOS_Logic_Circuits.pdf7_DVD_Combinational_MOS_Logic_Circuits.pdf
7_DVD_Combinational_MOS_Logic_Circuits.pdf
Usha Mehta59 views
2_DVD_ASIC_Design_FLow.pdf by Usha Mehta
2_DVD_ASIC_Design_FLow.pdf2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdf
Usha Mehta19 views
CHI-SQUARE ( χ2) TESTS.pptx by ssusera597c5
CHI-SQUARE ( χ2) TESTS.pptxCHI-SQUARE ( χ2) TESTS.pptx
CHI-SQUARE ( χ2) TESTS.pptx
ssusera597c529 views
Multi-objective distributed generation integration in radial distribution sy... by IJECEIAES
Multi-objective distributed generation integration in radial  distribution sy...Multi-objective distributed generation integration in radial  distribution sy...
Multi-objective distributed generation integration in radial distribution sy...
IJECEIAES15 views
What is Whirling Hygrometer.pdf by IIT KHARAGPUR
What is Whirling Hygrometer.pdfWhat is Whirling Hygrometer.pdf
What is Whirling Hygrometer.pdf
IIT KHARAGPUR 11 views

Grokking Techtalk #39: How to build an event driven architecture with Kafka & Kafka Connect

  • 1. How to build an event driven architecture with Kafka & Kafka Connect Nov 12, 2020 Lợi Nguyễn - Technical Architect @ VeXeRe 1
  • 2. Vietnam’s largest online bus booking systemvexere.com Name: Nguyễn Văn Lợi Company: ● Vexere - #1 Saas based bus ticket platform in Vietnam ● Chotot - #1 Classified Marketplace in Vietnam ● Blue Orchid - A start-up founded by ex-Grab CTO ● Softfoundry - VoIP product 2
  • 3. Vietnam’s largest online bus booking systemvexere.com VeXeRe.com is a Vietnamese online bus ticket booking system that operates through many transportation companies. 3
  • 4. Vietnam’s largest online bus booking systemvexere.com 4
  • 5. Vietnam’s largest online bus booking systemvexere.com 5
  • 6. Vietnam’s largest online bus booking systemvexere.com ● Why event driven architecture? ● What is “Event Driven” architecture? ○ Event-carried State Transfer ○ Event Sourcing ● Event Sourcing in real world ○ What is 2 phase write? ○ MSSQL / transaction log ○ Postgresql / WAL ● What is Kafka & Kafka Connect? ○ Connector/Task/Worker ■ MSSQL Source Connector ○ Transform ○ Kafka and Kafka Connect @ vexere ○ Pros/Cons of Kafka Connect vs Custom Producer ● Use Case/Demo ○ Customer Journey Map Notification ○ Social Proof ○ Event Sourcing + CQRS ○ Data Warehouse ● Experience / Tools / Troubleshoot ○ Tools: (kafka manager, kafka tool) ○ Troubleshoot connector ○ Monitoring ○ Domain Event vs Event Sourcing Event ● Q & A & Discussion 6
  • 7. Vietnam’s largest online bus booking systemvexere.com 7
  • 8. Vietnam’s largest online bus booking systemvexere.com 8 Phase Challenges Launch ● Business Idea Profitability ● Limit resource: ○ Time ○ Technology ○ Money Growth/Expansion ● Increasing Customers ● Increasing Feature ● Adding New Products/BU
  • 9. Vietnam’s largest online bus booking systemvexere.com ● Event-carried State Transfer ● Event Sourcing 9
  • 10. Vietnam’s largest online bus booking systemvexere.com 10
  • 11. Vietnam’s largest online bus booking systemvexere.com 11
  • 12. Vietnam’s largest online bus booking systemvexere.com 12
  • 13. Vietnam’s largest online bus booking systemvexere.com ● Two representation of the world: ○ Application State: the current representation of the world, and ○ log of all the events: that changed that world ● The test definition of Event Sourcing: ○ at any time we can blow away the application state and confidently rebuild it from the log. ● Benefit: ○ Audits ○ Debugging 13
  • 14. Vietnam’s largest online bus booking systemvexere.com ● What is “Event Driven” architecture? ○ Event-carried State Transfer ○ Event Sourcing 14
  • 15. Vietnam’s largest online bus booking systemvexere.com ● Event Sourcing in real world ○ What is 2 phase write? ○ MSSQL / transaction log ○ Postgresql / WAL 15
  • 16. Vietnam’s largest online bus booking systemvexere.com 16 Insert without WAL
  • 17. Vietnam’s largest online bus booking systemvexere.com 17 Insertion operations with WAL
  • 18. Vietnam’s largest online bus booking systemvexere.com 18
  • 19. Vietnam’s largest online bus booking systemvexere.com 19
  • 20. Vietnam’s largest online bus booking systemvexere.com ● Event Sourcing in real world ○ What is 2 phase write? ○ MSSQL / transaction log ○ Postgresql / WAL 20
  • 21. Vietnam’s largest online bus booking systemvexere.com ● What is Kafka & Kafka Connect? ○ Connector/Task/Worker ○ Transform ○ How we use Kafka and Kafka Connect @ vexere ○ Pros/Cons of Kafka Connect vs Custom Producer 21
  • 22. Vietnam’s largest online bus booking systemvexere.com ● topic ● producer ● consumer ● broker ● partition ● consumer group 22
  • 23. Vietnam’s largest online bus booking systemvexere.com 23
  • 24. Vietnam’s largest online bus booking systemvexere.com 24
  • 25. Vietnam’s largest online bus booking systemvexere.com 25
  • 26. Vietnam’s largest online bus booking systemvexere.com 26
  • 27. Vietnam’s largest online bus booking systemvexere.com 27
  • 28. Vietnam’s largest online bus booking systemvexere.com 28
  • 29. Vietnam’s largest online bus booking systemvexere.com Kafka Connect is a framework to stream data into and out of Apache Kafka ● Connectors – the high level abstraction that coordinates data streaming by managing tasks ● Tasks – the implementation of how data is copied to or from Kafka ● Workers – the running processes that execute connectors and tasks ● Converters – the code used to translate data between Connect and the system sending or receiving data ● Transforms – simple logic to alter each message produced by or sent to a connector ● Dead Letter Queue – how Connect handles connector errors 29
  • 30. Vietnam’s largest online bus booking systemvexere.com No coding required, just json config: 30
  • 31. Vietnam’s largest online bus booking systemvexere.com 31
  • 32. Vietnam’s largest online bus booking systemvexere.com 32
  • 33. Vietnam’s largest online bus booking systemvexere.com 33
  • 34. Vietnam’s largest online bus booking systemvexere.com 34
  • 35. Vietnam’s largest online bus booking systemvexere.com 35
  • 36. Vietnam’s largest online bus booking systemvexere.com 36
  • 37. Vietnam’s largest online bus booking systemvexere.com Pros Cons ● Many Connectors (source/sink) ● No coding required ● Simple transform only ● Hard to customize or write your own connector 37
  • 38. Vietnam’s largest online bus booking systemvexere.com ● What is Kafka & Kafka Connect? ○ Connector/Task/Worker ■ MSSQL Source Connector ○ Transform ○ How we use Kafka and Kafka Connect @ vexere ○ Pros/Cons of Kafka Connect vs Custom Producer 38
  • 39. Vietnam’s largest online bus booking systemvexere.com ● Monitor kafka connect job ● AlwaysOn Cluster Config ● Database schema evolution 39
  • 40. Vietnam’s largest online bus booking systemvexere.com 40
  • 41. Vietnam’s largest online bus booking systemvexere.com In Kafka Connect, task is being killed and will not recover until manually restarted Solution: ● Cronjob to monitor task status, then restart task by calling restful to task api ● Dead Letter Queue to handle error in: ○ Convert ○ Transform 41
  • 42. Vietnam’s largest online bus booking systemvexere.com 42 Reference: https://debezium.io/documentation/reference/connectors/sqlserver.html#sqlserver-schema-evolution
  • 43. Vietnam’s largest online bus booking systemvexere.com 43
  • 44. Vietnam’s largest online bus booking systemvexere.com 44 ● NVARCHAR(max) is not supported in CDC table (cannot record before value, only have after update value)
  • 45. Vietnam’s largest online bus booking systemvexere.com ● Experience / Tools / Troubleshoot ○ Tools: (kafka manager, kafka tool) ○ Troubleshoot connector ○ Monitoring 45
  • 46. Vietnam’s largest online bus booking systemvexere.com 46 Reward Thay đổi thông tin tài xế, biển số xe Đánh giá sau chuyến điThanh toán
  • 47. Vietnam’s largest online bus booking systemvexere.com Calculated from Ticket & Booking event 47
  • 48. Vietnam’s largest online bus booking systemvexere.com Separate read & write model Write model: MSSQL Read model: Elasticsearch MSSQL ⇒ Kafka ⇒ Kafka consumer ⇒ Elasticsearch 48
  • 49. Vietnam’s largest online bus booking systemvexere.com Example: Real Time sync data from MSSQL ⇒ Stagging Postgres ⇒ Bigquery Note: ● be careful when backfill data ● If we new column, we have to trigger dummy update to trigger all record event => a lot of trash in transaction log ==> need to write your own job 49
  • 50. Vietnam’s largest online bus booking systemvexere.com 50
  • 51. Vietnam’s largest online bus booking systemvexere.com 51 Reference: https://www.enterpriseintegrationpatterns.com/patterns/messaging/index.html
  • 52. Vietnam’s largest online bus booking systemvexere.com ● https://martinfowler.com/articles/201701-event-driven.html ● https://www.confluent.io/blog/announcing-kafka-connect-building-large-scale-low-latenc y-data-pipelines/ ● https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/about-change- data-capture-sql-server?view=sql-server-2017 ● https://docs.confluent.io/current/connect/concepts.html ● https://www.slideshare.net/ConfluentInc/from-zero-to-hero-with-kafka-connect ● https://www.innoq.com/en/blog/domain-events-versus-event-sourcing/#eventsfromeven tsourcing%E2%89%A0domainevents 52
  • 53. Vietnam’s largest online bus booking systemvexere.com 53
  • 54. Vietnam’s largest online bus booking systemvexere.com 54