SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Evolutionary Systems
Kafka Microservices
Stefano Rocco
Milan, 4 July 2018
Evolution of the Operational Domain
Monolith SOA Microservices
Microservice Based System
A Microservice based system is a Network whereas
nodes collaborate together via links in order to
achieve an overall consistent state of the system.
Nodes are responsible for carrying out logic and
holding some data, links are responsible for
transporting data between nodes.
Different Microservices (Nodes) act in concert as one
larger system. They communicate with each other,
typically asynchronously, through well defined
Contracts, whether via HTTP REST calls, RPC or
Message Broker passing.
Microservice Based System
- Each microservice carries out some business logic in
order to solve a unique business capability.
- Each microservice own and control its own
database and no services should share a database.
Avoid conflicts like competing read/write patterns,
data-model conflicts. Guarantee evolutionary
independence.
- Adapters are responsible for inbound
communication, “integrating” the outside world with
the service.
- Ports are responsible for outbound communication,
connecting the service with the outside world, while
Process/Logic
Data
Adapter
Port
A Classic Example: E-Commerce Checkout
Checkout
Service
Order
Service
Payment
Service
Checkout Service: Sends to the Order Service events
about a new shopping cart checkout.
Order Service: Create a new Customer Order and calls the
Payment Service for payment processing and
authorization.
Payment Service: Process Customer Payments by either
authorizing or rejecting them.
E-Commerce Checkout: Event Collaboration
Checkout Checkout Checkout
Order OrderPayment
Checkout
Created
Checkout
Created
Order
Created
Order
Created
Order
Created
Payment
Received
Payment
Received
Order
Acknowledged
Order
Acknowledged
Order
Created
Payment
Received
Order
Acknowledged
Checkout
Acknowledged
Checkout
Processed
Checkout
Created
Kafka
Kafka Ecosystem
Kafka
APIs
Kafka
Streams
Schema
Registry
Kafka REST
Proxy
Kafka
Connect
Kafka Message Broker
Kafka High Level Architecture
Producer 1
Producer 2
Producer N
Consumer 1
Consumer 2
Consumer N
Broker 1
Broker 2
Broker N
Zookeeper
Consumer
Group
Kafka
Cluster
Produce Consume
Commit
OffsetWritten
Offset
Kafka High Level Architecture
Consumer 1
Consumer 2
Consumer N
Producer 1 Producer 2 Producer 3
Topic
Partition 1 Partition 2 Partition 3
Consumer 1 Consumer 2 Consumer 3 Consumer N
- Different Producers can write to any topic.
- A Topic is a distributed log of events.
- Events are stored and distributed consistently, according an
hashing algorithm, into one of the Topic Partitions.
- Partitions defines the Topic’s level of parallelism for
consumers reading operations.
- Consumers are organized in Consumer Groups.
- Each Consumer within a Consumer Group is exclusively
assigned to a specific Topic Partition
- Different Consumer Groups, identified by a unique clientId,
can read from the same topic at the same time.
- Only one Consumer per Consumer Group can read from the
assigned Topic Partition
- Consumers are responsible for checkpointing their position by
committing the reading offset.**
How Kafka Replication Works
Partition 2
Partition 3
Partition 4
Partition 2 Partition 2
Partition 3
Partition 4 Partition 4
Partition 3
Partition 1 Partition 1 Partition 1
In-Sync Replica
In-Sync Replica
Available
for
consumers
One event topic per Bounded Context
CheckoutCreated
CheckoutProcessed
OrderCreated
OrderAcknowledgedCheckoutAcknowledged
PaymentReceived
checkout_events order_events payment_events
Checkout
Service
Order
Service
Payment
Service
CheckoutConfirmed
OrderConfirmed
PaymentConfirmed
Wrap events/messages around an Envelope
{
"envelope" : {
"id" : "...",
"Ip_address" : "...",
"timestamp" : "...",
"event" : {
"eventType" : "CheckoutCreated",
"id" : "...",
...
}
}
}
ChekoutRejected
CheckoutAcknowledged
CheckoutProcessed
CheckoutConfirmed
Choose a safe and evolutionary protocol
- Support backward, forward and full compatibility
- Test against a schema. Schema Registry?
- Leverage type safety. Avro, Protobuf, Thrift..
- If you want to be safe with Json you have to embrace an
additive change only policy… most of the times.
- Json does not support schema definition
- Json is not purely type safe
- If you go Json soon enough you’ll break your protocol.
- Version your protocol! Version your Microservices!
Get inspired by Event Sourcing
Event State
T1
T2
T3
OrderCreated
OrderAcknwledged
OrderConfirmed
Status
(Created)
Status (Acknowledged)
Status
(Confirmed)
Kafka Processor Architecture
Checkout
events
Checkout
Created
Order
Processor Order
Store
Commit Offset
Put
Put OK
Pull Receive
TOPIC EVENT
PROCESSOR
STATE STORE
SEMANTIC DELIVERY
ANTI CORRUPTION
Kafka Processor APi
import com.google.gson.JsonObject;
import org.apache.kafka.streams.processor.AbstractProcessor;
import org.apache.kafka.streams.state.KeyValueStore;
public class MyProcessor extends AbstractProcessor<String, JsonObject> {
@Override
public void process(final String key, final JsonObject value) {
//Implement your business logic here
// Eventually use the State Store
final KeyValueStore<String, JsonObject> store = (KeyValueStore<String, JsonObject>) context().getStateStore("store_name");
//store.put(?, ?);
//store.get(?, ?);
//Eventually forward to the downstream processor
context().forward(key, value);
// Commit
context().commit();
}
}
Kafka Processor Workflow Definition (PDSL)
// consumer from checkout_events topic
from(“order_source”, “checkout_events”)
// Process using OrderProcessor
.via(“order_processor”, OrderProcessor, “order_source”)
// Attach OrderStore state store
.with(OrderStore, “order_processor”)
// Sink to order_events topic
.to(“order_sink”, “order_events”, “order_processor”)
Kafka Processor Workflow Definition
Order
Processor
Checkout
Events
Payment
Events
Order
Events
Order
State
FROM VIA TO
WITH
Semantic Delivery Reliability
- At Most Once: The middleware decides for you. Not
what we want!
- Exactly Once: The middleware decides for you. Not
what we want!
- At Least Once: You controntol the middleware!
However it’s not smart enough...
- Effectively Once = Idempotent At Least Once!
Anti Corruption: Event Command Transformation
Checkout
Created
Create
Order
Order
Created
Status
(Created)
Payment
Processed
Acknowledge
Order
Order
Acknowledged
Payment
Confirmed
Status
(Acknowledged)
Confirm
Order
Order
Confirmed
Order
(Confirmed)
T1
T2
T3
Event Command Event State
ADAPTER
Event Command Transformation
Checkout
events
Evolutionary
events
Garbage
events
Payment
Adapter
Payment
Commands
Payment
Processor
Payment
Events
Payment
Store
What about the read side and Projections?
Events
State Store
Projector
Service
Your Fancy
Store
Processor
Punctuate
Web
Service
INTERACTIVE QUERIES
The Blueprint Architecture
Thanks
Source Code at
https://gitlab.com/simplematterpublic/blueprint-microservices

Weitere ähnliche Inhalte

Was ist angesagt?

Messaging queue - Kafka
Messaging queue - KafkaMessaging queue - Kafka
Messaging queue - KafkaMayank Bansal
 
Reducing Microservice Complexity with Kafka and Reactive Streams
Reducing Microservice Complexity with Kafka and Reactive StreamsReducing Microservice Complexity with Kafka and Reactive Streams
Reducing Microservice Complexity with Kafka and Reactive Streamsjimriecken
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And DesignYaroslav Tkachenko
 
Building scalable flexible messaging systems using qpid
Building scalable flexible messaging systems using qpidBuilding scalable flexible messaging systems using qpid
Building scalable flexible messaging systems using qpidJack Gibson
 
Introduction to the Nancy Framework
Introduction to the Nancy FrameworkIntroduction to the Nancy Framework
Introduction to the Nancy FrameworkTim Bourguignon
 
Implementing Microservices with NATS
Implementing Microservices with NATSImplementing Microservices with NATS
Implementing Microservices with NATSApcera
 
Luniverse Partners Day - Jay
Luniverse Partners Day - JayLuniverse Partners Day - Jay
Luniverse Partners Day - JayLuniverse Dunamu
 
The Rise of Microservices - Containers and Orchestration
The Rise of Microservices - Containers and OrchestrationThe Rise of Microservices - Containers and Orchestration
The Rise of Microservices - Containers and OrchestrationMongoDB
 
Encode Club workshop slides
Encode Club workshop slidesEncode Club workshop slides
Encode Club workshop slidesVanessa Lošić
 
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...HostedbyConfluent
 
Event-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS StreamingEvent-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS StreamingShiju Varghese
 
Messaging Connectivity in Hybrid Kubernetes Cloud Environments
Messaging Connectivity in Hybrid Kubernetes Cloud EnvironmentsMessaging Connectivity in Hybrid Kubernetes Cloud Environments
Messaging Connectivity in Hybrid Kubernetes Cloud EnvironmentsDevOps.com
 
MongoDB Evenings Toronto - Monolithic to Microservices with MongoDB
MongoDB Evenings Toronto - Monolithic to Microservices with MongoDBMongoDB Evenings Toronto - Monolithic to Microservices with MongoDB
MongoDB Evenings Toronto - Monolithic to Microservices with MongoDBMongoDB
 
Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...
Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...
Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...HostedbyConfluent
 
Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...
Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...
Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...HostedbyConfluent
 

Was ist angesagt? (16)

Messaging queue - Kafka
Messaging queue - KafkaMessaging queue - Kafka
Messaging queue - Kafka
 
Reducing Microservice Complexity with Kafka and Reactive Streams
Reducing Microservice Complexity with Kafka and Reactive StreamsReducing Microservice Complexity with Kafka and Reactive Streams
Reducing Microservice Complexity with Kafka and Reactive Streams
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
 
Building scalable flexible messaging systems using qpid
Building scalable flexible messaging systems using qpidBuilding scalable flexible messaging systems using qpid
Building scalable flexible messaging systems using qpid
 
Introduction to the Nancy Framework
Introduction to the Nancy FrameworkIntroduction to the Nancy Framework
Introduction to the Nancy Framework
 
Implementing Microservices with NATS
Implementing Microservices with NATSImplementing Microservices with NATS
Implementing Microservices with NATS
 
Luniverse Partners Day - Jay
Luniverse Partners Day - JayLuniverse Partners Day - Jay
Luniverse Partners Day - Jay
 
The Rise of Microservices - Containers and Orchestration
The Rise of Microservices - Containers and OrchestrationThe Rise of Microservices - Containers and Orchestration
The Rise of Microservices - Containers and Orchestration
 
Encode Club workshop slides
Encode Club workshop slidesEncode Club workshop slides
Encode Club workshop slides
 
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
 
Event-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS StreamingEvent-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS Streaming
 
Messaging Connectivity in Hybrid Kubernetes Cloud Environments
Messaging Connectivity in Hybrid Kubernetes Cloud EnvironmentsMessaging Connectivity in Hybrid Kubernetes Cloud Environments
Messaging Connectivity in Hybrid Kubernetes Cloud Environments
 
MongoDB Evenings Toronto - Monolithic to Microservices with MongoDB
MongoDB Evenings Toronto - Monolithic to Microservices with MongoDBMongoDB Evenings Toronto - Monolithic to Microservices with MongoDB
MongoDB Evenings Toronto - Monolithic to Microservices with MongoDB
 
Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...
Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...
Introducing KSML: Kafka Streams for low code environments | Jeroen van Dissel...
 
Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...
Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...
Sharing is Caring: Toward Creating Self-tuning Multi-tenant Kafka (Anna Povzn...
 
Introduction of Luniverse
Introduction of LuniverseIntroduction of Luniverse
Introduction of Luniverse
 

Ähnlich wie Evolutionary Systems - Kafka Microservices

Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Vinay Kumar
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Vinay Kumar
 
Kafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.pptKafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.pptInam Bukhary
 
Cluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQCluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQShameera Rathnayaka
 
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...GeeksLab Odessa
 
Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Guido Schmutz
 
Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Anton Nazaruk
 
Developing Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache KafkaDeveloping Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache KafkaJoe Stein
 
Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016Peter Lawrey
 
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningApache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningGuido Schmutz
 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with KafkaAndrei Rugina
 
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...VMware Tanzu
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka IntroductionAmita Mirajkar
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPCMax Alexejev
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Tammy Bednar
 

Ähnlich wie Evolutionary Systems - Kafka Microservices (20)

Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20
 
Kafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.pptKafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.ppt
 
Cluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQCluster_Performance_Apache_Kafak_vs_RabbitMQ
Cluster_Performance_Apache_Kafak_vs_RabbitMQ
 
Kafka internals
Kafka internalsKafka internals
Kafka internals
 
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
 
Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !
 
Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Developing Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache KafkaDeveloping Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache Kafka
 
Clustersoftware
ClustersoftwareClustersoftware
Clustersoftware
 
Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016Microservices for performance - GOTO Chicago 2016
Microservices for performance - GOTO Chicago 2016
 
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningApache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with Kafka
 
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Kafka RealTime Streaming
Kafka RealTime StreamingKafka RealTime Streaming
Kafka RealTime Streaming
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
 

Kürzlich hochgeladen

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Kürzlich hochgeladen (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Evolutionary Systems - Kafka Microservices

  • 2. Evolution of the Operational Domain Monolith SOA Microservices
  • 3. Microservice Based System A Microservice based system is a Network whereas nodes collaborate together via links in order to achieve an overall consistent state of the system. Nodes are responsible for carrying out logic and holding some data, links are responsible for transporting data between nodes. Different Microservices (Nodes) act in concert as one larger system. They communicate with each other, typically asynchronously, through well defined Contracts, whether via HTTP REST calls, RPC or Message Broker passing.
  • 4. Microservice Based System - Each microservice carries out some business logic in order to solve a unique business capability. - Each microservice own and control its own database and no services should share a database. Avoid conflicts like competing read/write patterns, data-model conflicts. Guarantee evolutionary independence. - Adapters are responsible for inbound communication, “integrating” the outside world with the service. - Ports are responsible for outbound communication, connecting the service with the outside world, while Process/Logic Data Adapter Port
  • 5. A Classic Example: E-Commerce Checkout Checkout Service Order Service Payment Service Checkout Service: Sends to the Order Service events about a new shopping cart checkout. Order Service: Create a new Customer Order and calls the Payment Service for payment processing and authorization. Payment Service: Process Customer Payments by either authorizing or rejecting them.
  • 6. E-Commerce Checkout: Event Collaboration Checkout Checkout Checkout Order OrderPayment Checkout Created Checkout Created Order Created Order Created Order Created Payment Received Payment Received Order Acknowledged Order Acknowledged Order Created Payment Received Order Acknowledged Checkout Acknowledged Checkout Processed Checkout Created Kafka
  • 8. Kafka High Level Architecture Producer 1 Producer 2 Producer N Consumer 1 Consumer 2 Consumer N Broker 1 Broker 2 Broker N Zookeeper Consumer Group Kafka Cluster Produce Consume Commit OffsetWritten Offset
  • 9. Kafka High Level Architecture Consumer 1 Consumer 2 Consumer N Producer 1 Producer 2 Producer 3 Topic Partition 1 Partition 2 Partition 3 Consumer 1 Consumer 2 Consumer 3 Consumer N - Different Producers can write to any topic. - A Topic is a distributed log of events. - Events are stored and distributed consistently, according an hashing algorithm, into one of the Topic Partitions. - Partitions defines the Topic’s level of parallelism for consumers reading operations. - Consumers are organized in Consumer Groups. - Each Consumer within a Consumer Group is exclusively assigned to a specific Topic Partition - Different Consumer Groups, identified by a unique clientId, can read from the same topic at the same time. - Only one Consumer per Consumer Group can read from the assigned Topic Partition - Consumers are responsible for checkpointing their position by committing the reading offset.**
  • 10. How Kafka Replication Works Partition 2 Partition 3 Partition 4 Partition 2 Partition 2 Partition 3 Partition 4 Partition 4 Partition 3 Partition 1 Partition 1 Partition 1 In-Sync Replica In-Sync Replica Available for consumers
  • 11. One event topic per Bounded Context CheckoutCreated CheckoutProcessed OrderCreated OrderAcknowledgedCheckoutAcknowledged PaymentReceived checkout_events order_events payment_events Checkout Service Order Service Payment Service CheckoutConfirmed OrderConfirmed PaymentConfirmed
  • 12. Wrap events/messages around an Envelope { "envelope" : { "id" : "...", "Ip_address" : "...", "timestamp" : "...", "event" : { "eventType" : "CheckoutCreated", "id" : "...", ... } } } ChekoutRejected CheckoutAcknowledged CheckoutProcessed CheckoutConfirmed
  • 13. Choose a safe and evolutionary protocol - Support backward, forward and full compatibility - Test against a schema. Schema Registry? - Leverage type safety. Avro, Protobuf, Thrift.. - If you want to be safe with Json you have to embrace an additive change only policy… most of the times. - Json does not support schema definition - Json is not purely type safe - If you go Json soon enough you’ll break your protocol. - Version your protocol! Version your Microservices!
  • 14. Get inspired by Event Sourcing Event State T1 T2 T3 OrderCreated OrderAcknwledged OrderConfirmed Status (Created) Status (Acknowledged) Status (Confirmed)
  • 15. Kafka Processor Architecture Checkout events Checkout Created Order Processor Order Store Commit Offset Put Put OK Pull Receive TOPIC EVENT PROCESSOR STATE STORE SEMANTIC DELIVERY ANTI CORRUPTION
  • 16. Kafka Processor APi import com.google.gson.JsonObject; import org.apache.kafka.streams.processor.AbstractProcessor; import org.apache.kafka.streams.state.KeyValueStore; public class MyProcessor extends AbstractProcessor<String, JsonObject> { @Override public void process(final String key, final JsonObject value) { //Implement your business logic here // Eventually use the State Store final KeyValueStore<String, JsonObject> store = (KeyValueStore<String, JsonObject>) context().getStateStore("store_name"); //store.put(?, ?); //store.get(?, ?); //Eventually forward to the downstream processor context().forward(key, value); // Commit context().commit(); } }
  • 17. Kafka Processor Workflow Definition (PDSL) // consumer from checkout_events topic from(“order_source”, “checkout_events”) // Process using OrderProcessor .via(“order_processor”, OrderProcessor, “order_source”) // Attach OrderStore state store .with(OrderStore, “order_processor”) // Sink to order_events topic .to(“order_sink”, “order_events”, “order_processor”)
  • 18. Kafka Processor Workflow Definition Order Processor Checkout Events Payment Events Order Events Order State FROM VIA TO WITH
  • 19. Semantic Delivery Reliability - At Most Once: The middleware decides for you. Not what we want! - Exactly Once: The middleware decides for you. Not what we want! - At Least Once: You controntol the middleware! However it’s not smart enough... - Effectively Once = Idempotent At Least Once!
  • 20. Anti Corruption: Event Command Transformation Checkout Created Create Order Order Created Status (Created) Payment Processed Acknowledge Order Order Acknowledged Payment Confirmed Status (Acknowledged) Confirm Order Order Confirmed Order (Confirmed) T1 T2 T3 Event Command Event State ADAPTER
  • 22. What about the read side and Projections? Events State Store Projector Service Your Fancy Store Processor Punctuate Web Service INTERACTIVE QUERIES