SlideShare a Scribd company logo
1 of 34
Download to read offline
Event-driven microservices
using Apache Kafka
Andrew Schofield
Chief Architect, Event Streams
IBM Hursley Park
© 2019 IBM Corporation
What and why microservices?
Microservices is a technique for structuring an
application as a collection of services:
• Self-contained with clear interfaces and a
distinct purpose
• Loosely coupled – communicate over a
network
• Independently deployable, scalable,
maintainable and testable
© 2019 IBM Corporation
Microservices ApplicationMonolithic Application
Being event-driven is different
© 2019 IBM Corporation
Source: Gartner - From data-centric to event-centric IT priority
Why event-driven?
• Proper loose coupling means asynchronous communication
• Enables responsive applications
• In the real world, things often take time to complete
© 2019 IBM Corporation
Event-driven microservices
• Microservices communicate primarily
using events, with APIs where required
• Microservices can produce and consume
events using the publish/subscribe
pattern
• Events are handled by an event
backbone
• Data is eventually consistent
© 2019 IBM Corporation
Microservice
Microservice
Microservice
Microservice
Microservice
Event
backbone
Publish
Service
discoveryMicroservice
Microservice
Microservice
Subscribe
Subscribe
API
API
Publish
JSON /
HTTP
JSON / HTTP
Microservices
application
Apache Kafka is an Open-Source Streaming Platform
© 2019 IBM Corporation
PUBLISH & SUBSCRIBE
Read and write streams of events, like a
traditional messaging system.
PROCESS
Support scalable stream processing applications
that react to events in real-time.
STORE
Store streams of data safely in a distributed,
replicated, fault-tolerant cluster.
https://kafka.apache.org/
Kafka
Cluster
Producer ProducerProducer
Consumer ConsumerConsumer
Stream
Processor
Stream
Processor
Source
Connector
Sink Connector
Event-driven terminology
Event A message usually representing a fact at a particular time
Event stream A continuous, ordered, unbounded sequence of events
Stream processing Computation optimized for continuous processing, often with state
Stream history The historical sequence of the events on an event stream
© 2019 IBM Corporation
Apache Kafka as the event backbone
© 2019 IBM Corporation
Apache Kafka as the event backbone
© 2019 IBM Corporation
Microservice
Microservice
Apache Kafka as the event backbone
© 2019 IBM Corporation
1
Building Blocks
1 :: Event sources
Microservice
Microservice
Apache Kafka as the event backbone
© 2019 IBM Corporation
1
2
Building Blocks
1 :: Event sources
2 :: Stream processing
Microservice
Microservice
Apache Kafka as the event backbone
© 2019 IBM Corporation
1
2 App
3
Building Blocks
1 :: Event sources
2 :: Stream processing
3 :: Event archive
Microservice
Microservice
Apache Kafka as the event backbone
© 2019 IBM Corporation
App
1
2
3
4
Building Blocks
1 :: Event sources
2 :: Stream processing
3 :: Event archive
4 :: Notifications
Microservice
Microservice
How to get started
• You could run an event storming workshop
https://www.ibm.com/cloud/garage/architectures/eventDrivenArchitecture/event-storming-methodology
• Identify:
• Events
• Actors
• Data
• Commands
© 2019 IBM Corporation
A simple stream processing example
© 2019 IBM Corporation
Event backbone
Transactions
A simple stream processing example
© 2019 IBM Corporation
Event backbone
Transactions
Alerts
A simple stream processing example
© 2019 IBM Corporation
Event backbone
Transactions
Alerts
SMS alerts
Email alerts
Push alerts
A simple stream processing example
© 2019 IBM Corporation
Event backbone
Send SMS
Transactions
Alerts
Send emails
Send push
notifications
SMS alerts
Email alerts
Push alerts
© 2019 IBM Corporation
A more complex event-driven example
https://ibm-cloud-architecture.github.io/refarch-kc/design/readme/
A more complex example – component view
© 2019 IBM Corporation
Fleet
microservice
Containers
microservice
Voyages
microservice
Orders
microservice
APIAPI
A more complex example – component view
© 2019 IBM Corporation
Fleet
microservice
Containers
microservice
Voyages
microservice
Orders
microservice
APIAPI
A more complex example – component view
© 2019 IBM Corporation
Event backbone
ships containers orders voyages
Fleet
microservice
Containers
microservice
Voyages
microservice
Orders
microservice
APIAPI
A more complex example – component view
© 2019 IBM Corporation
Event backbone
ships containers problems orders voyages
Fleet
microservice
Containers
microservice
Voyages
microservice
Orders
microservice
Streaming
analytics
APIAPI
Patterns for event-driven microservices
• You want:
• Loose coupling
• Data consistency
• Efficient queries
© 2019 IBM Corporation
Patterns for event-driven microservices
• You want:
• Loose coupling
• Data consistency
• Efficient queries
• You don’t want:
• Chaos
© 2019 IBM Corporation
Patterns for event-driven microservices
• You want:
• Loose coupling
• Data consistency
• Efficient queries
• You don’t want:
• Chaos
• You need PATTERNS
© 2019 IBM Corporation
Pattern – Database per service
• Each microservice persists its own data
+ Protects independence of the microservice against external change
- Introduces complexity for data consistency across microservices
Event backbone
ships containers problems orders voyages
Fleet
microservice
Containers
microservice
Voyages
microservice
Orders
microservice
© 2019 IBM Corporation
Kafka log compaction for data replication
© 2019 IBM Corporation
0
key:a
val:A1
1
key:b
val:B1
2
key:a
val:A2
3
key:c
val:C1
Partition 0
4
key:c
val:C2
5
key:b
val:
Producer
writes
Consumer
takes latest
values and
builds own
data store
reads
Key Value
a A2
b <deleted>
c C2
Old New
Source change log Read
Kafka log compaction for data replication
© 2019 IBM Corporation
0
key:a
val:A1
1
key:b
val:B1
2
key:a
val:A2
3
key:c
val:C1
Partition 0
4
key:c
val:C2
5
key:b
val:
2
key:a
val:A2
4
key:c
val:C2
5
key:b
val:
Periodic compaction eliminates duplicate keys
to minimize storage
Partition 0
(rewritten)
Key Value
a A2
b <deleted>
c C2
Pattern – Event sourcing
• Every state change is captured as an event stored in sequence
+ Publishing events is atomic
- Event store is hard to query efficiently
© 2019 IBM Corporation
OrderCreated
OrderUpdated
OrderUpdated
OrderConfirmed
OrderShipped
OrderDelivered
OrderInTransit
Orders
microservice
Orders
DB
Command
handler
USER
Time
OrderPending
OrderBooked
OrderAssigned
Pattern – Sagas
• Orchestration of multi-step operations across microservices
+ Data consistency across microservices without distributed transactions
- Programming can be complex, particularly for failure compensation
© 2019 IBM Corporation
Event backbone
Fleet
microservice
Containers
microservice
Voyages
microservice
Orders
microservice
1 2 3 4 5
Pattern – CQRS
• Command Query Responsibility Segregation
+ Atomic writes and efficient reads at the same time
- Complex to program correctly
© 2019 IBM Corporation
Event backbone
1 2 3 4 5
Fleet MS
WRITE MODEL
Fleet MS READ
MODEL
Write-optimized
store
Read-optimized
store
Write API Read API
Summary
• Event-driven microservices offer an effective way to build loosely-
coupled applications
• Techniques such as event storming can be used to derive the objects,
commands and events in an application
• Patterns such as event sourcing and sagas make the complexity
manageable
© 2019 IBM Corporation
Event driven microservices

More Related Content

What's hot

Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecturetyrantbrian
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architectureAbdelghani Azri
 
Building Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache KafkaBuilding Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache KafkaGuido Schmutz
 
How To Run Your Containers on AWS with ECS & Fargate: Collision 2018
How To Run Your Containers on AWS with ECS & Fargate: Collision 2018How To Run Your Containers on AWS with ECS & Fargate: Collision 2018
How To Run Your Containers on AWS with ECS & Fargate: Collision 2018Amazon Web Services
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principlesSanjoy Kumar Roy
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon Web Services
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)WSO2
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesAraf Karsh Hamid
 
Accelerating App Development with AWS Amplify
Accelerating App Development with AWS AmplifyAccelerating App Development with AWS Amplify
Accelerating App Development with AWS AmplifyAmazon Web Services
 
The Complete Guide to Service Mesh
The Complete Guide to Service MeshThe Complete Guide to Service Mesh
The Complete Guide to Service MeshAspen Mesh
 

What's hot (20)

Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Introduction to Amazon EKS
Introduction to Amazon EKSIntroduction to Amazon EKS
Introduction to Amazon EKS
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Building Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache KafkaBuilding Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache Kafka
 
DevOps on AWS
DevOps on AWSDevOps on AWS
DevOps on AWS
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
How To Run Your Containers on AWS with ECS & Fargate: Collision 2018
How To Run Your Containers on AWS with ECS & Fargate: Collision 2018How To Run Your Containers on AWS with ECS & Fargate: Collision 2018
How To Run Your Containers on AWS with ECS & Fargate: Collision 2018
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for Kubernetes
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)
 
Amazon Virtual Private Cloud
Amazon Virtual Private CloudAmazon Virtual Private Cloud
Amazon Virtual Private Cloud
 
Intro to Amazon ECS
Intro to Amazon ECSIntro to Amazon ECS
Intro to Amazon ECS
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing Strategies
 
Accelerating App Development with AWS Amplify
Accelerating App Development with AWS AmplifyAccelerating App Development with AWS Amplify
Accelerating App Development with AWS Amplify
 
The Complete Guide to Service Mesh
The Complete Guide to Service MeshThe Complete Guide to Service Mesh
The Complete Guide to Service Mesh
 

Similar to Event driven microservices

Kafka with IBM Event Streams - Technical Presentation
Kafka with IBM Event Streams - Technical PresentationKafka with IBM Event Streams - Technical Presentation
Kafka with IBM Event Streams - Technical PresentationWinton Winton
 
Creating Microservices Application with IBM Cloud Private (ICP) - introductio...
Creating Microservices Application with IBM Cloud Private (ICP) - introductio...Creating Microservices Application with IBM Cloud Private (ICP) - introductio...
Creating Microservices Application with IBM Cloud Private (ICP) - introductio...PT Datacomm Diangraha
 
CICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdfCICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdfAmazon Web Services
 
IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...
IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...
IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...Michael O'Sullivan
 
The resurgence of event driven architecture
The resurgence of event driven architectureThe resurgence of event driven architecture
The resurgence of event driven architectureKim Clark
 
IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...
IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...
IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...Michael O'Sullivan
 
Streaming Sensor Data Slides_Virender
Streaming Sensor Data Slides_VirenderStreaming Sensor Data Slides_Virender
Streaming Sensor Data Slides_Virendervithakur
 
Jfokus - Reacting to an event-driven world
Jfokus - Reacting to an event-driven worldJfokus - Reacting to an event-driven world
Jfokus - Reacting to an event-driven worldGrace Jansen
 
Developing for Hybrid Cloud with Bluemix
Developing for Hybrid Cloud with BluemixDeveloping for Hybrid Cloud with Bluemix
Developing for Hybrid Cloud with BluemixRoberto Pozzi
 
JSpring Virtual 2020 - Reacting to an event-driven world
JSpring Virtual 2020 - Reacting to an event-driven worldJSpring Virtual 2020 - Reacting to an event-driven world
JSpring Virtual 2020 - Reacting to an event-driven worldGrace Jansen
 
IBM Cloud Integration Platform Introduction - Integration Tech Conference
IBM Cloud Integration Platform Introduction - Integration Tech ConferenceIBM Cloud Integration Platform Introduction - Integration Tech Conference
IBM Cloud Integration Platform Introduction - Integration Tech ConferenceRobert Nicholson
 
Introduction to Serverless Computing - OOP Munich
 Introduction to Serverless Computing - OOP Munich Introduction to Serverless Computing - OOP Munich
Introduction to Serverless Computing - OOP MunichBoaz Ziniman
 
Modern Applications Development on AWS
Modern Applications Development on AWSModern Applications Development on AWS
Modern Applications Development on AWSBoaz Ziniman
 
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014IBM France Lab
 
Open Standards Enabling Digital Transformation
Open Standards Enabling Digital TransformationOpen Standards Enabling Digital Transformation
Open Standards Enabling Digital TransformationSolace
 
Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...
Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...
Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...Amazon Web Services
 
Sharing and Deploying Data Science with KNIME Server
Sharing and Deploying Data Science with KNIME ServerSharing and Deploying Data Science with KNIME Server
Sharing and Deploying Data Science with KNIME ServerKNIMESlides
 
IBM Relay 2015: Opening Keynote
IBM Relay 2015: Opening Keynote IBM Relay 2015: Opening Keynote
IBM Relay 2015: Opening Keynote IBM
 

Similar to Event driven microservices (20)

Kafka with IBM Event Streams - Technical Presentation
Kafka with IBM Event Streams - Technical PresentationKafka with IBM Event Streams - Technical Presentation
Kafka with IBM Event Streams - Technical Presentation
 
Creating Microservices Application with IBM Cloud Private (ICP) - introductio...
Creating Microservices Application with IBM Cloud Private (ICP) - introductio...Creating Microservices Application with IBM Cloud Private (ICP) - introductio...
Creating Microservices Application with IBM Cloud Private (ICP) - introductio...
 
CICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdfCICDforModernApplications-Oslo.pdf
CICDforModernApplications-Oslo.pdf
 
IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...
IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...
IBM Cloud UCC Talk, 8th December 2020 - Cloud Native, Microservices, and Serv...
 
The resurgence of event driven architecture
The resurgence of event driven architectureThe resurgence of event driven architecture
The resurgence of event driven architecture
 
IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...
IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...
IBM Hybrid Cloud Integration UCC Talk, 23rd November 2021 - Cloud Application...
 
Streaming Sensor Data Slides_Virender
Streaming Sensor Data Slides_VirenderStreaming Sensor Data Slides_Virender
Streaming Sensor Data Slides_Virender
 
Jfokus - Reacting to an event-driven world
Jfokus - Reacting to an event-driven worldJfokus - Reacting to an event-driven world
Jfokus - Reacting to an event-driven world
 
Developing for Hybrid Cloud with Bluemix
Developing for Hybrid Cloud with BluemixDeveloping for Hybrid Cloud with Bluemix
Developing for Hybrid Cloud with Bluemix
 
JSpring Virtual 2020 - Reacting to an event-driven world
JSpring Virtual 2020 - Reacting to an event-driven worldJSpring Virtual 2020 - Reacting to an event-driven world
JSpring Virtual 2020 - Reacting to an event-driven world
 
IBM Cloud Integration Platform Introduction - Integration Tech Conference
IBM Cloud Integration Platform Introduction - Integration Tech ConferenceIBM Cloud Integration Platform Introduction - Integration Tech Conference
IBM Cloud Integration Platform Introduction - Integration Tech Conference
 
Introduction to Serverless Computing - OOP Munich
 Introduction to Serverless Computing - OOP Munich Introduction to Serverless Computing - OOP Munich
Introduction to Serverless Computing - OOP Munich
 
Modern Applications Development on AWS
Modern Applications Development on AWSModern Applications Development on AWS
Modern Applications Development on AWS
 
App Modernization
App ModernizationApp Modernization
App Modernization
 
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
 
Open Standards Enabling Digital Transformation
Open Standards Enabling Digital TransformationOpen Standards Enabling Digital Transformation
Open Standards Enabling Digital Transformation
 
CI/CD for Modern Applications
CI/CD for Modern ApplicationsCI/CD for Modern Applications
CI/CD for Modern Applications
 
Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...
Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...
Mythical Mysfits - Build & collaborate on a modern web application on AWS - M...
 
Sharing and Deploying Data Science with KNIME Server
Sharing and Deploying Data Science with KNIME ServerSharing and Deploying Data Science with KNIME Server
Sharing and Deploying Data Science with KNIME Server
 
IBM Relay 2015: Opening Keynote
IBM Relay 2015: Opening Keynote IBM Relay 2015: Opening Keynote
IBM Relay 2015: Opening Keynote
 

Recently uploaded

Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Gáspár Nagy
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfsteffenkarlsson2
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationHelp Desk Migration
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfmbmh111980
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionMohammed Fazuluddin
 

Recently uploaded (20)

Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and Prevention
 

Event driven microservices

  • 1. Event-driven microservices using Apache Kafka Andrew Schofield Chief Architect, Event Streams IBM Hursley Park © 2019 IBM Corporation
  • 2. What and why microservices? Microservices is a technique for structuring an application as a collection of services: • Self-contained with clear interfaces and a distinct purpose • Loosely coupled – communicate over a network • Independently deployable, scalable, maintainable and testable © 2019 IBM Corporation Microservices ApplicationMonolithic Application
  • 3. Being event-driven is different © 2019 IBM Corporation Source: Gartner - From data-centric to event-centric IT priority
  • 4. Why event-driven? • Proper loose coupling means asynchronous communication • Enables responsive applications • In the real world, things often take time to complete © 2019 IBM Corporation
  • 5. Event-driven microservices • Microservices communicate primarily using events, with APIs where required • Microservices can produce and consume events using the publish/subscribe pattern • Events are handled by an event backbone • Data is eventually consistent © 2019 IBM Corporation Microservice Microservice Microservice Microservice Microservice Event backbone Publish Service discoveryMicroservice Microservice Microservice Subscribe Subscribe API API Publish JSON / HTTP JSON / HTTP Microservices application
  • 6. Apache Kafka is an Open-Source Streaming Platform © 2019 IBM Corporation PUBLISH & SUBSCRIBE Read and write streams of events, like a traditional messaging system. PROCESS Support scalable stream processing applications that react to events in real-time. STORE Store streams of data safely in a distributed, replicated, fault-tolerant cluster. https://kafka.apache.org/ Kafka Cluster Producer ProducerProducer Consumer ConsumerConsumer Stream Processor Stream Processor Source Connector Sink Connector
  • 7. Event-driven terminology Event A message usually representing a fact at a particular time Event stream A continuous, ordered, unbounded sequence of events Stream processing Computation optimized for continuous processing, often with state Stream history The historical sequence of the events on an event stream © 2019 IBM Corporation
  • 8. Apache Kafka as the event backbone © 2019 IBM Corporation
  • 9. Apache Kafka as the event backbone © 2019 IBM Corporation Microservice Microservice
  • 10. Apache Kafka as the event backbone © 2019 IBM Corporation 1 Building Blocks 1 :: Event sources Microservice Microservice
  • 11. Apache Kafka as the event backbone © 2019 IBM Corporation 1 2 Building Blocks 1 :: Event sources 2 :: Stream processing Microservice Microservice
  • 12. Apache Kafka as the event backbone © 2019 IBM Corporation 1 2 App 3 Building Blocks 1 :: Event sources 2 :: Stream processing 3 :: Event archive Microservice Microservice
  • 13. Apache Kafka as the event backbone © 2019 IBM Corporation App 1 2 3 4 Building Blocks 1 :: Event sources 2 :: Stream processing 3 :: Event archive 4 :: Notifications Microservice Microservice
  • 14. How to get started • You could run an event storming workshop https://www.ibm.com/cloud/garage/architectures/eventDrivenArchitecture/event-storming-methodology • Identify: • Events • Actors • Data • Commands © 2019 IBM Corporation
  • 15. A simple stream processing example © 2019 IBM Corporation Event backbone Transactions
  • 16. A simple stream processing example © 2019 IBM Corporation Event backbone Transactions Alerts
  • 17. A simple stream processing example © 2019 IBM Corporation Event backbone Transactions Alerts SMS alerts Email alerts Push alerts
  • 18. A simple stream processing example © 2019 IBM Corporation Event backbone Send SMS Transactions Alerts Send emails Send push notifications SMS alerts Email alerts Push alerts
  • 19. © 2019 IBM Corporation A more complex event-driven example https://ibm-cloud-architecture.github.io/refarch-kc/design/readme/
  • 20. A more complex example – component view © 2019 IBM Corporation Fleet microservice Containers microservice Voyages microservice Orders microservice APIAPI
  • 21. A more complex example – component view © 2019 IBM Corporation Fleet microservice Containers microservice Voyages microservice Orders microservice APIAPI
  • 22. A more complex example – component view © 2019 IBM Corporation Event backbone ships containers orders voyages Fleet microservice Containers microservice Voyages microservice Orders microservice APIAPI
  • 23. A more complex example – component view © 2019 IBM Corporation Event backbone ships containers problems orders voyages Fleet microservice Containers microservice Voyages microservice Orders microservice Streaming analytics APIAPI
  • 24. Patterns for event-driven microservices • You want: • Loose coupling • Data consistency • Efficient queries © 2019 IBM Corporation
  • 25. Patterns for event-driven microservices • You want: • Loose coupling • Data consistency • Efficient queries • You don’t want: • Chaos © 2019 IBM Corporation
  • 26. Patterns for event-driven microservices • You want: • Loose coupling • Data consistency • Efficient queries • You don’t want: • Chaos • You need PATTERNS © 2019 IBM Corporation
  • 27. Pattern – Database per service • Each microservice persists its own data + Protects independence of the microservice against external change - Introduces complexity for data consistency across microservices Event backbone ships containers problems orders voyages Fleet microservice Containers microservice Voyages microservice Orders microservice © 2019 IBM Corporation
  • 28. Kafka log compaction for data replication © 2019 IBM Corporation 0 key:a val:A1 1 key:b val:B1 2 key:a val:A2 3 key:c val:C1 Partition 0 4 key:c val:C2 5 key:b val: Producer writes Consumer takes latest values and builds own data store reads Key Value a A2 b <deleted> c C2 Old New Source change log Read
  • 29. Kafka log compaction for data replication © 2019 IBM Corporation 0 key:a val:A1 1 key:b val:B1 2 key:a val:A2 3 key:c val:C1 Partition 0 4 key:c val:C2 5 key:b val: 2 key:a val:A2 4 key:c val:C2 5 key:b val: Periodic compaction eliminates duplicate keys to minimize storage Partition 0 (rewritten) Key Value a A2 b <deleted> c C2
  • 30. Pattern – Event sourcing • Every state change is captured as an event stored in sequence + Publishing events is atomic - Event store is hard to query efficiently © 2019 IBM Corporation OrderCreated OrderUpdated OrderUpdated OrderConfirmed OrderShipped OrderDelivered OrderInTransit Orders microservice Orders DB Command handler USER Time OrderPending OrderBooked OrderAssigned
  • 31. Pattern – Sagas • Orchestration of multi-step operations across microservices + Data consistency across microservices without distributed transactions - Programming can be complex, particularly for failure compensation © 2019 IBM Corporation Event backbone Fleet microservice Containers microservice Voyages microservice Orders microservice 1 2 3 4 5
  • 32. Pattern – CQRS • Command Query Responsibility Segregation + Atomic writes and efficient reads at the same time - Complex to program correctly © 2019 IBM Corporation Event backbone 1 2 3 4 5 Fleet MS WRITE MODEL Fleet MS READ MODEL Write-optimized store Read-optimized store Write API Read API
  • 33. Summary • Event-driven microservices offer an effective way to build loosely- coupled applications • Techniques such as event storming can be used to derive the objects, commands and events in an application • Patterns such as event sourcing and sagas make the complexity manageable © 2019 IBM Corporation