SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Pulsar For Kafka People
1 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Introducing Pulsar
Architectures
API and Programming Differences
Use Cases
Pulsar For Kafka People
2 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Apache Pulsar is a distributed
event streaming system
Apache Pulsar
• It uses a distributed log to
durably store messages
• Pulsar was originally created
at Yahoo
• Open sourced in 2016
• Graduated to a top-level
Apache project in 2018
3 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Kafka is a distributed publish
subscribe system
Apache Kafka
• It uses a commit log to track
changes
• Kafka was originally created
at LinkedIn
• Open sourced in 2011
• Graduated to a top-level
Apache project in 2012
4 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Introducing Pulsar
Architectures
API and Programming Differences
Use Cases
Pulsar For Kafka People
5 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Basic Kafka Architecture
Publisher SubscriberKafka
Publisher sends data and
doesn't know about the
subscribers or their status.
Subscriber recieves data from
publisher and never directly
interacts with it.
All interactions go through
Kafka and it handles all
communication.
6 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Basic Pulsar Architecture
Producer ConsumerPulsar
Producers do not directly
interact with the BookKeeper
cluster.
Consumers do not directly
interact with the BookKeeper
cluster.
All Brokers in the Pulsar
cluster are stateless and can
be scaled independently.
BookKeeper All Bookies in the BookKeeper
cluster are stateful and can
be scaled independently.
7 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Kafka Partitions
Producer 0
Data is divided into partitions.
Partitions are both logical
and physical divisions.
Producer 1
Topic
Partition 0 Partition 1 Partition 2
All data is sent and received
on topics. Topics group like
data together.
8 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Pulsar Ledgers
The individual messages that
are produced are stored as
records in the ledger.
Stream
Ledger 1 Ledger 2 Ledger 3
Record 1 Record 2 Record 3 Record 4
Each topic has it's own stream
and all data for a topic
is stored in it.
As more data is added to a
topic, new ledgers are
allocated to store the data.
9 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Kafka Consumers
Producer 0
Consumer recieves data from
all topic partitions and connects
to brokers 0, 1, and 2.
Producer 1
Broker 0 Broker 1 Broker 2
Topic
Partition 0 Partition 1 Partition 2
Consumer (P012)
10 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Pulsar Subscriptions
Producer 0
In failover, all partitions are
consumed by one consumer and
will fail over to hot spare on fail.
Producer 1
Broker 0 Broker 1 Broker 2
Topic
Partition 0 Partition 1 Partition 2
Failover Sub. (P012)
Shared Sub. (P012)
In shared, messages are
sent in a round robin way to
all consumers.
Shared Sub. (P012)
Key Shared (P012)
Key Shared (P012)
Failover Sub. (P)
In key shared, messages with
the same key are consistently
routed to the same consumer.
11 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Introducing Pulsar
Architectures
API and Programming Differences
Use Cases
Pulsar For Kafka People
12 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import static org.apache.kafka.clients.producer.ProducerConfig.*;
Properties props = new Properties();
// Configure brokers to connect to
props.put(BOOTSTRAP_SERVERS_CONFIG, "broker1:9092");
// Create a producer with the key as a string and value as a string
KafkaProducer<String, String> producer = new KafkaProducer<>(props,
new StringSerializer(), new StringSerializer());
// Create ProducerRecord and send it
String key = "mykey";
String value = "myvalue";
ProducerRecord<String, String> record = new
ProducerRecord<>("hello_topic", key, value);
producer.send(record);
producer.close();
Kafka Producer API
13 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
PulsarClient client = PulsarClient.builder()
.serviceUrl("pulsar://broker1:6650")
.build();
// Create a producer that will send values as strings
// Default is byte[]
Producer<String> producer = client
.newProducer(Schema.STRING)
.topic("hellotopic")
.create();
// Create a new message, send it, and block until it is
// acknowledged
producer.newMessage()
.key("mykey")
.value("myvalue")
.send();
// Create a new message, send it, and don't block until it is
// acknowledged
producer.newMessage()
.key("mykey2")
.value("myvalue2")
.sendAsync();
// Close producer and client
producer.close();
client.close();
Pulsar Producer API
14 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import static org.apache.kafka.clients.consumer.ConsumerConfig.*;
@SuppressWarnings("unused")
public class HelloConsumer {
KafkaConsumer<String, String> consumer;
public void createConsumer() {
String topic = "hello_topic";
Properties props = new Properties();
// Configure initial location bootstrap servers
props.put(BOOTSTRAP_SERVERS_CONFIG, "broker1:9092");
// Configure consumer group
props.put(GROUP_ID_CONFIG, "group1");
// Create the consumer with the key as a string and value as a string
consumer = new KafkaConsumer<>(props, new StringDeserializer(),
new StringDeserializer());
Kafka Consumer API (1/2)
15 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
consumer.subscribe(Arrays.asList(topic));
while (true) {
// Poll for ConsumerRecords for a certain amount of time
ConsumerRecords<String, String> records = consumer.poll(
Duration.ofMillis(100));
// Process the ConsumerRecords, if any, that came back
for (ConsumerRecord<String, String> record : records) {
String key = record.key();
String value = record.value();
// Do something with message
}
}
}
public void close() {
consumer.close();
}
public static void main(String[] args) {
HelloConsumer consumer = new HelloConsumer();
consumer.createConsumer();
consumer.close();
}
Kafka Consumer API (2/2)
16 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
client = PulsarClient.builder()
.serviceUrl("pulsar://broker1:6650")
.build();
String myTopic = "hellotopic";
String mySubscriptionName = "my-subscription";
// Create a consumer that will receive values as strings
// Default is byte[]
consumer = client.newConsumer(Schema.STRING)
.topic(myTopic)
.subscriptionName(mySubscriptionName)
.subscribe();
while (true) {
// Block and wait until a single message is available
Message<String> message = consumer.receive();
try {
// Do something with the message
System.out.println("Key is "" + message.getKey()
+ "" value is "" + message.getValue()
+ """);
// Acknowledge the message so that it can be
// deleted by the message broker
consumer.acknowledgeCumulative(message);
} catch (Exception e) {
// Message failed to process, redeliver later
consumer.negativeAcknowledge(message);
}
}
Pulsar Consumer API
17 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Both projects have an ecosystem
associated with them
Ecosystem
Projects
• Kafka Streams -> Pulsar
Functions
• KSQLDB (prop) -> Pulsar SQL
• Kafka Connect -> Pulsar IO
• Kafka API compatibility for
Pulsar
18 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Introducing Pulsar
Architectures
API and Programming Differences
Use Cases
Pulsar For Kafka People
19 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Kafka++
All Kafka use cases plus
more
20 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Work Queues
http://tiny.bdi.io/workqueues
21 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Geo-Replication
Built-in geo-replication
22 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Unified
Do both MQ-style and
Pub/Sub-style with the
same cluster
23 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Lots of Topics
Supports millions of topics
24 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
Thank You
bigdatainstitute.io
25 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9

Weitere ähnliche Inhalte

Was ist angesagt?

Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Alex Maclinovsky
 

Was ist angesagt? (20)

Microservices with Netflix OSS and Spring Cloud
Microservices with Netflix OSS and Spring CloudMicroservices with Netflix OSS and Spring Cloud
Microservices with Netflix OSS and Spring Cloud
 
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes
 Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes
 
Monitoring Docker Containers with Metricbeat, Elasticsearch, and Kibana
Monitoring Docker Containers with Metricbeat, Elasticsearch, and KibanaMonitoring Docker Containers with Metricbeat, Elasticsearch, and Kibana
Monitoring Docker Containers with Metricbeat, Elasticsearch, and Kibana
 
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
 
OpenStack 101 Technical Overview
OpenStack 101 Technical OverviewOpenStack 101 Technical Overview
OpenStack 101 Technical Overview
 
Hands-on Lab: Migrating Oracle to PostgreSQL
Hands-on Lab: Migrating Oracle to PostgreSQL Hands-on Lab: Migrating Oracle to PostgreSQL
Hands-on Lab: Migrating Oracle to PostgreSQL
 
Building IAM for OpenStack
Building IAM for OpenStackBuilding IAM for OpenStack
Building IAM for OpenStack
 
How to scheduled jobs in a cloudera cluster without oozie
How to scheduled jobs in a cloudera cluster without oozieHow to scheduled jobs in a cloudera cluster without oozie
How to scheduled jobs in a cloudera cluster without oozie
 
reModernize-Updating and Consolidating MySQL
reModernize-Updating and Consolidating MySQLreModernize-Updating and Consolidating MySQL
reModernize-Updating and Consolidating MySQL
 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 Instead
 
Hands-on Lab: Comparing Redis with Relational
Hands-on Lab: Comparing Redis with RelationalHands-on Lab: Comparing Redis with Relational
Hands-on Lab: Comparing Redis with Relational
 
Building Microservices with Spring Cloud and Netflix OSS
Building Microservices with Spring Cloud and Netflix OSSBuilding Microservices with Spring Cloud and Netflix OSS
Building Microservices with Spring Cloud and Netflix OSS
 
Processing messages in a sqs with lambda function
Processing messages in a sqs with lambda functionProcessing messages in a sqs with lambda function
Processing messages in a sqs with lambda function
 
5 things you don't know about Amazon Web Services
5 things you don't know about Amazon Web Services5 things you don't know about Amazon Web Services
5 things you don't know about Amazon Web Services
 
Cloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudCloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring Cloud
 
Hands-on Lab - Combaring Redis with Relational
Hands-on Lab - Combaring Redis with RelationalHands-on Lab - Combaring Redis with Relational
Hands-on Lab - Combaring Redis with Relational
 
Introduction to OpenStack Architecture (Grizzly Edition)
Introduction to OpenStack Architecture (Grizzly Edition)Introduction to OpenStack Architecture (Grizzly Edition)
Introduction to OpenStack Architecture (Grizzly Edition)
 
Virtual private cloud fundamentals
Virtual private cloud fundamentalsVirtual private cloud fundamentals
Virtual private cloud fundamentals
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
Aws object storage and cdn(s3, glacier and cloud front) part 2
Aws object storage and cdn(s3, glacier and cloud front)   part 2Aws object storage and cdn(s3, glacier and cloud front)   part 2
Aws object storage and cdn(s3, glacier and cloud front) part 2
 

Ähnlich wie Pulsar for Kafka People

Cracking wpa2 psk in the cloud
Cracking wpa2 psk in the cloudCracking wpa2 psk in the cloud
Cracking wpa2 psk in the cloud
Fotios Lindiakos
 
Spark Streaming Info
Spark Streaming InfoSpark Streaming Info
Spark Streaming Info
Doug Chang
 
Fast Streaming into Clickhouse with Apache Pulsar
Fast Streaming into Clickhouse with Apache PulsarFast Streaming into Clickhouse with Apache Pulsar
Fast Streaming into Clickhouse with Apache Pulsar
Timothy Spann
 

Ähnlich wie Pulsar for Kafka People (20)

Developing Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache KafkaDeveloping Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache Kafka
 
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
 
mastering libcurl part 1
mastering libcurl part 1mastering libcurl part 1
mastering libcurl part 1
 
Apache Kafka - Strakin Technologies Pvt Ltd
Apache Kafka - Strakin Technologies Pvt LtdApache Kafka - Strakin Technologies Pvt Ltd
Apache Kafka - Strakin Technologies Pvt Ltd
 
Mqtt 5 meetup dortmund
Mqtt 5 meetup dortmundMqtt 5 meetup dortmund
Mqtt 5 meetup dortmund
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
Publishing AwsLlambda Logs Into SplunkCloud
Publishing AwsLlambda Logs Into SplunkCloudPublishing AwsLlambda Logs Into SplunkCloud
Publishing AwsLlambda Logs Into SplunkCloud
 
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
 
KAFKA Quickstart
KAFKA QuickstartKAFKA Quickstart
KAFKA Quickstart
 
Python networking
Python networkingPython networking
Python networking
 
Iot hub agent
Iot hub agentIot hub agent
Iot hub agent
 
Cracking wpa2 psk in the cloud
Cracking wpa2 psk in the cloudCracking wpa2 psk in the cloud
Cracking wpa2 psk in the cloud
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101
 
Docker at Flux7
Docker at Flux7Docker at Flux7
Docker at Flux7
 
Spark Streaming Info
Spark Streaming InfoSpark Streaming Info
Spark Streaming Info
 
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
EWD 3 Training Course Part 6: What Happens when a QEWD Application is StartedEWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
 
Enhancing Apache Kafka for Large Scale Real-Time Data Pipeline at Tencent | K...
Enhancing Apache Kafka for Large Scale Real-Time Data Pipeline at Tencent | K...Enhancing Apache Kafka for Large Scale Real-Time Data Pipeline at Tencent | K...
Enhancing Apache Kafka for Large Scale Real-Time Data Pipeline at Tencent | K...
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptx
 
Fast Streaming into Clickhouse with Apache Pulsar
Fast Streaming into Clickhouse with Apache PulsarFast Streaming into Clickhouse with Apache Pulsar
Fast Streaming into Clickhouse with Apache Pulsar
 
Fast Insight from Fast Data: Integrating ClickHouse and Apache Kafka
Fast Insight from Fast Data: Integrating ClickHouse and Apache KafkaFast Insight from Fast Data: Integrating ClickHouse and Apache Kafka
Fast Insight from Fast Data: Integrating ClickHouse and Apache Kafka
 

Mehr von Jesse Anderson

Strata 2012 Million Monkeys
Strata 2012 Million MonkeysStrata 2012 Million Monkeys
Strata 2012 Million Monkeys
Jesse Anderson
 

Mehr von Jesse Anderson (13)

Managing Real-Time Data Teams
Managing Real-Time Data TeamsManaging Real-Time Data Teams
Managing Real-Time Data Teams
 
Big Data and Analytics in the COVID-19 Era
Big Data and Analytics in the COVID-19 EraBig Data and Analytics in the COVID-19 Era
Big Data and Analytics in the COVID-19 Era
 
Working Together As Data Teams V1
Working Together As Data Teams V1Working Together As Data Teams V1
Working Together As Data Teams V1
 
What Does an Exec Need to About Architecture and Why
What Does an Exec Need to About Architecture and WhyWhat Does an Exec Need to About Architecture and Why
What Does an Exec Need to About Architecture and Why
 
The Five Dysfunctions of a Data Engineering Team
The Five Dysfunctions of a Data Engineering TeamThe Five Dysfunctions of a Data Engineering Team
The Five Dysfunctions of a Data Engineering Team
 
HBaseCon 2014-Just the Basics
HBaseCon 2014-Just the BasicsHBaseCon 2014-Just the Basics
HBaseCon 2014-Just the Basics
 
Million Monkeys User Group
Million Monkeys User GroupMillion Monkeys User Group
Million Monkeys User Group
 
Strata 2012 Million Monkeys
Strata 2012 Million MonkeysStrata 2012 Million Monkeys
Strata 2012 Million Monkeys
 
EC2 Performance, Spot Instance ROI and EMR Scalability
EC2 Performance, Spot Instance ROI and EMR ScalabilityEC2 Performance, Spot Instance ROI and EMR Scalability
EC2 Performance, Spot Instance ROI and EMR Scalability
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Why Use MVC?
Why Use MVC?Why Use MVC?
Why Use MVC?
 
How to Use MVC
How to Use MVCHow to Use MVC
How to Use MVC
 
Introduction to Android
Introduction to AndroidIntroduction to Android
Introduction to Android
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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)
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 

Pulsar for Kafka People

  • 1. Pulsar For Kafka People 1 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 2. Introducing Pulsar Architectures API and Programming Differences Use Cases Pulsar For Kafka People 2 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 3. Apache Pulsar is a distributed event streaming system Apache Pulsar • It uses a distributed log to durably store messages • Pulsar was originally created at Yahoo • Open sourced in 2016 • Graduated to a top-level Apache project in 2018 3 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 4. Kafka is a distributed publish subscribe system Apache Kafka • It uses a commit log to track changes • Kafka was originally created at LinkedIn • Open sourced in 2011 • Graduated to a top-level Apache project in 2012 4 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 5. Introducing Pulsar Architectures API and Programming Differences Use Cases Pulsar For Kafka People 5 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 6. Basic Kafka Architecture Publisher SubscriberKafka Publisher sends data and doesn't know about the subscribers or their status. Subscriber recieves data from publisher and never directly interacts with it. All interactions go through Kafka and it handles all communication. 6 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 7. Basic Pulsar Architecture Producer ConsumerPulsar Producers do not directly interact with the BookKeeper cluster. Consumers do not directly interact with the BookKeeper cluster. All Brokers in the Pulsar cluster are stateless and can be scaled independently. BookKeeper All Bookies in the BookKeeper cluster are stateful and can be scaled independently. 7 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 8. Kafka Partitions Producer 0 Data is divided into partitions. Partitions are both logical and physical divisions. Producer 1 Topic Partition 0 Partition 1 Partition 2 All data is sent and received on topics. Topics group like data together. 8 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 9. Pulsar Ledgers The individual messages that are produced are stored as records in the ledger. Stream Ledger 1 Ledger 2 Ledger 3 Record 1 Record 2 Record 3 Record 4 Each topic has it's own stream and all data for a topic is stored in it. As more data is added to a topic, new ledgers are allocated to store the data. 9 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 10. Kafka Consumers Producer 0 Consumer recieves data from all topic partitions and connects to brokers 0, 1, and 2. Producer 1 Broker 0 Broker 1 Broker 2 Topic Partition 0 Partition 1 Partition 2 Consumer (P012) 10 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 11. Pulsar Subscriptions Producer 0 In failover, all partitions are consumed by one consumer and will fail over to hot spare on fail. Producer 1 Broker 0 Broker 1 Broker 2 Topic Partition 0 Partition 1 Partition 2 Failover Sub. (P012) Shared Sub. (P012) In shared, messages are sent in a round robin way to all consumers. Shared Sub. (P012) Key Shared (P012) Key Shared (P012) Failover Sub. (P) In key shared, messages with the same key are consistently routed to the same consumer. 11 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 12. Introducing Pulsar Architectures API and Programming Differences Use Cases Pulsar For Kafka People 12 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 13. import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; import static org.apache.kafka.clients.producer.ProducerConfig.*; Properties props = new Properties(); // Configure brokers to connect to props.put(BOOTSTRAP_SERVERS_CONFIG, "broker1:9092"); // Create a producer with the key as a string and value as a string KafkaProducer<String, String> producer = new KafkaProducer<>(props, new StringSerializer(), new StringSerializer()); // Create ProducerRecord and send it String key = "mykey"; String value = "myvalue"; ProducerRecord<String, String> record = new ProducerRecord<>("hello_topic", key, value); producer.send(record); producer.close(); Kafka Producer API 13 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 14. PulsarClient client = PulsarClient.builder() .serviceUrl("pulsar://broker1:6650") .build(); // Create a producer that will send values as strings // Default is byte[] Producer<String> producer = client .newProducer(Schema.STRING) .topic("hellotopic") .create(); // Create a new message, send it, and block until it is // acknowledged producer.newMessage() .key("mykey") .value("myvalue") .send(); // Create a new message, send it, and don't block until it is // acknowledged producer.newMessage() .key("mykey2") .value("myvalue2") .sendAsync(); // Close producer and client producer.close(); client.close(); Pulsar Producer API 14 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 15. import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; import static org.apache.kafka.clients.consumer.ConsumerConfig.*; @SuppressWarnings("unused") public class HelloConsumer { KafkaConsumer<String, String> consumer; public void createConsumer() { String topic = "hello_topic"; Properties props = new Properties(); // Configure initial location bootstrap servers props.put(BOOTSTRAP_SERVERS_CONFIG, "broker1:9092"); // Configure consumer group props.put(GROUP_ID_CONFIG, "group1"); // Create the consumer with the key as a string and value as a string consumer = new KafkaConsumer<>(props, new StringDeserializer(), new StringDeserializer()); Kafka Consumer API (1/2) 15 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 16. consumer.subscribe(Arrays.asList(topic)); while (true) { // Poll for ConsumerRecords for a certain amount of time ConsumerRecords<String, String> records = consumer.poll( Duration.ofMillis(100)); // Process the ConsumerRecords, if any, that came back for (ConsumerRecord<String, String> record : records) { String key = record.key(); String value = record.value(); // Do something with message } } } public void close() { consumer.close(); } public static void main(String[] args) { HelloConsumer consumer = new HelloConsumer(); consumer.createConsumer(); consumer.close(); } Kafka Consumer API (2/2) 16 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 17. client = PulsarClient.builder() .serviceUrl("pulsar://broker1:6650") .build(); String myTopic = "hellotopic"; String mySubscriptionName = "my-subscription"; // Create a consumer that will receive values as strings // Default is byte[] consumer = client.newConsumer(Schema.STRING) .topic(myTopic) .subscriptionName(mySubscriptionName) .subscribe(); while (true) { // Block and wait until a single message is available Message<String> message = consumer.receive(); try { // Do something with the message System.out.println("Key is "" + message.getKey() + "" value is "" + message.getValue() + """); // Acknowledge the message so that it can be // deleted by the message broker consumer.acknowledgeCumulative(message); } catch (Exception e) { // Message failed to process, redeliver later consumer.negativeAcknowledge(message); } } Pulsar Consumer API 17 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 18. Both projects have an ecosystem associated with them Ecosystem Projects • Kafka Streams -> Pulsar Functions • KSQLDB (prop) -> Pulsar SQL • Kafka Connect -> Pulsar IO • Kafka API compatibility for Pulsar 18 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 19. Introducing Pulsar Architectures API and Programming Differences Use Cases Pulsar For Kafka People 19 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 20. Kafka++ All Kafka use cases plus more 20 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 21. Work Queues http://tiny.bdi.io/workqueues 21 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 22. Geo-Replication Built-in geo-replication 22 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 23. Unified Do both MQ-style and Pub/Sub-style with the same cluster 23 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 24. Lots of Topics Supports millions of topics 24 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9
  • 25. Thank You bigdatainstitute.io 25 / 25Copyright © 2020 Smoking Hand LLC. All rights Reserved. Version: 82982da9