SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
RabbitMQ
vs
Apache Kafka
Comparing two giants of the messaging space
Part 1 – Core Concepts and Topologies
Background
• Jack Vanlightly
• Software Architect of SII Concatel, Barcelona
• Event-Driven Architectures
• Messaging Systems
• Data Integrations
• https://jack-vanlightly.com
The Log
(Apache Kafka)
The Queue
(RabbitMQ)
VS
The Log
(Apache Kafka)
The Queue
(RabbitMQ)
The Queue
• First In First Out data structure
• Optimized for efficient write and read operations from either end of
the sequence
• Stored data is transient in nature
• Not shared between applications
7 6 5 4 3 2 1Write Read
VS The Log
• Also known as Write-Ahead Logs, Transaction Logs and Commit
Logs.
• Append-only. Ordered By Time.
• Unique log sequence numbers.
• Stored data is persistent in nature
• Shared between applications
1 2 3 4 5 6 7
Reader
Reader
RabbitMQ
The Building Blocks
Routing
Fanout Exchange
Direct Exchange
Topic Exchange
Header Exchange
Consistent Hashing Exchange
Random Exchange
Sharding
Queues and Consumers
Queues
Competing Consumers
Non-Competing Consumers
Ephemeral Queues
Lazy Queues
Priority Queues
More
Deadletter Exchange
Alternate Exchange
Virtual Hosts
Exchanges, Queues and Bindings
• Publishers send messages to Exchanges
• Exchanges route messages to Queues and even other
Exchanges.
• Consumers read from Queues
• Bindings link Exchanges to Queues and even Exchanges to
Exchanges
Publisher Exchange Queue Consumer
binding
RabbitMQ
Building Blocks
Traditional queues on
steroids
Publish – Subscribe
Publisher
Fanout
Exchange
Queue B Consumer
Fanout
Simplest Publish-Subscribe pattern.
Each consumer receives every message
Queue A
Queue C Consumer
Consumer
Publish – Subscribe with Routing
Direct Exchange
Routing by Routing Key
Exact match routing key = binding key
Publisher
Direct
Exchange
Queue B Consumer
Queue A
Queue C Consumer
Consumer
created
modified
cancelled
Routing Key
Binding Key: created
Binding Key: modified
Binding Key: cancelled
Publish – Subscribe with Routing
Topic Exchange
Wildcard routing by Routing Key
* = match 1 word
# = match multiple words
booking.baggage.added
booking.baggage.removed
booking.passenger.added
booking.passenger.removed
payment.received
Publisher
Topic
Exchange
Queue B Consumer
Queue A
Queue C Consumer
Consumer
Routing Key
booking.#
*.passenger.*
payment.received
Publish – Subscribe with Routing
Header Exchange
Routing by message headers
Publisher
Header
Exchange
Queue B Consumer
Queue A
Queue C Consumer
Consumer
VIP=true, Country=UK, All
VIP=False
VIP: true
Country: UK
VIP=true, Country=UK, Any
Point-to-Point Messaging
Default Exchange
Direct exchange type
All queues have implicit binding to the default exchange.
Routes messages by Routing Key to Queue Name
Publisher
Default
Exchange
Orders Consumer
Notifications
Shipping Consumer
Consumer
Routing Key
Protecting Against Routing Failures
Alternate Exchange
Not an exchange type but a configured relationship
between two exchanges.
Route unrouteable messages to an alternate exchange
Publisher
Topic
Exchange
Queue Consumer
Queue
Unrouteable
messages
Consumer
Consumer
created
modified
Fanout
Exchangeunrouteable
Scaling Out Consumers
Fanout
Exchange
Shipping Shipping
Non-Competing Consumers
Each consumer receives every message
Scale Out with Competing Consumers
Each Shipping consumer receives a subset of the messages.
Notifications
Billing Billing
Notifier
Sales
Publisher
Fanout
Exchange
Shipping Shipping
Shipping
Shipping
Notifications Notifier
Billing Billing
Sales
Publisher
Scaling Out Queues
Random Exchange
Load balance messages across queues randomly
Publisher
Random
Exchange
Shipping.2 Consumer
Shipping.1
Shipping.3 Consumer
Consumer
Scaling Out Queues With Data Locality
Consistent Hashing Exchange
Partition messages across queues via hashing function over routing key, message header or message property
Publisher
Hashing
Exchange
Shipping.2 Consumer
Shipping.1
Shipping.3 Consumer
Consumer
Routing Key
1/3 hash space
1/3 hash space
1/3 hash space
Scaling Out Queues With Data Locality
Sharding Plugin and Modulus Exchange
Partition messages across queues over multiple hosts via hashing function on the routing key.
Publisher
Modulus
Exchange
Host 1 Shard 2 Consumer
Host 1 Shard 1
Host 1 Shard 3 Consumer
Consumer
Routing Key
Publisher
Modulus
Exchange
Host 2 Shard 2 Consumer
Host 2 Shard 1
Host 2 Shard 3 Consumer
Consumer
Routing Key
Apply limits to queues
• Length
• Size
• Time limits (TTL)
Eject messages from a queue when:
• A queue size/length limit reached.
• A message has spent longer than the TTL time limit in the
queue
Route to a deadletter exchange to avoid message loss.
Queue Limits
and
Deadletter
Exchanges
7 6 5 4 3 2 1
X
Queue
Exchange
Consumer
Queue
Ephemeral
• Auto-Delete Queue
• Queue Expiration (TTL)
• Exclusive Queues
• Auto-Delete Exchanges
Lazy Queues
• Memory optimized queues.
Priority Queues
• No longer FIFO.
• Publisher sets priority on messages
• Priority Queue moves higher priority messages ahead of lower
• Drawbacks – blocked low priority messages, low priority can
eject high priority when queue is full
Ephemeral Exchanges
and Queues
Lazy Queues
Priority
Queues
• Allows Multi-Tenant architecture
• Isolation of groups of exchanges, queues and users
• No routing between two virtual hosts
Virtual Hosts
Apache Kafka
The Building Blocks
Topics
Partitions
Consumer Groups
• Distributed because Kafka is deployed as a cluster of nodes, for
both fault tolerance and scale
• Partitioned because each topic can be sharded into multiple
partitions, with each partition storing a disjoint set of the data.
• Replicated because partitions are usually replicated across
multiple nodes (servers).
• Commit Log because messages are stored in an append only
fashion.
Apache Kafka
Core Concepts
The Rise of the
Distributed,
Partitioned,
Replicated,
Commit Log
• Kafka has a simple Publish Subscribe model
• Topics
• Each Topic has one or more partitions
• Each partition has a replication factor of one or more
Topics,
Partitions
and
Consumer
Groups
Producer ConsumerTopic
Producer ConsumerPartition 2
Partition 1
Partition 3
Consumer Group
Topics,
Partitions
and
Consumer
Groups
Producer
P
1
P
2
P
3
C1 C2 C3
A single consumer group of three consumers reads from a
topic of three partitions.
The unit of parallelism of a topic is the partition.
Topics,
Partitions
and
Consumer
Groups
Consumer Group
Producer
P
1
P
2
P
3
C1 C2 C3 C4
A single consumer group of four consumers reads from a
topic of three partitions. One consumer sits idle.
Consumer Group
Topics,
Partitions
and
Consumer
Groups
Producer
P
1
P
2
P
5
C1 C2 C3
P
3
P
4
A single consumer group of three consumers reads from a
topic of five partitions. Two consumers read from two
partitions.
Consumer Group
Topics,
Partitions
and
Consumer
Groups
Producer
P
1
P
2
P
3
C1 C2 C3
Consumer Group
C4 C5 C6
Two consumer groups of three consumers read from a
topic of three partitions
• Producers append messages to the end of partitions.
• The partition is chosen by the producer (round robin or partition
key).
• Messages are removed according to the data retention policy.
• Consumers keep track their position in the partitions they
consume from – called the consumer offset
Topics,
Partitions
and
Consumer
Groups
1 2 3 4 5 6 7
Producer
Consumer 1
Write
Read at offsetData retention policyX
Topics,
Partitions
and
Consumer
Groups
1 2 3 4 5 6 7
Producer
Consumer 1
CG ARead at offset
Consumer 4
CG BRead at offset
Partition 1
1 2 3 4 5 6 7
Consumer 2
CG ARead at offset
Consumer 5
CG B
Read
at offset
Partition 28
1 2 3 4 5 6
Consumer 3
CG ARead at offset
Consumer 6
CG BRead at offset
Partition 3
Topics,
Partitions
and
Consumer
Groups
Consumer Group
Producer
P
1
P
2
P
3
C1 C2 C3
Batch
Batch Batch Batch
Log Compaction
• Clean up old versions of a record (by record key). Keep latest
version only.
• Periodic process
• Kafka as an event store
Apache Kafka
Log Compaction
A X G U D W J X E A E O P X
A X
G U
D
W J
X E
A E O D X
G U W J A E O D X
Avro Schema Registry
• Send messages in a compact binary format – Avro
• Schema Registry service automates sharing of Avro schemas
between producers and consumers
• Schema Registry to safely control evolution of schemas
Apache Kafka
Schema Registry
Producer ConsumerTopic
Schema
Registry
Send
schema
Get
schema
Data Replication / Event Sourcing
• Kafka as a single source of truth
• Sits at the center of your architecture
• Kafka Connect
Apache Kafka
Data Replication
Event Sourcing
Kafka Topics
Apache Kafka
Example Topologies
RabbitMQ
Example Topologies
VS
Example Scenario
eCommerce
Site
Sales and
Inventory
Billing
Shipping
PlaceOrder OrderPlaced
OrderBilledOrderPlaced
eCommerce
Site
Sales and
Inventory
Billing
Shipping
ModifyOrder OrderModified
ModificationBilledOrderModified
eCommerce
Site
Sales and
Inventory
Billing
Shipping
CancelOrder OrderCancelled
OrderCancelled
Example Scenario – RabbitMQ Fanout Exchanges
eCommerce
Site
PlaceOrder
SalesSales
OrderPlaced
BillingBilling
Shipping Shipping
OrderRefunded
Fanout Exchange per Event, Single Queue per Application
ModifyOrder
CancelOrder
OrderModified
OrderCancelled
OrderBilled
Modification
Billed
Example Scenario – RabbitMQ Fanout Exchanges
eCommerce
Site
PlaceOrder
Sales
Scaling our Single Queue, Maintaining Relative Ordering
ModifyOrder
CancelOrder
Sales.1
Sales Hashing
Exchange
Sales.2
Sales.3
Sales.4
Sales.5
Sales
Sales
Sales
Sales
Example Scenario – RabbitMQ Topic Exchanges
eCommerce
Site
amq.topic
SalesSales
ShippingShipping
place.order
modify.order
cancel.order
place.order
modify.order
cancel.order
Billing Billing
order.placed
order.modified
order.cancelled
order.billed
modification.billed
order.placed
order.modified
order.cancelled
order.billed
order.modification.billed
order.refunded
Single Topic Exchange (amq.topic)
order.placed
order.modified
order.cancelled
Example Scenario – Kafka Topics
eCommerce
Site
SalesOrder Requests Topic
Orders Topic
Related Events in One Topic
Billing
Shipping
OrderPlaced Event
OrderModified Event
OrderCancelled EventOrderBilled Event
ModificationBilled Event
OrderRefunded Event
OrderShipped Event
OrderShippingCancelled Event
PlaceOrder Request
ModifyOrder Request
CancelOrder Request
Example Scenario – Kafka Topics
Related Events in a Few Topics
eCommerce
Site
SalesOrder Requests Topic
Orders Topic
Billing
Shipping
OrderPlaced Event
OrderModified Event
OrderCancelled Event
OrderBilled Event
ModificationBilled Event
OrderRefunded Event
OrderShipped Event
OrderShippingCancelled Event
PlaceOrder Request
ModifyOrder Request
CancelOrder Request
Billing Topic
Shipments Topic
Example Scenario – Kafka Topics
One Topic per Event
eCommerce
Site
SalesModify Order Requests Topic
OrdersModified Topic
Billing
Shipping
OrderPlaced Event
OrderModified Event
OrderCancelled Event
OrderShipped Event
OrderShippingCancelled Event
PlaceOrder Request
ModifyOrder Request
CancelOrder Request
Order Refunded Topic
Shipments Topic
Order Billed Topic
ModificationBilled Topic
OrdersPlaced Topic
OrdersCancelled Topic
CancelledShipments Topic
OrderRefunded Event
OrderBilled Event
ModificationBilled Event
Place Order Requests Topic
Cancel Order Requests Topic
Modifying the Scenario – Class of Service
eCommerce
Site
Sales and
Inventory
Billing
Shipping
PlaceOrder-Priority
PlaceOrder-Standard
OrderPlaced-Priority
OrderPlaced-Standard
OrderBilled-Priority
OrderBilled-Standard
OrderPlaced-Priority
OrderPlaced-Standard
eCommerce
Site
Sales and
Inventory
Billing
Shipping
ModifyOrder-Priority
ModifyOrder-Standard
OrderModified-Priority
OrderModified-Standard
ModificationBilled-Priority
ModificationBilled-Standard
OrderModified-Priority
OrderModified-Standard
Scenario #2 – RabbitMQ Topic Exchanges
eCommerce
Site
PlaceOrder
Sales
Sales-Standard
OrderPlaced
Billing-Priority
Billing
Shipping
Shipping-Priority
OrderRefunded
Direct Exchange per Event, Routing Key with Class of Service,
Queue per Class of Service
ModifyOrder
CancelOrder
OrderModified
OrderCancelled
OrderBilled
Modification
Billed
Sales-Priority
Billing-Standard
Shipping-Standard
priority
standard
Scenario #2 – RabbitMQ Two Layered Topic Exchanges
eCommerce
Site
amq.topic
Sales
Sales-Standard
Shipping-Priority
place.order.standard
modify.order.standard
cancel.order.standard
Billing-Priority
Billing
order.placed.priority
order.modified.priority
order.cancelled.priority
Single Topic Exchange (amq.topic)
Routing Key with event name
Class of Service as Message Header
Sales-Priority
Billing-Standard
order.placed.*
order.modified.*
order.cancelled.*
Shipping-Standard
order.placed.*
order.modified.*
order.cancelled.*
order.billed.*
modification.billed.*
Shipping
Sales (Topic)
place.order.*
modify.order.*
cancel.order.*
Billing
(Topic)
Shipping
(Topic)
order.billed.standard
modification.billed.standard
order.refunded.standard
order.billed.priority
modification.billed.priority
order.refunded.priority
#.priority
#.standard
#.priority
#.priority
#.standard
#.standard
place.order.priority
modify.order.priority
cancel.order.priority
order.placed.standard
order.modified.standard
order.cancelled.standard
Scenario #2 – RabbitMQ Topic and Header Exchanges
eCommerce
Site
amq.topic
Sales
Sales-Standard
Shipping-Priority
place.order
modify.order
cancel.order
Billing-Priority
Billing
order.placed
order.modified
order.cancelled
Single Topic Exchange (amq.topic)
Routing Key with event name
Class of Service as Message Header
Sales-Priority
Billing-Standard
order.placed
order.modified
order.cancelled
Shipping-Standard
order.placed
order.modified
order.cancelled,
order.billed
modification.billed
Shipping
Sales
(Header)
place.order
modify.order
cancel.order
Billing
(Header)
Shipping
(Header)order.billed
modification.billed
order.refunded
Scenario #2 – RabbitMQ Topic Exchanges
Priority VHost
Replicate preferred routing topology without Class of Service,
in two separate virtual hosts
Standard VHost
Scenario #2 – Kafka Topics
eCommerce
Site
Sales-Priority
Order Requests Topic
Orders Topic
Related Events in One Topic – Dedicated Application Instances
Billing-Priority
Shipping-Standard
OrderPlaced Event
OrderModified Event
OrderCancelled Event
OrderBilled Event
ModificationBilled Event
OrderRefunded Event
OrderShipped Event
OrderShippingCancelled Event
PlaceOrder Request
ModifyOrder Request
CancelOrder Request
Sales-Standard
Billing-Standard
Shipping-Priority
Scenario #2 – Kafka Topics
eCommerce
Site
Priority Orders Topic
Related Events in Class of Service Based Topics – Dedicated Instances
Billing-Priority
Shipping-Standard
OrderPlaced Event
OrderModified Event
OrderCancelled Event
OrderBilled Event, ModificationBilled Event, OrderRefunded Event
PlaceOrder Request
ModifyOrder Request
CancelOrder Request
Sales-Priority
Shipping-Priority
Billing-Standard
Standard Orders Topic
OrderShipped Event, OrderShippingCancelled Event
OrderShipped Event, OrderShippingCancelled Event
OrderBilled Event, ModificationBilled Event, OrderRefunded Event
Priority Order
Requests Topic
Sales-Standard
Standard Order
Requests Topic OrderPlaced Event
OrderModified Event
OrderCancelled Event
Scenario #2 – Replicate Events to Other Systems
eCommerce
Site
Sales-Priority
Order Requests Topic
Orders Topic
Kafka Topic as an Event Store and Data Replication Source
Billing-Priority
Shipping-Standard
Sales-Standard
Billing-Standard
Shipping-Priority
Decoupling of publishers from subscribers
Endpoint Decoupling
RabbitMQ: The endpoint we publish to is decoupled from
the endpoint we consume from.
Kafka: The endpoint we publish to is the same as we
subscribe from.
Temporal Decoupling
RabbitMQ: Consumers read a message once, most likely
close to the time of publishing.
Kafka: Consumers are decoupled temporally from the
publisher. Consumers can read messages multiple times,
and go back in history to read old messages.
RabbitMQ KafkaSimple Pub Sub
Easily Evolvable
Topologies
Transient Messages
Persistent Messages
AMQP
Time Travel
Data Replication
Event Store
Simple Scaling
Flexible Message
Routing
Thank you!
Questions?
Jack Vanlightly
12 NOVEMBER 2018
London, UK
CALL FOR TALKS close 1 June
EARLY BIRD TICKETS available now!

Contenu connexe

Tendances

Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin PodvalMartin Podval
 
An Introduction to Apache Kafka
An Introduction to Apache KafkaAn Introduction to Apache Kafka
An Introduction to Apache KafkaAmir Sedighi
 
Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3SANG WON PARK
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafkaemreakis
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache KafkaShiao-An Yuan
 
IBM MQ and Kafka, what is the difference?
IBM MQ and Kafka, what is the difference?IBM MQ and Kafka, what is the difference?
IBM MQ and Kafka, what is the difference?David Ware
 
Deep Dive into Apache Kafka
Deep Dive into Apache KafkaDeep Dive into Apache Kafka
Deep Dive into Apache Kafkaconfluent
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka IntroductionAmita Mirajkar
 
IBM MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM MQ: Managing Workloads, Scaling and Availability with MQ ClustersIBM MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM MQ: Managing Workloads, Scaling and Availability with MQ ClustersDavid Ware
 
Rabbitmq an amqp message broker
Rabbitmq an amqp message brokerRabbitmq an amqp message broker
Rabbitmq an amqp message brokerANASYS
 

Tendances (20)

Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin Podval
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
An Introduction to Apache Kafka
An Introduction to Apache KafkaAn Introduction to Apache Kafka
An Introduction to Apache Kafka
 
Kafka basics
Kafka basicsKafka basics
Kafka basics
 
Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3Apache kafka performance(latency)_benchmark_v0.3
Apache kafka performance(latency)_benchmark_v0.3
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Kafka: Internals
Kafka: InternalsKafka: Internals
Kafka: Internals
 
Apache Kafka at LinkedIn
Apache Kafka at LinkedInApache Kafka at LinkedIn
Apache Kafka at LinkedIn
 
RabbitMQ
RabbitMQ RabbitMQ
RabbitMQ
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Kafka tutorial
Kafka tutorialKafka tutorial
Kafka tutorial
 
IBM MQ and Kafka, what is the difference?
IBM MQ and Kafka, what is the difference?IBM MQ and Kafka, what is the difference?
IBM MQ and Kafka, what is the difference?
 
Deep Dive into Apache Kafka
Deep Dive into Apache KafkaDeep Dive into Apache Kafka
Deep Dive into Apache Kafka
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
IBM MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM MQ: Managing Workloads, Scaling and Availability with MQ ClustersIBM MQ: Managing Workloads, Scaling and Availability with MQ Clusters
IBM MQ: Managing Workloads, Scaling and Availability with MQ Clusters
 
Rabbitmq an amqp message broker
Rabbitmq an amqp message brokerRabbitmq an amqp message broker
Rabbitmq an amqp message broker
 

Similaire à RabbitMQ vs Apache Kafka: Comparing two giants of the messaging space - Part 1

Distributed messaging with Apache Kafka
Distributed messaging with Apache KafkaDistributed messaging with Apache Kafka
Distributed messaging with Apache KafkaSaumitra Srivastav
 
Timothy Spann: Apache Pulsar for ML
Timothy Spann: Apache Pulsar for MLTimothy Spann: Apache Pulsar for ML
Timothy Spann: Apache Pulsar for MLEdunomica
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPCMax Alexejev
 
Kafka - Messaging System
Kafka - Messaging SystemKafka - Messaging System
Kafka - Messaging SystemTanuj Mehta
 
bigdata 2022_ FLiP Into Pulsar Apps
bigdata 2022_ FLiP Into Pulsar Appsbigdata 2022_ FLiP Into Pulsar Apps
bigdata 2022_ FLiP Into Pulsar AppsTimothy Spann
 
Multi-Datacenter Kafka - Strata San Jose 2017
Multi-Datacenter Kafka - Strata San Jose 2017Multi-Datacenter Kafka - Strata San Jose 2017
Multi-Datacenter Kafka - Strata San Jose 2017Gwen (Chen) Shapira
 
Kafka syed academy_v1_introduction
Kafka syed academy_v1_introductionKafka syed academy_v1_introduction
Kafka syed academy_v1_introductionSyed Hadoop
 
apachekafka-160907180205.pdf
apachekafka-160907180205.pdfapachekafka-160907180205.pdf
apachekafka-160907180205.pdfTarekHamdi8
 
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 MeetUpJosé Román Martín Gil
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache KafkaRicardo Bravo
 
JConf.dev 2022 - Apache Pulsar Development 101 with Java
JConf.dev 2022 - Apache Pulsar Development 101 with JavaJConf.dev 2022 - Apache Pulsar Development 101 with Java
JConf.dev 2022 - Apache Pulsar Development 101 with JavaTimothy Spann
 
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...Lucas Jellema
 
Data Pipelines with Apache Kafka
Data Pipelines with Apache KafkaData Pipelines with Apache Kafka
Data Pipelines with Apache KafkaBen Stopford
 
Kafka 10000 feet view
Kafka 10000 feet viewKafka 10000 feet view
Kafka 10000 feet viewyounessx01
 
Copy of Kafka-Camus
Copy of Kafka-CamusCopy of Kafka-Camus
Copy of Kafka-CamusDeep Shah
 
Kafka for begginer
Kafka for begginerKafka for begginer
Kafka for begginerYousun Jeong
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 
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
 

Similaire à RabbitMQ vs Apache Kafka: Comparing two giants of the messaging space - Part 1 (20)

Distributed messaging with Apache Kafka
Distributed messaging with Apache KafkaDistributed messaging with Apache Kafka
Distributed messaging with Apache Kafka
 
Timothy Spann: Apache Pulsar for ML
Timothy Spann: Apache Pulsar for MLTimothy Spann: Apache Pulsar for ML
Timothy Spann: Apache Pulsar for ML
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
 
Kafka - Messaging System
Kafka - Messaging SystemKafka - Messaging System
Kafka - Messaging System
 
Envoy and Kafka
Envoy and KafkaEnvoy and Kafka
Envoy and Kafka
 
Kafka
KafkaKafka
Kafka
 
bigdata 2022_ FLiP Into Pulsar Apps
bigdata 2022_ FLiP Into Pulsar Appsbigdata 2022_ FLiP Into Pulsar Apps
bigdata 2022_ FLiP Into Pulsar Apps
 
Multi-Datacenter Kafka - Strata San Jose 2017
Multi-Datacenter Kafka - Strata San Jose 2017Multi-Datacenter Kafka - Strata San Jose 2017
Multi-Datacenter Kafka - Strata San Jose 2017
 
Kafka syed academy_v1_introduction
Kafka syed academy_v1_introductionKafka syed academy_v1_introduction
Kafka syed academy_v1_introduction
 
apachekafka-160907180205.pdf
apachekafka-160907180205.pdfapachekafka-160907180205.pdf
apachekafka-160907180205.pdf
 
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
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
JConf.dev 2022 - Apache Pulsar Development 101 with Java
JConf.dev 2022 - Apache Pulsar Development 101 with JavaJConf.dev 2022 - Apache Pulsar Development 101 with Java
JConf.dev 2022 - Apache Pulsar Development 101 with Java
 
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
AMIS SIG - Introducing Apache Kafka - Scalable, reliable Event Bus & Message ...
 
Data Pipelines with Apache Kafka
Data Pipelines with Apache KafkaData Pipelines with Apache Kafka
Data Pipelines with Apache Kafka
 
Kafka 10000 feet view
Kafka 10000 feet viewKafka 10000 feet view
Kafka 10000 feet view
 
Copy of Kafka-Camus
Copy of Kafka-CamusCopy of Kafka-Camus
Copy of Kafka-Camus
 
Kafka for begginer
Kafka for begginerKafka for begginer
Kafka for begginer
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
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 !
 

Plus de Erlang Solutions

Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdfFintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdfErlang Solutions
 
Datadog and Elixir with Erlang Solutions
Datadog and Elixir with Erlang SolutionsDatadog and Elixir with Erlang Solutions
Datadog and Elixir with Erlang SolutionsErlang Solutions
 
Strategies for successfully adopting Elixir
Strategies for successfully adopting ElixirStrategies for successfully adopting Elixir
Strategies for successfully adopting ElixirErlang Solutions
 
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...Erlang Solutions
 
Building the ideal betting stack | London Erlang User Group presentation
Building the ideal betting stack | London Erlang User Group presentationBuilding the ideal betting stack | London Erlang User Group presentation
Building the ideal betting stack | London Erlang User Group presentationErlang Solutions
 
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...Erlang Solutions
 
Empowering mobile first workers in emerging-markets using messaging
Empowering mobile first workers in emerging-markets using messagingEmpowering mobile first workers in emerging-markets using messaging
Empowering mobile first workers in emerging-markets using messagingErlang Solutions
 

Plus de Erlang Solutions (7)

Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdfFintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
 
Datadog and Elixir with Erlang Solutions
Datadog and Elixir with Erlang SolutionsDatadog and Elixir with Erlang Solutions
Datadog and Elixir with Erlang Solutions
 
Strategies for successfully adopting Elixir
Strategies for successfully adopting ElixirStrategies for successfully adopting Elixir
Strategies for successfully adopting Elixir
 
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
 
Building the ideal betting stack | London Erlang User Group presentation
Building the ideal betting stack | London Erlang User Group presentationBuilding the ideal betting stack | London Erlang User Group presentation
Building the ideal betting stack | London Erlang User Group presentation
 
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
 
Empowering mobile first workers in emerging-markets using messaging
Empowering mobile first workers in emerging-markets using messagingEmpowering mobile first workers in emerging-markets using messaging
Empowering mobile first workers in emerging-markets using messaging
 

Dernier

2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainAbdul Ahad
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 

Dernier (20)

2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software Domain
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 

RabbitMQ vs Apache Kafka: Comparing two giants of the messaging space - Part 1

  • 1. RabbitMQ vs Apache Kafka Comparing two giants of the messaging space Part 1 – Core Concepts and Topologies
  • 2. Background • Jack Vanlightly • Software Architect of SII Concatel, Barcelona • Event-Driven Architectures • Messaging Systems • Data Integrations • https://jack-vanlightly.com
  • 3. The Log (Apache Kafka) The Queue (RabbitMQ) VS
  • 4. The Log (Apache Kafka) The Queue (RabbitMQ) The Queue • First In First Out data structure • Optimized for efficient write and read operations from either end of the sequence • Stored data is transient in nature • Not shared between applications 7 6 5 4 3 2 1Write Read VS The Log • Also known as Write-Ahead Logs, Transaction Logs and Commit Logs. • Append-only. Ordered By Time. • Unique log sequence numbers. • Stored data is persistent in nature • Shared between applications 1 2 3 4 5 6 7 Reader Reader
  • 5. RabbitMQ The Building Blocks Routing Fanout Exchange Direct Exchange Topic Exchange Header Exchange Consistent Hashing Exchange Random Exchange Sharding Queues and Consumers Queues Competing Consumers Non-Competing Consumers Ephemeral Queues Lazy Queues Priority Queues More Deadletter Exchange Alternate Exchange Virtual Hosts
  • 6. Exchanges, Queues and Bindings • Publishers send messages to Exchanges • Exchanges route messages to Queues and even other Exchanges. • Consumers read from Queues • Bindings link Exchanges to Queues and even Exchanges to Exchanges Publisher Exchange Queue Consumer binding RabbitMQ Building Blocks Traditional queues on steroids
  • 7. Publish – Subscribe Publisher Fanout Exchange Queue B Consumer Fanout Simplest Publish-Subscribe pattern. Each consumer receives every message Queue A Queue C Consumer Consumer
  • 8. Publish – Subscribe with Routing Direct Exchange Routing by Routing Key Exact match routing key = binding key Publisher Direct Exchange Queue B Consumer Queue A Queue C Consumer Consumer created modified cancelled Routing Key Binding Key: created Binding Key: modified Binding Key: cancelled
  • 9. Publish – Subscribe with Routing Topic Exchange Wildcard routing by Routing Key * = match 1 word # = match multiple words booking.baggage.added booking.baggage.removed booking.passenger.added booking.passenger.removed payment.received Publisher Topic Exchange Queue B Consumer Queue A Queue C Consumer Consumer Routing Key booking.# *.passenger.* payment.received
  • 10. Publish – Subscribe with Routing Header Exchange Routing by message headers Publisher Header Exchange Queue B Consumer Queue A Queue C Consumer Consumer VIP=true, Country=UK, All VIP=False VIP: true Country: UK VIP=true, Country=UK, Any
  • 11. Point-to-Point Messaging Default Exchange Direct exchange type All queues have implicit binding to the default exchange. Routes messages by Routing Key to Queue Name Publisher Default Exchange Orders Consumer Notifications Shipping Consumer Consumer Routing Key
  • 12. Protecting Against Routing Failures Alternate Exchange Not an exchange type but a configured relationship between two exchanges. Route unrouteable messages to an alternate exchange Publisher Topic Exchange Queue Consumer Queue Unrouteable messages Consumer Consumer created modified Fanout Exchangeunrouteable
  • 13. Scaling Out Consumers Fanout Exchange Shipping Shipping Non-Competing Consumers Each consumer receives every message Scale Out with Competing Consumers Each Shipping consumer receives a subset of the messages. Notifications Billing Billing Notifier Sales Publisher Fanout Exchange Shipping Shipping Shipping Shipping Notifications Notifier Billing Billing Sales Publisher
  • 14. Scaling Out Queues Random Exchange Load balance messages across queues randomly Publisher Random Exchange Shipping.2 Consumer Shipping.1 Shipping.3 Consumer Consumer
  • 15. Scaling Out Queues With Data Locality Consistent Hashing Exchange Partition messages across queues via hashing function over routing key, message header or message property Publisher Hashing Exchange Shipping.2 Consumer Shipping.1 Shipping.3 Consumer Consumer Routing Key 1/3 hash space 1/3 hash space 1/3 hash space
  • 16. Scaling Out Queues With Data Locality Sharding Plugin and Modulus Exchange Partition messages across queues over multiple hosts via hashing function on the routing key. Publisher Modulus Exchange Host 1 Shard 2 Consumer Host 1 Shard 1 Host 1 Shard 3 Consumer Consumer Routing Key Publisher Modulus Exchange Host 2 Shard 2 Consumer Host 2 Shard 1 Host 2 Shard 3 Consumer Consumer Routing Key
  • 17. Apply limits to queues • Length • Size • Time limits (TTL) Eject messages from a queue when: • A queue size/length limit reached. • A message has spent longer than the TTL time limit in the queue Route to a deadletter exchange to avoid message loss. Queue Limits and Deadletter Exchanges 7 6 5 4 3 2 1 X Queue Exchange Consumer Queue
  • 18. Ephemeral • Auto-Delete Queue • Queue Expiration (TTL) • Exclusive Queues • Auto-Delete Exchanges Lazy Queues • Memory optimized queues. Priority Queues • No longer FIFO. • Publisher sets priority on messages • Priority Queue moves higher priority messages ahead of lower • Drawbacks – blocked low priority messages, low priority can eject high priority when queue is full Ephemeral Exchanges and Queues Lazy Queues Priority Queues
  • 19. • Allows Multi-Tenant architecture • Isolation of groups of exchanges, queues and users • No routing between two virtual hosts Virtual Hosts
  • 20. Apache Kafka The Building Blocks Topics Partitions Consumer Groups
  • 21. • Distributed because Kafka is deployed as a cluster of nodes, for both fault tolerance and scale • Partitioned because each topic can be sharded into multiple partitions, with each partition storing a disjoint set of the data. • Replicated because partitions are usually replicated across multiple nodes (servers). • Commit Log because messages are stored in an append only fashion. Apache Kafka Core Concepts The Rise of the Distributed, Partitioned, Replicated, Commit Log
  • 22. • Kafka has a simple Publish Subscribe model • Topics • Each Topic has one or more partitions • Each partition has a replication factor of one or more Topics, Partitions and Consumer Groups Producer ConsumerTopic Producer ConsumerPartition 2 Partition 1 Partition 3
  • 23. Consumer Group Topics, Partitions and Consumer Groups Producer P 1 P 2 P 3 C1 C2 C3 A single consumer group of three consumers reads from a topic of three partitions. The unit of parallelism of a topic is the partition.
  • 24. Topics, Partitions and Consumer Groups Consumer Group Producer P 1 P 2 P 3 C1 C2 C3 C4 A single consumer group of four consumers reads from a topic of three partitions. One consumer sits idle.
  • 25. Consumer Group Topics, Partitions and Consumer Groups Producer P 1 P 2 P 5 C1 C2 C3 P 3 P 4 A single consumer group of three consumers reads from a topic of five partitions. Two consumers read from two partitions.
  • 26. Consumer Group Topics, Partitions and Consumer Groups Producer P 1 P 2 P 3 C1 C2 C3 Consumer Group C4 C5 C6 Two consumer groups of three consumers read from a topic of three partitions
  • 27. • Producers append messages to the end of partitions. • The partition is chosen by the producer (round robin or partition key). • Messages are removed according to the data retention policy. • Consumers keep track their position in the partitions they consume from – called the consumer offset Topics, Partitions and Consumer Groups 1 2 3 4 5 6 7 Producer Consumer 1 Write Read at offsetData retention policyX
  • 28. Topics, Partitions and Consumer Groups 1 2 3 4 5 6 7 Producer Consumer 1 CG ARead at offset Consumer 4 CG BRead at offset Partition 1 1 2 3 4 5 6 7 Consumer 2 CG ARead at offset Consumer 5 CG B Read at offset Partition 28 1 2 3 4 5 6 Consumer 3 CG ARead at offset Consumer 6 CG BRead at offset Partition 3
  • 30. Log Compaction • Clean up old versions of a record (by record key). Keep latest version only. • Periodic process • Kafka as an event store Apache Kafka Log Compaction A X G U D W J X E A E O P X A X G U D W J X E A E O D X G U W J A E O D X
  • 31. Avro Schema Registry • Send messages in a compact binary format – Avro • Schema Registry service automates sharing of Avro schemas between producers and consumers • Schema Registry to safely control evolution of schemas Apache Kafka Schema Registry Producer ConsumerTopic Schema Registry Send schema Get schema
  • 32. Data Replication / Event Sourcing • Kafka as a single source of truth • Sits at the center of your architecture • Kafka Connect Apache Kafka Data Replication Event Sourcing Kafka Topics
  • 34. Example Scenario eCommerce Site Sales and Inventory Billing Shipping PlaceOrder OrderPlaced OrderBilledOrderPlaced eCommerce Site Sales and Inventory Billing Shipping ModifyOrder OrderModified ModificationBilledOrderModified eCommerce Site Sales and Inventory Billing Shipping CancelOrder OrderCancelled OrderCancelled
  • 35. Example Scenario – RabbitMQ Fanout Exchanges eCommerce Site PlaceOrder SalesSales OrderPlaced BillingBilling Shipping Shipping OrderRefunded Fanout Exchange per Event, Single Queue per Application ModifyOrder CancelOrder OrderModified OrderCancelled OrderBilled Modification Billed
  • 36. Example Scenario – RabbitMQ Fanout Exchanges eCommerce Site PlaceOrder Sales Scaling our Single Queue, Maintaining Relative Ordering ModifyOrder CancelOrder Sales.1 Sales Hashing Exchange Sales.2 Sales.3 Sales.4 Sales.5 Sales Sales Sales Sales
  • 37. Example Scenario – RabbitMQ Topic Exchanges eCommerce Site amq.topic SalesSales ShippingShipping place.order modify.order cancel.order place.order modify.order cancel.order Billing Billing order.placed order.modified order.cancelled order.billed modification.billed order.placed order.modified order.cancelled order.billed order.modification.billed order.refunded Single Topic Exchange (amq.topic) order.placed order.modified order.cancelled
  • 38. Example Scenario – Kafka Topics eCommerce Site SalesOrder Requests Topic Orders Topic Related Events in One Topic Billing Shipping OrderPlaced Event OrderModified Event OrderCancelled EventOrderBilled Event ModificationBilled Event OrderRefunded Event OrderShipped Event OrderShippingCancelled Event PlaceOrder Request ModifyOrder Request CancelOrder Request
  • 39. Example Scenario – Kafka Topics Related Events in a Few Topics eCommerce Site SalesOrder Requests Topic Orders Topic Billing Shipping OrderPlaced Event OrderModified Event OrderCancelled Event OrderBilled Event ModificationBilled Event OrderRefunded Event OrderShipped Event OrderShippingCancelled Event PlaceOrder Request ModifyOrder Request CancelOrder Request Billing Topic Shipments Topic
  • 40. Example Scenario – Kafka Topics One Topic per Event eCommerce Site SalesModify Order Requests Topic OrdersModified Topic Billing Shipping OrderPlaced Event OrderModified Event OrderCancelled Event OrderShipped Event OrderShippingCancelled Event PlaceOrder Request ModifyOrder Request CancelOrder Request Order Refunded Topic Shipments Topic Order Billed Topic ModificationBilled Topic OrdersPlaced Topic OrdersCancelled Topic CancelledShipments Topic OrderRefunded Event OrderBilled Event ModificationBilled Event Place Order Requests Topic Cancel Order Requests Topic
  • 41. Modifying the Scenario – Class of Service eCommerce Site Sales and Inventory Billing Shipping PlaceOrder-Priority PlaceOrder-Standard OrderPlaced-Priority OrderPlaced-Standard OrderBilled-Priority OrderBilled-Standard OrderPlaced-Priority OrderPlaced-Standard eCommerce Site Sales and Inventory Billing Shipping ModifyOrder-Priority ModifyOrder-Standard OrderModified-Priority OrderModified-Standard ModificationBilled-Priority ModificationBilled-Standard OrderModified-Priority OrderModified-Standard
  • 42. Scenario #2 – RabbitMQ Topic Exchanges eCommerce Site PlaceOrder Sales Sales-Standard OrderPlaced Billing-Priority Billing Shipping Shipping-Priority OrderRefunded Direct Exchange per Event, Routing Key with Class of Service, Queue per Class of Service ModifyOrder CancelOrder OrderModified OrderCancelled OrderBilled Modification Billed Sales-Priority Billing-Standard Shipping-Standard priority standard
  • 43. Scenario #2 – RabbitMQ Two Layered Topic Exchanges eCommerce Site amq.topic Sales Sales-Standard Shipping-Priority place.order.standard modify.order.standard cancel.order.standard Billing-Priority Billing order.placed.priority order.modified.priority order.cancelled.priority Single Topic Exchange (amq.topic) Routing Key with event name Class of Service as Message Header Sales-Priority Billing-Standard order.placed.* order.modified.* order.cancelled.* Shipping-Standard order.placed.* order.modified.* order.cancelled.* order.billed.* modification.billed.* Shipping Sales (Topic) place.order.* modify.order.* cancel.order.* Billing (Topic) Shipping (Topic) order.billed.standard modification.billed.standard order.refunded.standard order.billed.priority modification.billed.priority order.refunded.priority #.priority #.standard #.priority #.priority #.standard #.standard place.order.priority modify.order.priority cancel.order.priority order.placed.standard order.modified.standard order.cancelled.standard
  • 44. Scenario #2 – RabbitMQ Topic and Header Exchanges eCommerce Site amq.topic Sales Sales-Standard Shipping-Priority place.order modify.order cancel.order Billing-Priority Billing order.placed order.modified order.cancelled Single Topic Exchange (amq.topic) Routing Key with event name Class of Service as Message Header Sales-Priority Billing-Standard order.placed order.modified order.cancelled Shipping-Standard order.placed order.modified order.cancelled, order.billed modification.billed Shipping Sales (Header) place.order modify.order cancel.order Billing (Header) Shipping (Header)order.billed modification.billed order.refunded
  • 45. Scenario #2 – RabbitMQ Topic Exchanges Priority VHost Replicate preferred routing topology without Class of Service, in two separate virtual hosts Standard VHost
  • 46. Scenario #2 – Kafka Topics eCommerce Site Sales-Priority Order Requests Topic Orders Topic Related Events in One Topic – Dedicated Application Instances Billing-Priority Shipping-Standard OrderPlaced Event OrderModified Event OrderCancelled Event OrderBilled Event ModificationBilled Event OrderRefunded Event OrderShipped Event OrderShippingCancelled Event PlaceOrder Request ModifyOrder Request CancelOrder Request Sales-Standard Billing-Standard Shipping-Priority
  • 47. Scenario #2 – Kafka Topics eCommerce Site Priority Orders Topic Related Events in Class of Service Based Topics – Dedicated Instances Billing-Priority Shipping-Standard OrderPlaced Event OrderModified Event OrderCancelled Event OrderBilled Event, ModificationBilled Event, OrderRefunded Event PlaceOrder Request ModifyOrder Request CancelOrder Request Sales-Priority Shipping-Priority Billing-Standard Standard Orders Topic OrderShipped Event, OrderShippingCancelled Event OrderShipped Event, OrderShippingCancelled Event OrderBilled Event, ModificationBilled Event, OrderRefunded Event Priority Order Requests Topic Sales-Standard Standard Order Requests Topic OrderPlaced Event OrderModified Event OrderCancelled Event
  • 48. Scenario #2 – Replicate Events to Other Systems eCommerce Site Sales-Priority Order Requests Topic Orders Topic Kafka Topic as an Event Store and Data Replication Source Billing-Priority Shipping-Standard Sales-Standard Billing-Standard Shipping-Priority
  • 49. Decoupling of publishers from subscribers Endpoint Decoupling RabbitMQ: The endpoint we publish to is decoupled from the endpoint we consume from. Kafka: The endpoint we publish to is the same as we subscribe from. Temporal Decoupling RabbitMQ: Consumers read a message once, most likely close to the time of publishing. Kafka: Consumers are decoupled temporally from the publisher. Consumers can read messages multiple times, and go back in history to read old messages.
  • 50. RabbitMQ KafkaSimple Pub Sub Easily Evolvable Topologies Transient Messages Persistent Messages AMQP Time Travel Data Replication Event Store Simple Scaling Flexible Message Routing
  • 51. Thank you! Questions? Jack Vanlightly 12 NOVEMBER 2018 London, UK CALL FOR TALKS close 1 June EARLY BIRD TICKETS available now!