SlideShare a Scribd company logo
Event Driven Architecture
Introduction to Event driven systems and Apache Kafka
Agenda
● Introduction to Event Driven Systems
● Introduction to different problems that arise when using Event Driven Systems
● Different patterns
● Apache Kafka
● Org-wide implementations
Lets Build Scamazon
Disclaimer: The session will have stupid poor jokes scattered all over. Forgive the incompetent joker in me.
Developer report
My code provisions the order
quickly. While investigating, I
observed that sending the order
successful mail takes a lot of
time.
Customer report
Placing an order on
Scamazon is such a pain.
It takes too long.
Latency: Amount of time it takes to complete one request
Throughput: Amount of requests that can be completed in a unit of time
Asynchronous Messaging
1. Postponing an action
2. Perform time consuming
operations
3. Faster API responses/page load
times
Command
Scamazon Customer report
I placed an order on the last
samsong smart watch before
my friend yesterday. But he got
the watch and I didnt.
Annoying Business manager
What? How can that happen?
Devs, fix it.
Transaction Ordering
1. Have a Distributed Locking
mechanism
2. Ensure Message queues
inherently supports ordering
Customer report
On your Great Scamazon
sale, I purchased a shoe. I
never got it.
Apparently Microservices
are in trend now!
Business Manager
Each customer we lose, is
one gained for FlopKart! Jeff
Bozo is going to kill us. Devs,
Do Something !!
Developer
Delivery Service was down
because some SysAd
upgraded something.
Blame them! My code is gold.
Resiliency
1. Guarantee that the action is
processed
2. Handle traffic spikes
Scale Independently
Message queues
1. Message queueing allows applications to communicate
asynchronously by sending messages to each other.
2. Messages may or may not be sent in FIFO
Message queues v/s APIs
APIs are 2-way communication.
Message Queues are 1-way communication.
Some theory
● Messages: Messages can be commands or events. Each message can have a type
and payload data to be sent across.
● Channels/Queues: Channels/Queues are delivery points the messages are sent to.
● Event Dispatcher/Producers: The duty of the dispatcher is to register channels and
produce events/messages.
● Event Handlers/Consumers: Event handlers act as destination points for receiving
events as channels do.
● Dynamic Routers: The harmony of messaging systems occurs through its routers.
Routers are responsible for selecting the proper path for a given message.
Review Message Queue Advantages
1. Decoupled Architecture: The sender’s job is to send messages to the queue
and the receiver’s job is to receive messages from the queue. This separation
allows for components to operate independently, while still communicating
with each other.
1. Fault tolerant: If the consumer server is down, the messages would still be
stored in queue until the server goes back up and retrieves it
2. Scalability: We can push all the messages in the queue and configure the rate
at which the consumer server pulls from it. This way, the receiver won’t get
overloaded with network requests and can instead maintain a steady stream
of data to process.
3. Transaction Ordering: Have patterns to Ensure messages are delivered in
order of they getting published if the use-case needs it
Publish/Subscribe
Event Notification
Advantages
1. Decoupled
2. Simple to use
3. Reduced team dependency
Disadvantages
1. Behavior of the system is
harder to determine.
Event-carried state transfer
Event Sourcing
Events may or may not be stored in
an EventStore(ex: broker).
4
Designed for Fast & low latency
applications(ex: stock trading)
1
Capture all changes to an application
state as a sequence of events.
2
Events define the state of the
system.
3
Like git, it doesn't store the latest
version of code, but maintains the
changes from the base version.
5
If server goes down, we can replay
the events and get the state back.
6
Event sourcing Advantages/ Disadvantages
Advantages
1. Entire applications can be in
memory
2. Parallel model
Disadvantages
1. Event schemas
2. Non event sourcing service
interaction
Apache Kafka
● Developed by LinkedIn.
● Building real-time streaming data pipelines that reliably
get data between systems or applications
● Building real-time streaming applications that transform
or react to the streams of data
1. Channels a.k.a Topics
2. Brokers a.k.a Routers
Distributed Streaming Platform
Records in Kafka
Each Record(Message) in kafka has:
1. Key
2. Value
3. Timestamp
Key
Value
Timestamp
null
{“orderid”:1,
“cid”: 5}
1322468906767
8461
Abhishek
1592468905404
resellerhosting
{“cid”: 5,
“addons”: []}
1492468905404
Examples:
Topic
1. Partition: Ordered, immutable
sequence of records that is
continually appended to
2. Offset: Uniquely identifies each
record within the partition
How is kafka resilient ?
1. Cluster of kafka servers
2. Partitions are replicated in all
3. Each Server function as leader for a fair share
of partitions
4. Followers passively replicate leader.
5. Each kafka server will have leaders and
followers.
P1
Broker 1
P1 P2 P3
P2 P3
Broker 2
Can you Explain?
Scenario 1:
Brokers: 3
Partitions: 3
Replication Factor: 2
Scenario 2:
Brokers: 3
Partitions: 2
Replication Factor: 3
Broker 1
P
1
P
3
Broker 2
P
2
P
1
Broker 3
P
3
P
2
Broker 1
P
1
P
2
Broker 2
P
2
P
1
P
1
Broker 3
P
2
APIs provided by Kafka
1. Producer: publish messages to one or more topics
2. Consumer: subscribe to a topic and process these messages
3. Connect API: Bind existing systems like databases to kafka topics
4. Streams API: Consume a stream of data and produce one or more output streams.
5. Admin API: manage topics, broker and other kafka objects
How Kafka handles
multiple partitions and consumers ?
Kafka Producers
● Producers publish records to the kafka topics with help of kafka provided kafka APIs
● Any number of producer can public records to the same topic
● Producers can decide the partition of the topic into which record to publish
○ For normal use case and better load balancing they follow round-robin allocation
● Batch processing on producer side. Why and at What cost?
● How records are routed from producer to the leader of target partition?
Why Zookeeper?
● Zookeeper can provide primitives to support:
○ Distributed Configuration Service
○ Synchronization
○ Cluster Management
○ Service Discovery
● Highly optimized for reads than writes.
● How kafka utilizes Zookeeper?
○ Controller Election
○ Configuration of Topics
○ Membership of the cluster
Coordination Service for Distributed Applications
Difference Between
Queue and Pub-Sub
Model?
Why is Kafka not a simple queue ?
1. durably persists all published
records—whether or not they have
been consumed—using a
configurable retention period
2. This offset is controlled by the
consumer
3. Consumer can consume however it
wants.
4. Consumer can reset to an older
offset to reprocess data or skip
ahead.
5. Kafka provides feature of both
Queuing and Pub-Sub model with its
partitioned topic based design.
Ordering of Records in Kafka
● Total ordering over records within partition
● How to achieve total ordering over all data?
● Why kafka decided to provide ordering over
only partition?
Kafka Provides better ordering than Queues!!?
Sample use cases of Kafka
1. Messaging
2. Website Activity Tracking
3. Metrics
4. Log aggregation
5. Stream processing
6. Event sourcing
Example of Enterprise Messaging in Endurance
BLL implemented event driven architecture using Kafka.
1
RP uses ActiveMQ’s Queues and Topics for messaging,
notifications etc.
2
CA uses it for CQRS via ActiveMQ.
4
OrderBox uses Kafka for Streaming changes from databases.
3
Example of
Event Driven Architecture
In Email Hosting BLL
CQRS of CA
Cassandra does replication
across nodes asynchronously
and hence is said to be
eventually consistent.
Real Time Data Streaming in OrderBox
Why Kafka for Data Streaming(why not ActiveMQ) ?
● Plethora of connectors to connect to multiple data sources.
● Inherent architecture promotes its use as a Log store.
● Kafka Streams provides an amazing set of API’s to provide aggregation features.
● This format of streaming is abbreviated as Change Data Capture
○ More details can be found here
RP use cases
1. Message from Core Web layer to
Executor Layer(Queue)
2. Cache Eviction across containers of
same service(Topic)
3. Cache eviction across different
services(Topic)
4. Can use Event Carried State
Transfer for cache updation(Topic)
Questions?
Homework!! 😬
Domain Driven Design
1
CQRS
2
Event Sourcing
3
Distributed Transactions
4
Change Data Capture
5
Log Compacted Topics
6
Thank You

More Related Content

What's hot

Building distributed processing system from scratch - Part 2
Building distributed processing system from scratch - Part 2Building distributed processing system from scratch - Part 2
Building distributed processing system from scratch - Part 2
datamantra
 
Log ingestion kafka -- impala using apex
Log ingestion   kafka -- impala using apexLog ingestion   kafka -- impala using apex
Log ingestion kafka -- impala using apex
Apache Apex
 
Apache Airflow in Production
Apache Airflow in ProductionApache Airflow in Production
Apache Airflow in Production
Robert Sanders
 
Introduction to Structured Streaming
Introduction to Structured StreamingIntroduction to Structured Streaming
Introduction to Structured Streaming
datamantra
 
Reactive programming intro
Reactive programming introReactive programming intro
Reactive programming intro
Ahmed Ehab AbdulAziz
 
Core Services behind Spark Job Execution
Core Services behind Spark Job ExecutionCore Services behind Spark Job Execution
Core Services behind Spark Job Execution
datamantra
 
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
Flink Forward
 
How I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with AirflowHow I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with Airflow
Laura Lorenz
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
Shashank L
 
Structured Streaming with Kafka
Structured Streaming with KafkaStructured Streaming with Kafka
Structured Streaming with Kafka
datamantra
 
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Reactive programming   using rx java & akka actors - pdx-scala - june 2014Reactive programming   using rx java & akka actors - pdx-scala - june 2014
Reactive programming using rx java & akka actors - pdx-scala - june 2014Thomas Lockney
 
Structured streaming in Spark
Structured streaming in SparkStructured streaming in Spark
Structured streaming in Spark
Giri R Varatharajan
 
Data Engineer’s Lunch #41: PygramETL
Data Engineer’s Lunch #41: PygramETLData Engineer’s Lunch #41: PygramETL
Data Engineer’s Lunch #41: PygramETL
Anant Corporation
 
Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
Leapfrog Technology Inc.
 
Introduction to Apache Airflow - Data Day Seattle 2016
Introduction to Apache Airflow - Data Day Seattle 2016Introduction to Apache Airflow - Data Day Seattle 2016
Introduction to Apache Airflow - Data Day Seattle 2016
Sid Anand
 
State management in Structured Streaming
State management in Structured StreamingState management in Structured Streaming
State management in Structured Streaming
datamantra
 
Introduction to Flink Streaming
Introduction to Flink StreamingIntroduction to Flink Streaming
Introduction to Flink Streaming
datamantra
 
Pluggable Pipelines
Pluggable PipelinesPluggable Pipelines
Pluggable Pipelines
setitesuk
 
Exploratory Data Analysis in Spark
Exploratory Data Analysis in SparkExploratory Data Analysis in Spark
Exploratory Data Analysis in Spark
datamantra
 
Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015
Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015
Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015
Till Rohrmann
 

What's hot (20)

Building distributed processing system from scratch - Part 2
Building distributed processing system from scratch - Part 2Building distributed processing system from scratch - Part 2
Building distributed processing system from scratch - Part 2
 
Log ingestion kafka -- impala using apex
Log ingestion   kafka -- impala using apexLog ingestion   kafka -- impala using apex
Log ingestion kafka -- impala using apex
 
Apache Airflow in Production
Apache Airflow in ProductionApache Airflow in Production
Apache Airflow in Production
 
Introduction to Structured Streaming
Introduction to Structured StreamingIntroduction to Structured Streaming
Introduction to Structured Streaming
 
Reactive programming intro
Reactive programming introReactive programming intro
Reactive programming intro
 
Core Services behind Spark Job Execution
Core Services behind Spark Job ExecutionCore Services behind Spark Job Execution
Core Services behind Spark Job Execution
 
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing...
 
How I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with AirflowHow I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with Airflow
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Structured Streaming with Kafka
Structured Streaming with KafkaStructured Streaming with Kafka
Structured Streaming with Kafka
 
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Reactive programming   using rx java & akka actors - pdx-scala - june 2014Reactive programming   using rx java & akka actors - pdx-scala - june 2014
Reactive programming using rx java & akka actors - pdx-scala - june 2014
 
Structured streaming in Spark
Structured streaming in SparkStructured streaming in Spark
Structured streaming in Spark
 
Data Engineer’s Lunch #41: PygramETL
Data Engineer’s Lunch #41: PygramETLData Engineer’s Lunch #41: PygramETL
Data Engineer’s Lunch #41: PygramETL
 
Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
 
Introduction to Apache Airflow - Data Day Seattle 2016
Introduction to Apache Airflow - Data Day Seattle 2016Introduction to Apache Airflow - Data Day Seattle 2016
Introduction to Apache Airflow - Data Day Seattle 2016
 
State management in Structured Streaming
State management in Structured StreamingState management in Structured Streaming
State management in Structured Streaming
 
Introduction to Flink Streaming
Introduction to Flink StreamingIntroduction to Flink Streaming
Introduction to Flink Streaming
 
Pluggable Pipelines
Pluggable PipelinesPluggable Pipelines
Pluggable Pipelines
 
Exploratory Data Analysis in Spark
Exploratory Data Analysis in SparkExploratory Data Analysis in Spark
Exploratory Data Analysis in Spark
 
Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015
Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015
Computing recommendations at extreme scale with Apache Flink @Buzzwords 2015
 

Similar to Event driven-arch

Apache kafka
Apache kafkaApache kafka
Apache kafka
Apache kafkaApache kafka
Apache kafka
Kumar Shivam
 
Copy of Kafka-Camus
Copy of Kafka-CamusCopy of Kafka-Camus
Copy of Kafka-CamusDeep Shah
 
Fundamentals and Architecture of Apache Kafka
Fundamentals and Architecture of Apache KafkaFundamentals and Architecture of Apache Kafka
Fundamentals and Architecture of Apache Kafka
Angelo Cesaro
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
Amita Mirajkar
 
Cluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQCluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQShameera Rathnayaka
 
Unleashing Real-time Power with Kafka.pptx
Unleashing Real-time Power with Kafka.pptxUnleashing Real-time Power with Kafka.pptx
Unleashing Real-time Power with Kafka.pptx
Knoldus Inc.
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
Araf Karsh Hamid
 
Introduction to Kafka Streams Presentation
Introduction to Kafka Streams PresentationIntroduction to Kafka Streams Presentation
Introduction to Kafka Streams Presentation
Knoldus Inc.
 
Introduction to Kafka and Event-Driven
Introduction to Kafka and Event-DrivenIntroduction to Kafka and Event-Driven
Introduction to Kafka and Event-Driven
Dimosthenis Botsaris
 
Introduction to Kafka and Event-Driven
Introduction to Kafka and Event-DrivenIntroduction to Kafka and Event-Driven
Introduction to Kafka and Event-Driven
arconsis
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
Steven Wu
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
Allen (Xiaozhong) Wang
 
Kafka aws
Kafka awsKafka aws
Kafka aws
Ariel Moskovich
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
Jemin Patel
 
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
StreamNative
 
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
confluent
 
Strimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUp
Strimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUpStrimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUp
Strimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUp
José Román Martín Gil
 
Kafka internals
Kafka internalsKafka internals
Kafka internals
David Groozman
 
Kafka Deep Dive
Kafka Deep DiveKafka Deep Dive
Kafka Deep Dive
Knoldus Inc.
 

Similar to Event driven-arch (20)

Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Copy of Kafka-Camus
Copy of Kafka-CamusCopy of Kafka-Camus
Copy of Kafka-Camus
 
Fundamentals and Architecture of Apache Kafka
Fundamentals and Architecture of Apache KafkaFundamentals and Architecture of Apache Kafka
Fundamentals and Architecture of Apache Kafka
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
 
Cluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQCluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQ
 
Unleashing Real-time Power with Kafka.pptx
Unleashing Real-time Power with Kafka.pptxUnleashing Real-time Power with Kafka.pptx
Unleashing Real-time Power with Kafka.pptx
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Introduction to Kafka Streams Presentation
Introduction to Kafka Streams PresentationIntroduction to Kafka Streams Presentation
Introduction to Kafka Streams Presentation
 
Introduction to Kafka and Event-Driven
Introduction to Kafka and Event-DrivenIntroduction to Kafka and Event-Driven
Introduction to Kafka and Event-Driven
 
Introduction to Kafka and Event-Driven
Introduction to Kafka and Event-DrivenIntroduction to Kafka and Event-Driven
Introduction to Kafka and Event-Driven
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
Kafka aws
Kafka awsKafka aws
Kafka aws
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
 
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
 
Strimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUp
Strimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUpStrimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUp
Strimzi - Where Apache Kafka meets OpenShift - OpenShift Spain MeetUp
 
Kafka internals
Kafka internalsKafka internals
Kafka internals
 
Kafka Deep Dive
Kafka Deep DiveKafka Deep Dive
Kafka Deep Dive
 

Recently uploaded

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 

Recently uploaded (20)

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 

Event driven-arch

  • 1. Event Driven Architecture Introduction to Event driven systems and Apache Kafka
  • 2. Agenda ● Introduction to Event Driven Systems ● Introduction to different problems that arise when using Event Driven Systems ● Different patterns ● Apache Kafka ● Org-wide implementations
  • 3. Lets Build Scamazon Disclaimer: The session will have stupid poor jokes scattered all over. Forgive the incompetent joker in me.
  • 4. Developer report My code provisions the order quickly. While investigating, I observed that sending the order successful mail takes a lot of time. Customer report Placing an order on Scamazon is such a pain. It takes too long. Latency: Amount of time it takes to complete one request Throughput: Amount of requests that can be completed in a unit of time
  • 5. Asynchronous Messaging 1. Postponing an action 2. Perform time consuming operations 3. Faster API responses/page load times Command
  • 6. Scamazon Customer report I placed an order on the last samsong smart watch before my friend yesterday. But he got the watch and I didnt. Annoying Business manager What? How can that happen? Devs, fix it.
  • 7. Transaction Ordering 1. Have a Distributed Locking mechanism 2. Ensure Message queues inherently supports ordering
  • 8. Customer report On your Great Scamazon sale, I purchased a shoe. I never got it. Apparently Microservices are in trend now! Business Manager Each customer we lose, is one gained for FlopKart! Jeff Bozo is going to kill us. Devs, Do Something !! Developer Delivery Service was down because some SysAd upgraded something. Blame them! My code is gold.
  • 9. Resiliency 1. Guarantee that the action is processed 2. Handle traffic spikes
  • 11. Message queues 1. Message queueing allows applications to communicate asynchronously by sending messages to each other. 2. Messages may or may not be sent in FIFO
  • 12. Message queues v/s APIs APIs are 2-way communication. Message Queues are 1-way communication.
  • 13. Some theory ● Messages: Messages can be commands or events. Each message can have a type and payload data to be sent across. ● Channels/Queues: Channels/Queues are delivery points the messages are sent to. ● Event Dispatcher/Producers: The duty of the dispatcher is to register channels and produce events/messages. ● Event Handlers/Consumers: Event handlers act as destination points for receiving events as channels do. ● Dynamic Routers: The harmony of messaging systems occurs through its routers. Routers are responsible for selecting the proper path for a given message.
  • 14. Review Message Queue Advantages 1. Decoupled Architecture: The sender’s job is to send messages to the queue and the receiver’s job is to receive messages from the queue. This separation allows for components to operate independently, while still communicating with each other. 1. Fault tolerant: If the consumer server is down, the messages would still be stored in queue until the server goes back up and retrieves it 2. Scalability: We can push all the messages in the queue and configure the rate at which the consumer server pulls from it. This way, the receiver won’t get overloaded with network requests and can instead maintain a steady stream of data to process. 3. Transaction Ordering: Have patterns to Ensure messages are delivered in order of they getting published if the use-case needs it
  • 16. Event Notification Advantages 1. Decoupled 2. Simple to use 3. Reduced team dependency Disadvantages 1. Behavior of the system is harder to determine.
  • 18. Event Sourcing Events may or may not be stored in an EventStore(ex: broker). 4 Designed for Fast & low latency applications(ex: stock trading) 1 Capture all changes to an application state as a sequence of events. 2 Events define the state of the system. 3 Like git, it doesn't store the latest version of code, but maintains the changes from the base version. 5 If server goes down, we can replay the events and get the state back. 6
  • 19. Event sourcing Advantages/ Disadvantages Advantages 1. Entire applications can be in memory 2. Parallel model Disadvantages 1. Event schemas 2. Non event sourcing service interaction
  • 20.
  • 21. Apache Kafka ● Developed by LinkedIn. ● Building real-time streaming data pipelines that reliably get data between systems or applications ● Building real-time streaming applications that transform or react to the streams of data 1. Channels a.k.a Topics 2. Brokers a.k.a Routers Distributed Streaming Platform
  • 22. Records in Kafka Each Record(Message) in kafka has: 1. Key 2. Value 3. Timestamp Key Value Timestamp null {“orderid”:1, “cid”: 5} 1322468906767 8461 Abhishek 1592468905404 resellerhosting {“cid”: 5, “addons”: []} 1492468905404 Examples:
  • 23. Topic 1. Partition: Ordered, immutable sequence of records that is continually appended to 2. Offset: Uniquely identifies each record within the partition
  • 24. How is kafka resilient ? 1. Cluster of kafka servers 2. Partitions are replicated in all 3. Each Server function as leader for a fair share of partitions 4. Followers passively replicate leader. 5. Each kafka server will have leaders and followers. P1 Broker 1 P1 P2 P3 P2 P3 Broker 2
  • 25. Can you Explain? Scenario 1: Brokers: 3 Partitions: 3 Replication Factor: 2 Scenario 2: Brokers: 3 Partitions: 2 Replication Factor: 3 Broker 1 P 1 P 3 Broker 2 P 2 P 1 Broker 3 P 3 P 2 Broker 1 P 1 P 2 Broker 2 P 2 P 1 P 1 Broker 3 P 2
  • 26. APIs provided by Kafka 1. Producer: publish messages to one or more topics 2. Consumer: subscribe to a topic and process these messages 3. Connect API: Bind existing systems like databases to kafka topics 4. Streams API: Consume a stream of data and produce one or more output streams. 5. Admin API: manage topics, broker and other kafka objects
  • 27. How Kafka handles multiple partitions and consumers ?
  • 28. Kafka Producers ● Producers publish records to the kafka topics with help of kafka provided kafka APIs ● Any number of producer can public records to the same topic ● Producers can decide the partition of the topic into which record to publish ○ For normal use case and better load balancing they follow round-robin allocation ● Batch processing on producer side. Why and at What cost? ● How records are routed from producer to the leader of target partition?
  • 29. Why Zookeeper? ● Zookeeper can provide primitives to support: ○ Distributed Configuration Service ○ Synchronization ○ Cluster Management ○ Service Discovery ● Highly optimized for reads than writes. ● How kafka utilizes Zookeeper? ○ Controller Election ○ Configuration of Topics ○ Membership of the cluster Coordination Service for Distributed Applications
  • 31. Why is Kafka not a simple queue ? 1. durably persists all published records—whether or not they have been consumed—using a configurable retention period 2. This offset is controlled by the consumer 3. Consumer can consume however it wants. 4. Consumer can reset to an older offset to reprocess data or skip ahead. 5. Kafka provides feature of both Queuing and Pub-Sub model with its partitioned topic based design.
  • 32. Ordering of Records in Kafka ● Total ordering over records within partition ● How to achieve total ordering over all data? ● Why kafka decided to provide ordering over only partition? Kafka Provides better ordering than Queues!!?
  • 33. Sample use cases of Kafka 1. Messaging 2. Website Activity Tracking 3. Metrics 4. Log aggregation 5. Stream processing 6. Event sourcing
  • 34. Example of Enterprise Messaging in Endurance BLL implemented event driven architecture using Kafka. 1 RP uses ActiveMQ’s Queues and Topics for messaging, notifications etc. 2 CA uses it for CQRS via ActiveMQ. 4 OrderBox uses Kafka for Streaming changes from databases. 3
  • 35. Example of Event Driven Architecture In Email Hosting BLL
  • 36. CQRS of CA Cassandra does replication across nodes asynchronously and hence is said to be eventually consistent.
  • 37. Real Time Data Streaming in OrderBox
  • 38. Why Kafka for Data Streaming(why not ActiveMQ) ? ● Plethora of connectors to connect to multiple data sources. ● Inherent architecture promotes its use as a Log store. ● Kafka Streams provides an amazing set of API’s to provide aggregation features. ● This format of streaming is abbreviated as Change Data Capture ○ More details can be found here
  • 39. RP use cases 1. Message from Core Web layer to Executor Layer(Queue) 2. Cache Eviction across containers of same service(Topic) 3. Cache eviction across different services(Topic) 4. Can use Event Carried State Transfer for cache updation(Topic)
  • 41. Homework!! 😬 Domain Driven Design 1 CQRS 2 Event Sourcing 3 Distributed Transactions 4 Change Data Capture 5 Log Compacted Topics 6