SlideShare a Scribd company logo
Ten reasons to choose Apache Pulsar over
Apache Kafka for Event Sourcing (CQRS)
Who am I?
Ten reasons to choose Apache Pulsar 2
Robert van Mölken
Solution Architect / Developer
Blockchain / IoT / Cloud Apps
Groundbreaker Ambassador
Author two books including:
Blockchain across Oracle
Linkedin: linkedin.com/in/rvmolken
Blog: technology.vanmolken.nl
Twitter: @robertvanmolken
Ten reasons to choose Apache Pulsar over Apache Kafka
For Event Sourcing (CQRS)
Apache Pulsar for Event Sourcing 3
TOPICS TO COVER
What is Event Sourcing and CQRS
Common problems with Kafka-based projects
Introducing our ‘friend’, Pulsar
Reasons why Pulsar should be your #1 pick
What is Event Sourcing and CQRS
• Event sourcing uses event-centric
approach to persistence business
object states.
• A business object is persisted by
storing a sequence of state
changing events.
• Whenever an object’s state
changes, a new event is appended
to the sequence of events.
• An app stores an object by
persisting its state changing events.
Each event would contain sufficient
data to reconstruct the object’s state
by many different applications.
What is Event Sourcing and CQRS
Apache Pulsar for Event Sourcing 5
Event Sourcing
• Architectural design pattern for
developing software whereby writing
and reading data are separate
responsibilities
• The bits of the system that are
responsible for changing the system’s
state are physically separated from the
bits of the system that manage views
• In constast, a traditional CRUD
architecture is implemented by the
same component
• It has the responsibility for both reads
(the views) and the writes (the state
changes)
What is Event Sourcing and CQRS (Cont.)
Apache Pulsar for Event Sourcing 6
CQRS
Command and Query Responsibility Segregation
Why use Event Sourcing and CQRS?
Apache Pulsar for Event Sourcing 7
Common problems with Kafka-based projects
Common problems with Kafka-based projects
Apache Pulsar for Event Sourcing 9
Source: https://jack-vanlightly.com/sketches/2018/10/2/kafka-vs-pulsar-rebalancing-sketch
Common problems with Kafka-based projects (Cont.)
• Scaling Kafka is difficult due to the way Kafka stores data within the broker as
distributed logs that stores as messaging persistence store
• Changing partition sizes to allow more storage can mess the message order by
conflicting the message indexes, but for CQRS order is most important
• Must plan and calculate number of brokers, topics, partitions and replicas in first place
to avoid scaling problems
• Cluster rebalancing can impact performance of connected producers and consumers.
Brokers must synchronize state from others that contain replicas of its partitions.
• No native authorization on events/commands and no native event analyzer tool (you
would for example need Apache Spark or Heron)
• Kafka’s geo replication mechanism is notoriously problematic, even within just two
data centers, resulting in delayed data delivery or complete loss of data
Apache Pulsar for Event Sourcing 10
Apache Pulsar for Event Sourcing 11
Let’s talk about our “friend”, Pulsar
What is Apache Pulsar?
Apache Pulsar for Event Sourcing 12
Apache Pulsar is an open source pub-sub messaging platform backed by durable
storage (Apache Bookkeeper) with the following cool features:
Apache Pulsar for Event Sourcing 13
Apache Pulsar for Event Sourcing 14
#1 Streaming and Queing come together
• Kafka is a event streaming platform (only)
• It implements the concept of topics
• Pub/sub system, permanent storage,
processing event streams, Avro message
validation shema
• Based on a distributed commit log
• Capable of handling trillions of events a day
Kafka
• Pulsar started as message queing platform, but
can also handle high-rate
real-time (event sourcing) use case
• It implements the concept of topics
• Pub/sub, distributed + cold storage, event
processing, and multiple message validation
schemas (incl. AVRO, JSON, raw)
• And standard message queuing patterns
• Competing consumers, fail-over
subscriptions, and message fan out
• Based on distributed legder / log segments
Pulsar
Apache Pulsar for Event Sourcing 15
#2 Logs versus distributed ledgers
Kafka logs are append-only and sequential, so data can be written to and extracted from them quickly
But simple logs can get you into trouble when they get large – storage, scale up / out, replication …
Pulsar avoids the problem of copying large
logs by breaking the log into segments. It
distributes those segments across multiple
servers while the data is being written by
using BookKeeper as its storage layer
Apache Pulsar for Event Sourcing 16
#2 Logs versus distributed ledgers
For event sourcing and CQRS it is important to distribute events quickly to all consumers even when loads get high!
Apache Pulsar for Event Sourcing 17
#2 Logs versus distributed ledgers
With Pulsar tiered storage you can
automatically push old messages into
practically infinite, cheap cloud storage and
retrieve them just like you do those newer,
fresh messages
Apache Pulsar for Event Sourcing 18
#3 Tiered Storage (plus for Event Sourcing)
For event sourcing it is important to be able to replay messages that already been consumed. For example when the
application got an unexpected exception or you build a new application. So keeping then forever! Sounds great right?
#3 Tiered Storage (plus for Event Sourcing)
Apache Pulsar for Event Sourcing 19
Plus for ES/CQRS:
New tenants (bookkeepers) can
easily sync data and consumers
can easily get all events via same
API without difference
Apache Pulsar for Event Sourcing 20
#4 Stateful vs Stateless brokers
• Kafka uses stateful brokers
• Every broker contains the complete log for each
of its partitions.
• If a broker fails, the work can’t be taken over by
just any broker. Also when load is getting to high
• Brokers must synchronize state from other
brokers that contain replicas of its partitions.
• Syncing large logs takes time to distribute
Kafka
• Pulsar uses stateless brokers
• Pulsar holds state, but just not in the broker
• Brokering of data is separated from storing
• Brokers accept data (from producers)
• Brokers send data (to consumers)
• Data is separate stored in BookKeeper
• If load gets high can easily add a new broker
• No data to load so starts immediately
• Plus for ES/CQRS: always garantee data is
available to consumer in real-time (in high load)
Pulsar
Apache Pulsar for Event Sourcing 21
Source: https://www.xenonstack.com/
#4 Stateful vs Stateless brokers
Plus for ES/CQRS:
Always garantee data is available
to consumer in real-time (e.g. in
high load)
In Pulsar Type safety is paramount in
communication between the producer and
the consumer. For safety in messaging,
pulsar adopted both client-side as server-side
schema/message validation.
Apache Pulsar for Event Sourcing 22
#5 Schema registry and message validation
For CQRS it is important that clients send only (known) commands that can be validated. Kafka only support
message validation using AVRO schemas. Additionally, messages need to be encoded and decoded in code
#5 Schema registry and message validation - how it works?
• Pulsar schema is applied and enforced at the topic level. Producers and
consumers upload schemas to pulsar are asked to conform to the following:
• The Pulsar schema message consists of :
• Name: name is the topic to which the schema is applied.
• Type: the schema format
• Schema: binary representation of the schema.
• User-defined properties as a string/string map
• It supports the following schema payload formats in:
• JSON
• Protobuf
• Avro
• string (used for UTF-8-encoded lines)
• raw bytes (if no schema is defined)
Apache Pulsar for Event Sourcing 23
{
"name": "test-string-schema",
"type": "STRING",
"schema": "",
"properties": {}
}
5 more reasons to choice Pulsar
Apache Pulsar for Event Sourcing 24
Thanks for attending!

More Related Content

What's hot (20)

PDF
Event-driven Architecture
Centric Consulting
 
PDF
The Rise Of Event Streaming – Why Apache Kafka Changes Everything
Kai Wähner
 
PDF
Disaster Recovery Plans for Apache Kafka
confluent
 
PPTX
Event Driven Microservices architecture
NikhilBarthwal4
 
KEY
Introduction to memcached
Jurriaan Persyn
 
PPTX
Netflix Data Pipeline With Kafka
Allen (Xiaozhong) Wang
 
PDF
Common issues with Apache Kafka® Producer
confluent
 
PDF
Design patterns for microservice architecture
The Software House
 
PPTX
Delta Lake with Azure Databricks
Dustin Vannoy
 
PDF
Amazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Web Services Korea
 
PDF
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Kai Wähner
 
PPTX
Introduction to Apache Kafka
Jeff Holoman
 
PDF
Why Splunk Chose Pulsar_Karthik Ramasamy
StreamNative
 
PPTX
The top 3 challenges running multi-tenant Flink at scale
Flink Forward
 
PDF
Aks pimarox from zero to hero
Johan Biere
 
PPTX
Deep Dive into Apache Kafka
confluent
 
PPTX
Change Data Capture to Data Lakes Using Apache Pulsar and Apache Hudi - Pulsa...
StreamNative
 
PPTX
Using the New Apache Flink Kubernetes Operator in a Production Deployment
Flink Forward
 
PDF
[WhaTap DevOps Day] 세션 1 : Observability Practice on AWS
WhaTap Labs
 
PDF
End-to-End Spark/TensorFlow/PyTorch Pipelines with Databricks Delta
Databricks
 
Event-driven Architecture
Centric Consulting
 
The Rise Of Event Streaming – Why Apache Kafka Changes Everything
Kai Wähner
 
Disaster Recovery Plans for Apache Kafka
confluent
 
Event Driven Microservices architecture
NikhilBarthwal4
 
Introduction to memcached
Jurriaan Persyn
 
Netflix Data Pipeline With Kafka
Allen (Xiaozhong) Wang
 
Common issues with Apache Kafka® Producer
confluent
 
Design patterns for microservice architecture
The Software House
 
Delta Lake with Azure Databricks
Dustin Vannoy
 
Amazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Web Services Korea
 
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Kai Wähner
 
Introduction to Apache Kafka
Jeff Holoman
 
Why Splunk Chose Pulsar_Karthik Ramasamy
StreamNative
 
The top 3 challenges running multi-tenant Flink at scale
Flink Forward
 
Aks pimarox from zero to hero
Johan Biere
 
Deep Dive into Apache Kafka
confluent
 
Change Data Capture to Data Lakes Using Apache Pulsar and Apache Hudi - Pulsa...
StreamNative
 
Using the New Apache Flink Kubernetes Operator in a Production Deployment
Flink Forward
 
[WhaTap DevOps Day] 세션 1 : Observability Practice on AWS
WhaTap Labs
 
End-to-End Spark/TensorFlow/PyTorch Pipelines with Databricks Delta
Databricks
 

Similar to Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robert van Mölken (20)

PDF
lessons from managing a pulsar cluster
Shivji Kumar Jha
 
PDF
apidays New York 2022 - Leveraging Event Streaming to Super-Charge your Busin...
apidays
 
PDF
bigdata 2022_ FLiP Into Pulsar Apps
Timothy Spann
 
PDF
Apache Pulsar in Action MEAP V04 David Kjerrumgaard
gcawlrgjfe307
 
PDF
Apache Pulsar in Action MEAP V04 David Kjerrumgaard
biruktresehb
 
PDF
Machine Intelligence Guild_ Build ML Enhanced Event Streaming Applications wi...
Timothy Spann
 
PDF
Apache Pulsar Seattle - Meetup
Karthik Ramasamy
 
PDF
Timothy Spann: Apache Pulsar for ML
Edunomica
 
PDF
INTERFACE by apidays 2023 - Leveraging Event Streaming to Super-Charge your B...
apidays
 
PDF
PhillyJug Getting Started With Real-time Cloud Native Streaming With Java
Timothy Spann
 
PDF
Open keynote_carolyn&matteo&sijie
StreamNative
 
PDF
Apache Pulsar Overview
Streamlio
 
PDF
The Dream Stream Team for Pulsar and Spring
Timothy Spann
 
PPTX
Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus
Data Con LA
 
PDF
Stream or segment : what is the best way to access your events in Pulsar_Neng
StreamNative
 
PDF
Open Source Bristol 30 March 2022
Timothy Spann
 
PDF
Pulsar for Kafka People_Jesse anderson
StreamNative
 
PDF
Pulsar for Kafka People
Jesse Anderson
 
PDF
Music city data Hail Hydrate! from stream to lake
Timothy Spann
 
PDF
What We Learned From Building a Modern Messaging and Streaming System for Cloud
StreamNative
 
lessons from managing a pulsar cluster
Shivji Kumar Jha
 
apidays New York 2022 - Leveraging Event Streaming to Super-Charge your Busin...
apidays
 
bigdata 2022_ FLiP Into Pulsar Apps
Timothy Spann
 
Apache Pulsar in Action MEAP V04 David Kjerrumgaard
gcawlrgjfe307
 
Apache Pulsar in Action MEAP V04 David Kjerrumgaard
biruktresehb
 
Machine Intelligence Guild_ Build ML Enhanced Event Streaming Applications wi...
Timothy Spann
 
Apache Pulsar Seattle - Meetup
Karthik Ramasamy
 
Timothy Spann: Apache Pulsar for ML
Edunomica
 
INTERFACE by apidays 2023 - Leveraging Event Streaming to Super-Charge your B...
apidays
 
PhillyJug Getting Started With Real-time Cloud Native Streaming With Java
Timothy Spann
 
Open keynote_carolyn&matteo&sijie
StreamNative
 
Apache Pulsar Overview
Streamlio
 
The Dream Stream Team for Pulsar and Spring
Timothy Spann
 
Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus
Data Con LA
 
Stream or segment : what is the best way to access your events in Pulsar_Neng
StreamNative
 
Open Source Bristol 30 March 2022
Timothy Spann
 
Pulsar for Kafka People_Jesse anderson
StreamNative
 
Pulsar for Kafka People
Jesse Anderson
 
Music city data Hail Hydrate! from stream to lake
Timothy Spann
 
What We Learned From Building a Modern Messaging and Streaming System for Cloud
StreamNative
 
Ad

More from StreamNative (20)

PDF
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
StreamNative
 
PDF
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
 
PDF
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
StreamNative
 
PDF
Distributed Database Design Decisions to Support High Performance Event Strea...
StreamNative
 
PDF
Simplify Pulsar Functions Development with SQL - Pulsar Summit SF 2022
StreamNative
 
PDF
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
StreamNative
 
PDF
Validating Apache Pulsar’s Behavior under Failure Conditions - Pulsar Summit ...
StreamNative
 
PDF
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
StreamNative
 
PDF
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
StreamNative
 
PDF
Unlocking the Power of Lakehouse Architectures with Apache Pulsar and Apache ...
StreamNative
 
PDF
Understanding Broker Load Balancing - Pulsar Summit SF 2022
StreamNative
 
PDF
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
 
PDF
Pulsar's Journey in Yahoo!: On-prem, Cloud and Hybrid - Pulsar Summit SF 2022
StreamNative
 
PDF
Event-Driven Applications Done Right - Pulsar Summit SF 2022
StreamNative
 
PDF
Pulsar @ Scale. 200M RPM and 1K instances - Pulsar Summit SF 2022
StreamNative
 
PDF
Data Democracy: Journey to User-Facing Analytics - Pulsar Summit SF 2022
StreamNative
 
PDF
Beam + Pulsar: Powerful Stream Processing at Scale - Pulsar Summit SF 2022
StreamNative
 
PDF
Welcome and Opening Remarks - Pulsar Summit SF 2022
StreamNative
 
PDF
Log System As Backbone – How We Built the World’s Most Advanced Vector Databa...
StreamNative
 
PDF
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
StreamNative
 
Is Using KoP (Kafka-on-Pulsar) a Good Idea? - Pulsar Summit SF 2022
StreamNative
 
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
 
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
StreamNative
 
Distributed Database Design Decisions to Support High Performance Event Strea...
StreamNative
 
Simplify Pulsar Functions Development with SQL - Pulsar Summit SF 2022
StreamNative
 
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
StreamNative
 
Validating Apache Pulsar’s Behavior under Failure Conditions - Pulsar Summit ...
StreamNative
 
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
StreamNative
 
Message Redelivery: An Unexpected Journey - Pulsar Summit SF 2022
StreamNative
 
Unlocking the Power of Lakehouse Architectures with Apache Pulsar and Apache ...
StreamNative
 
Understanding Broker Load Balancing - Pulsar Summit SF 2022
StreamNative
 
Building an Asynchronous Application Framework with Python and Pulsar - Pulsa...
StreamNative
 
Pulsar's Journey in Yahoo!: On-prem, Cloud and Hybrid - Pulsar Summit SF 2022
StreamNative
 
Event-Driven Applications Done Right - Pulsar Summit SF 2022
StreamNative
 
Pulsar @ Scale. 200M RPM and 1K instances - Pulsar Summit SF 2022
StreamNative
 
Data Democracy: Journey to User-Facing Analytics - Pulsar Summit SF 2022
StreamNative
 
Beam + Pulsar: Powerful Stream Processing at Scale - Pulsar Summit SF 2022
StreamNative
 
Welcome and Opening Remarks - Pulsar Summit SF 2022
StreamNative
 
Log System As Backbone – How We Built the World’s Most Advanced Vector Databa...
StreamNative
 
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
StreamNative
 
Ad

Recently uploaded (20)

PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
Merits and Demerits of DBMS over File System & 3-Tier Architecture in DBMS
MD RIZWAN MOLLA
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PDF
Early_Diabetes_Detection_using_Machine_L.pdf
maria879693
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPT
Data base management system Transactions.ppt
gandhamcharan2006
 
PPTX
GenAI-Introduction-to-Copilot-for-Bing-March-2025-FOR-HUB.pptx
cleydsonborges1
 
PDF
List of all the AI prompt cheat codes.pdf
Avijit Kumar Roy
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PPTX
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
PPTX
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
PPTX
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
PDF
Choosing the Right Database for Indexing.pdf
Tamanna
 
PPTX
recruitment Presentation.pptxhdhshhshshhehh
devraj40467
 
PDF
WEF_Future_of_Global_Fintech_Second_Edition_2025.pdf
AproximacionAlFuturo
 
PDF
How to Connect Your On-Premises Site to AWS Using Site-to-Site VPN.pdf
Tamanna
 
PPTX
The _Operations_on_Functions_Addition subtruction Multiplication and Division...
mdregaspi24
 
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
Merits and Demerits of DBMS over File System & 3-Tier Architecture in DBMS
MD RIZWAN MOLLA
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
Early_Diabetes_Detection_using_Machine_L.pdf
maria879693
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
Data base management system Transactions.ppt
gandhamcharan2006
 
GenAI-Introduction-to-Copilot-for-Bing-March-2025-FOR-HUB.pptx
cleydsonborges1
 
List of all the AI prompt cheat codes.pdf
Avijit Kumar Roy
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
Choosing the Right Database for Indexing.pdf
Tamanna
 
recruitment Presentation.pptxhdhshhshshhehh
devraj40467
 
WEF_Future_of_Global_Fintech_Second_Edition_2025.pdf
AproximacionAlFuturo
 
How to Connect Your On-Premises Site to AWS Using Site-to-Site VPN.pdf
Tamanna
 
The _Operations_on_Functions_Addition subtruction Multiplication and Division...
mdregaspi24
 
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 

Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robert van Mölken

  • 1. Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing (CQRS)
  • 2. Who am I? Ten reasons to choose Apache Pulsar 2 Robert van Mölken Solution Architect / Developer Blockchain / IoT / Cloud Apps Groundbreaker Ambassador Author two books including: Blockchain across Oracle Linkedin: linkedin.com/in/rvmolken Blog: technology.vanmolken.nl Twitter: @robertvanmolken
  • 3. Ten reasons to choose Apache Pulsar over Apache Kafka For Event Sourcing (CQRS) Apache Pulsar for Event Sourcing 3 TOPICS TO COVER What is Event Sourcing and CQRS Common problems with Kafka-based projects Introducing our ‘friend’, Pulsar Reasons why Pulsar should be your #1 pick
  • 4. What is Event Sourcing and CQRS
  • 5. • Event sourcing uses event-centric approach to persistence business object states. • A business object is persisted by storing a sequence of state changing events. • Whenever an object’s state changes, a new event is appended to the sequence of events. • An app stores an object by persisting its state changing events. Each event would contain sufficient data to reconstruct the object’s state by many different applications. What is Event Sourcing and CQRS Apache Pulsar for Event Sourcing 5 Event Sourcing
  • 6. • Architectural design pattern for developing software whereby writing and reading data are separate responsibilities • The bits of the system that are responsible for changing the system’s state are physically separated from the bits of the system that manage views • In constast, a traditional CRUD architecture is implemented by the same component • It has the responsibility for both reads (the views) and the writes (the state changes) What is Event Sourcing and CQRS (Cont.) Apache Pulsar for Event Sourcing 6 CQRS Command and Query Responsibility Segregation
  • 7. Why use Event Sourcing and CQRS? Apache Pulsar for Event Sourcing 7
  • 8. Common problems with Kafka-based projects
  • 9. Common problems with Kafka-based projects Apache Pulsar for Event Sourcing 9 Source: https://jack-vanlightly.com/sketches/2018/10/2/kafka-vs-pulsar-rebalancing-sketch
  • 10. Common problems with Kafka-based projects (Cont.) • Scaling Kafka is difficult due to the way Kafka stores data within the broker as distributed logs that stores as messaging persistence store • Changing partition sizes to allow more storage can mess the message order by conflicting the message indexes, but for CQRS order is most important • Must plan and calculate number of brokers, topics, partitions and replicas in first place to avoid scaling problems • Cluster rebalancing can impact performance of connected producers and consumers. Brokers must synchronize state from others that contain replicas of its partitions. • No native authorization on events/commands and no native event analyzer tool (you would for example need Apache Spark or Heron) • Kafka’s geo replication mechanism is notoriously problematic, even within just two data centers, resulting in delayed data delivery or complete loss of data Apache Pulsar for Event Sourcing 10
  • 11. Apache Pulsar for Event Sourcing 11 Let’s talk about our “friend”, Pulsar
  • 12. What is Apache Pulsar? Apache Pulsar for Event Sourcing 12 Apache Pulsar is an open source pub-sub messaging platform backed by durable storage (Apache Bookkeeper) with the following cool features:
  • 13. Apache Pulsar for Event Sourcing 13
  • 14. Apache Pulsar for Event Sourcing 14 #1 Streaming and Queing come together • Kafka is a event streaming platform (only) • It implements the concept of topics • Pub/sub system, permanent storage, processing event streams, Avro message validation shema • Based on a distributed commit log • Capable of handling trillions of events a day Kafka • Pulsar started as message queing platform, but can also handle high-rate real-time (event sourcing) use case • It implements the concept of topics • Pub/sub, distributed + cold storage, event processing, and multiple message validation schemas (incl. AVRO, JSON, raw) • And standard message queuing patterns • Competing consumers, fail-over subscriptions, and message fan out • Based on distributed legder / log segments Pulsar
  • 15. Apache Pulsar for Event Sourcing 15 #2 Logs versus distributed ledgers Kafka logs are append-only and sequential, so data can be written to and extracted from them quickly But simple logs can get you into trouble when they get large – storage, scale up / out, replication …
  • 16. Pulsar avoids the problem of copying large logs by breaking the log into segments. It distributes those segments across multiple servers while the data is being written by using BookKeeper as its storage layer Apache Pulsar for Event Sourcing 16 #2 Logs versus distributed ledgers For event sourcing and CQRS it is important to distribute events quickly to all consumers even when loads get high!
  • 17. Apache Pulsar for Event Sourcing 17 #2 Logs versus distributed ledgers
  • 18. With Pulsar tiered storage you can automatically push old messages into practically infinite, cheap cloud storage and retrieve them just like you do those newer, fresh messages Apache Pulsar for Event Sourcing 18 #3 Tiered Storage (plus for Event Sourcing) For event sourcing it is important to be able to replay messages that already been consumed. For example when the application got an unexpected exception or you build a new application. So keeping then forever! Sounds great right?
  • 19. #3 Tiered Storage (plus for Event Sourcing) Apache Pulsar for Event Sourcing 19 Plus for ES/CQRS: New tenants (bookkeepers) can easily sync data and consumers can easily get all events via same API without difference
  • 20. Apache Pulsar for Event Sourcing 20 #4 Stateful vs Stateless brokers • Kafka uses stateful brokers • Every broker contains the complete log for each of its partitions. • If a broker fails, the work can’t be taken over by just any broker. Also when load is getting to high • Brokers must synchronize state from other brokers that contain replicas of its partitions. • Syncing large logs takes time to distribute Kafka • Pulsar uses stateless brokers • Pulsar holds state, but just not in the broker • Brokering of data is separated from storing • Brokers accept data (from producers) • Brokers send data (to consumers) • Data is separate stored in BookKeeper • If load gets high can easily add a new broker • No data to load so starts immediately • Plus for ES/CQRS: always garantee data is available to consumer in real-time (in high load) Pulsar
  • 21. Apache Pulsar for Event Sourcing 21 Source: https://www.xenonstack.com/ #4 Stateful vs Stateless brokers Plus for ES/CQRS: Always garantee data is available to consumer in real-time (e.g. in high load)
  • 22. In Pulsar Type safety is paramount in communication between the producer and the consumer. For safety in messaging, pulsar adopted both client-side as server-side schema/message validation. Apache Pulsar for Event Sourcing 22 #5 Schema registry and message validation For CQRS it is important that clients send only (known) commands that can be validated. Kafka only support message validation using AVRO schemas. Additionally, messages need to be encoded and decoded in code
  • 23. #5 Schema registry and message validation - how it works? • Pulsar schema is applied and enforced at the topic level. Producers and consumers upload schemas to pulsar are asked to conform to the following: • The Pulsar schema message consists of : • Name: name is the topic to which the schema is applied. • Type: the schema format • Schema: binary representation of the schema. • User-defined properties as a string/string map • It supports the following schema payload formats in: • JSON • Protobuf • Avro • string (used for UTF-8-encoded lines) • raw bytes (if no schema is defined) Apache Pulsar for Event Sourcing 23 { "name": "test-string-schema", "type": "STRING", "schema": "", "properties": {} }
  • 24. 5 more reasons to choice Pulsar Apache Pulsar for Event Sourcing 24