SlideShare a Scribd company logo
Hello, Kafka!
(An Introduction to Apache Kafka)
Timothy Spann - Principal DataFlow Field Engineer
July-2021
https://www.meetup.com/futureofdata-boston/
@PaasDev
Hello, kafka! (an introduction to apache kafka)
© 2021 Cloudera, Inc. All rights reserved. 3
Welcome to Future of Data - Virtual - 15/July/2021
@PaasDev
https://www.meetup.com/futureofdata-princeton/
https://www.meetup.com/futureofdata-newyork/
https://www.meetup.com/futureofdata-philadelphia/
https://www.meetup.com/futureofdata-boston/
From Big Data to AI to Streaming to Containers to
Cloud to Analytics to Cloud Storage to Fast Data to
Machine Learning to Microservices to ...
© 2021 Cloudera, Inc. All rights reserved. 4
https://github.com/tspannhw https://www.datainmotion.dev/
© 2021 Cloudera, Inc. All rights reserved. 5
© 2021 Cloudera, Inc. All rights reserved. 6
CLOUDERA DATAFLOW DATA-IN-MOTION PLATFORM
© 2021 Cloudera, Inc. All rights reserved. 7
AGENDA
● What is Event Streaming?
● What is Apache Kafka?
● What Can You Do With Apache Kafka?
● An Introduction to Apache Kafka
● Demos
● Q&A
● RaïŹ„e
● Closing Remarks
© 2021 Cloudera, Inc. All rights reserved. 8
What is Event Streaming?
Events are data points that are delivered in a stream.
In Event Streaming we work with data in motion often from systems that continuously
produce data such as logs, IIoT devices, distributed applications, live orders, CDC from
production databases, stock data, temperature, weather feeds, sensors, time series data and
more.
Events have data and various timestamps that let us know things like creation date/time,
processing date/time and more.
https://en.wikipedia.org/wiki/Event-driven_architecture
© 2021 Cloudera, Inc. All rights reserved. 9
What is Event Streaming?
OVERVIEW
A comprehensive edge-to-cloud
real-time streaming data platform.
Cloudera Dataflow (CDF) is a scalable, real-time streaming data platform that ingests, curates, and analyzes data for key
insights and immediate actionable intelligence. DataFlow addresses the following challenges:
● Processing real-time data streaming at high volume and high scale
● Tracking data provenance and lineage of streaming data
● Managing and monitoring edge applications and streaming sources
● Gaining real-time insights and actionable intelligence from streaming data
© 2021 Cloudera, Inc. All rights reserved. 10
WHAT IS REAL-TIME?
© 2021 Cloudera, Inc. All rights reserved. 11
What is Apache Kafka?
– Distributed: horizontally scalable (just like Hadoop!)
– Partitioned: the data is split-up and distributed across the brokers
– Replicated: allows for automatic failover
– Unique: Kafka does not track the consumption of messages (the consumers
do)
– Fast: designed from the ground up with a focus on performance and
throughput
– Kafka was built at Linkedin in 2011
– Open sourced as an Apache project
© 2021 Cloudera, Inc. All rights reserved. 12
Yes, Franz, It’s Kafka
Let’s do a metamorphosis on your data. Don’t fear changing data.
You don’t need to be a brilliant writer to stream
data.
Franz Kafka was a German-speaking
Bohemian novelist and short-story writer,
widely regarded as one of the major figures of
20th-century literature. His work fuses
elements of realism and the fantastic.
Wikipedia
© 2021 Cloudera, Inc. All rights reserved. 13
What is Can You Do With Apache Kafka?
‱ Web site activity: track page views, searches, etc. in real time
‱ Events & log aggregation: particularly in distributed systems where messages
come from multiple sources
‱ Monitoring and metrics: aggregate statistics from distributed applications and
build a dashboard application
‱ Stream processing: process raw data, clean it up, and forward it on to another
topic or messaging system
‱ Real-time data ingestion: fast processing of a very large volume of messages
© 2021 Cloudera, Inc. All rights reserved. 14
KAFKA TERMINOLOGY
‱ Kafka is a publish/subscribe messaging system comprised of the
following components:
– Topic: a message feed
– Producer: a process that publishes messages to a topic
– Consumer: a process that subscribes to a topic and processes its messages
– Broker: a server in a Kafka cluster
© 2019 Cloudera, Inc. All rights reserved. 15
Apache Kafka
‱ Highly reliable distributed
messaging system
‱ Decouple applications, enables
many-to-many patterns
‱ Publish-Subscribe semantics
‱ Horizontal scalability
‱ EïŹƒcient implementation to
operate at speed with big data
volumes
‱ Organized by topic to support
several use cases
Source
System
Source
System
Source
System
Kafka
Fraud
Detection
Security
Systems
Real-Time
Monitoring
Source
System
Source
System
Source
System
Fraud
Detection
Security
Systems
Real-Time
Monitoring
Many-To-Many
Publish-Subscribe
Point-To-Point
Request-Response
© 2021 Cloudera, Inc. All rights reserved. 16
KAFKA COMPONENTS
Kafka Cluster
producer
producer
producer
consumer
consumer
consumer
brokers
Kafka uses ZooKeeper to coordinate
brokers with consumers
Kafka: Anatomy of a Topic
Partition 0 Partition 1 Partition 2
0 0 0
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10
11 11
12
Writes
Old
New
APACHE
KAFKA
Kafka: Under the Hood
Broker 1
Topic-1
Partition-0
Zookeeper
Stores Information about cluster
status and consumer offsets
APACHE
KAFKA
Broker 2
Topic-1
Partition-1
Broker 3
Topic-1
Partition-2
producer
consumer
Kafka
Cluster
producer
consumer
consumer
Kafka Basics
Kafka has 4 core APIs
1. Producer API
2. Consumer API
3. Streams API
4. Connector API
Anatomy of a Kafka Topic
Kafka Consumers
© 2021 Cloudera, Inc. All rights reserved. 20
OVERVIEW OF TOPICS
‱ A topic is a name assigned to a feed to which messages are published
– A topic in Kafka is partitioned
‱ Each partition is an ordered, immutable sequence of messages
– it is continually appended to
– each message is assigned a sequential id called an offset
‱ Messages are retained for a conïŹgurable amount of time (24 hours, 7
days, etc.)
‱ Each consumer retains its own offset in the partition
– allows the consumer to go back and re-read messages without retaining the
message
– the offset is the only metadata that the consumer retains
– different consumers maintain their own offset
© 2021 Cloudera, Inc. All rights reserved. 21
PUBLISHING MESSAGES
producer
message_a
message_b
message_c
message_d
message_e
message_f
1. A producer publishes messages to a topic
2. The producer decides which
partition to send each message to
offset -> 0 1 2 3 4
Partition 0 message_b message_f
Partition 1 message_a message_c message_
e
Partition 2 message_d
Old New
3. New messages are written to the
end of the partition
consumer
4. A consumer fetches messages from a
partition by specifying an offset
© 2021 Cloudera, Inc. All rights reserved. 22
LEADER AND FOLLOWERS
Broker 1
my_topic
Partition-1 (follower)
Broker 2
my_topic
Partition-1 (leader)
Broker 3
my_topic
Partition-1 (follower)
producer
consumer
producer
consumer
consumer
The leader handles all
read and write requests
© 2021 Cloudera, Inc. All rights reserved. 23
CONSUMING MESSAGES
‱ Messages are consumed in Kafka by a consumer group
‱ Each individual consumer is labeled with a group name
‱ Each message in a topic is sent to one consumer in the group
‱ In other words, messages are consumed at the group level, not at the individual
consumer level
– This allows for fault tolerance and scalability of consumers
‱ This design allows for both queue and publish-subscribe models:
– If you need a queue behavior, then simply place all consumers into the same group
– If you need a publish-subscribe model, then create multiple consumer groups that
subscribe to a topic
© 2021 Cloudera, Inc. All rights reserved. 24
CONSUMER GROUPS
Kafka Cluster
Broker 1
my_topic: Partition-0
my_topic: Partition-3
Broker 2
my_topic: Partition-1
my_topic: Partition-2
Consumer Group A
consumer consumer
consumer consumer
Consumer Group B
consumer consumer
consumer consumer
consumer
message_1
Each message is
consumed by one
consumer per
group
© 2021 Cloudera, Inc. All rights reserved. 25
THE CONSUMER OFFSET
It is up to the consumer to maintain its offset in the partition (stored in a
special topic named __consumer_offsets)
0 1 2 3 4 5 6 7 8 9 10 11 12
Messages a b c d e f g h i j
‱ This has several key benefits, including:
‱ performance: there is no back-and-forth acknowledging of message consumption
‱ simplicity: the consumer only has to maintain a single integer value for its state, which can
be easily stored and shared between consumers (if a failure occurs)
‱ re-consume messages: it becomes trivial for a consumer to re-consume messages
consumer
offset
© 2021 Cloudera, Inc. All rights reserved. 26
MESSAGE DELIVERY GUARANTEES
‱ Kafka guarantees at-least-once delivery by default
‱ At-most-once delivery is possibly by disabling retries on the producer (when a
commit fails)
‱ Exactly-once delivery is possible (with clever coordination of your consumers and
the consumer offset)
‱ Other guarantees:
– Messages in a partition are stored in the order that they were sent by the publisher
– Each partition is consumed by exactly one consumer in the group
– That consumer is the only reader in the group of that partition in the group
– Messages are consumed in order
– Messages committed to the log are not lost for up to N-1 broker failures
© 2021 Cloudera, Inc. All rights reserved. 27
IN-SYNC REPLICAS
‱ Kafka replicates the messages in each partition across multiple brokers
‱ New messages are always appended to the leader
‱ A follower that keeps up is called an ISR, or in-sync replica, which means:
‱ A message is considered committed when all ISRs have a copy of the
message
How does Kafka preserve message order
⏹ Partition algorithm is ïŹxed (hash on key)
⏹ Stored as a log sequential write to a ïŹle
⏹ Consume in order based on offset
How does Kafka prevent data loss
⏹ Replicate, replicate, replicate
⏹ Acknowledge you got the message
⏹ Keep it even after it is consumed
© 2021 Cloudera, Inc. All rights reserved. 30
AT-MOST-ONCE
© 2021 Cloudera, Inc. All rights reserved. 31
AT-LEAST-ONCE
© 2021 Cloudera, Inc. All rights reserved. 32
EXACTLY-ONCE
© 2021 Cloudera, Inc. All rights reserved. 33
Demo Time
Produce Messages
Consume Messages
View Messages in SMM
Show Details of Brokers, Topics, Consumer Groups, Producers, Partitions
© 2021 Cloudera, Inc. All rights reserved. 34
Download these assets today
© 2021 Cloudera, Inc. All rights reserved. 35
TH N Y U

More Related Content

What's hot (20)

PPTX
APACHE KAFKA / Kafka Connect / Kafka Streams
Ketan Gote
 
PDF
Introduction to apache kafka
Dimitris Kontokostas
 
PPTX
Apache Kafka
emreakis
 
PDF
Apache kafka
NexThoughts Technologies
 
PPTX
kafka
Amikam Snir
 
PDF
Introduction to Apache Kafka
Shiao-An Yuan
 
ODP
Stream processing using Kafka
Knoldus Inc.
 
PDF
Apache Kafka Architecture & Fundamentals Explained
confluent
 
PPTX
Apache kafka
Viswanath J
 
PDF
Apache Kafka - Martin Podval
Martin Podval
 
PPTX
Introduction to Kafka Cruise Control
Jiangjie Qin
 
PDF
Kafka 101 and Developer Best Practices
confluent
 
PDF
Apache Kafka Introduction
Amita Mirajkar
 
PPTX
Apache Kafka
Saroj Panyasrivanit
 
PPTX
Apache Kafka - Overview
CodeOps Technologies LLP
 
PDF
From Zero to Hero with Kafka Connect
confluent
 
PDF
Kafka Streams: What it is, and how to use it?
confluent
 
PPTX
Introduction to Apache Kafka
AIMDek Technologies
 
PDF
Benefits of Stream Processing and Apache Kafka Use Cases
confluent
 
APACHE KAFKA / Kafka Connect / Kafka Streams
Ketan Gote
 
Introduction to apache kafka
Dimitris Kontokostas
 
Apache Kafka
emreakis
 
Apache kafka
NexThoughts Technologies
 
kafka
Amikam Snir
 
Introduction to Apache Kafka
Shiao-An Yuan
 
Stream processing using Kafka
Knoldus Inc.
 
Apache Kafka Architecture & Fundamentals Explained
confluent
 
Apache kafka
Viswanath J
 
Apache Kafka - Martin Podval
Martin Podval
 
Introduction to Kafka Cruise Control
Jiangjie Qin
 
Kafka 101 and Developer Best Practices
confluent
 
Apache Kafka Introduction
Amita Mirajkar
 
Apache Kafka
Saroj Panyasrivanit
 
Apache Kafka - Overview
CodeOps Technologies LLP
 
From Zero to Hero with Kafka Connect
confluent
 
Kafka Streams: What it is, and how to use it?
confluent
 
Introduction to Apache Kafka
AIMDek Technologies
 
Benefits of Stream Processing and Apache Kafka Use Cases
confluent
 

Similar to Hello, kafka! (an introduction to apache kafka) (20)

PPTX
Session 23 - Kafka and Zookeeper
AnandMHadoop
 
PDF
Introduction_to_Kafka - A brief Overview.pdf
ssuserc49ec4
 
PDF
Unlocking the Power of Apache Kafka: How Kafka Listeners Facilitate Real-time...
Denodo
 
PDF
Apache Kafka
Worapol Alex Pongpech, PhD
 
PPTX
Kafka RealTime Streaming
Viyaan Jhiingade
 
PDF
Budapest Data/ML - Building Modern Data Streaming Apps with NiFi, Flink and K...
Timothy Spann
 
PPTX
Apache kafka
Janu Jahnavi
 
PDF
Apache kafka
Janu Jahnavi
 
PPTX
Apache kafka
Ramakrishna kapa
 
PPTX
Connecting mq&kafka
Matt Leming
 
PDF
Apache Kafka - Strakin Technologies Pvt Ltd
Strakin Technologies Pvt Ltd
 
PDF
ITPC Building Modern Data Streaming Apps
Timothy Spann
 
PPTX
Cloud native Kafka | Sascha Holtbruegge and Margaretha Erber, HiveMQ
HostedbyConfluent
 
PPTX
Apache kafka
Srikrishna k
 
PPTX
Kafka for DBAs
Gwen (Chen) Shapira
 
PPTX
Decoupling Decisions with Apache Kafka
Grant Henke
 
PDF
GSJUG: Mastering Data Streaming Pipelines 09May2023
Timothy Spann
 
PDF
apachekafka-160907180205.pdf
TarekHamdi8
 
PPTX
Apache kafka
Srikrishna k
 
PPTX
Kafka tutorial
Srikrishna k
 
Session 23 - Kafka and Zookeeper
AnandMHadoop
 
Introduction_to_Kafka - A brief Overview.pdf
ssuserc49ec4
 
Unlocking the Power of Apache Kafka: How Kafka Listeners Facilitate Real-time...
Denodo
 
Kafka RealTime Streaming
Viyaan Jhiingade
 
Budapest Data/ML - Building Modern Data Streaming Apps with NiFi, Flink and K...
Timothy Spann
 
Apache kafka
Janu Jahnavi
 
Apache kafka
Janu Jahnavi
 
Apache kafka
Ramakrishna kapa
 
Connecting mq&kafka
Matt Leming
 
Apache Kafka - Strakin Technologies Pvt Ltd
Strakin Technologies Pvt Ltd
 
ITPC Building Modern Data Streaming Apps
Timothy Spann
 
Cloud native Kafka | Sascha Holtbruegge and Margaretha Erber, HiveMQ
HostedbyConfluent
 
Apache kafka
Srikrishna k
 
Kafka for DBAs
Gwen (Chen) Shapira
 
Decoupling Decisions with Apache Kafka
Grant Henke
 
GSJUG: Mastering Data Streaming Pipelines 09May2023
Timothy Spann
 
apachekafka-160907180205.pdf
TarekHamdi8
 
Apache kafka
Srikrishna k
 
Kafka tutorial
Srikrishna k
 
Ad

More from Timothy Spann (20)

PDF
14May2025_TSPANN_FromAirQualityUnstructuredData.pdf
Timothy Spann
 
PDF
Streaming AI Pipelines with Apache NiFi and Snowflake NYC 2025
Timothy Spann
 
PDF
2025-03-03-Philly-AAAI-GoodData-Build Secure RAG Apps With Open LLM
Timothy Spann
 
PDF
Conf42_IoT_Dec2024_Building IoT Applications With Open Source
Timothy Spann
 
PDF
2024 Dec 05 - PyData Global - Tutorial Its In The Air Tonight
Timothy Spann
 
PDF
2024Nov20-BigDataEU-RealTimeAIWithOpenSource
Timothy Spann
 
PDF
TSPANN-2024-Nov-CloudX-Adding Generative AI to Real-Time Streaming Pipelines
Timothy Spann
 
PDF
2024-Nov-BuildStuff-Adding Generative AI to Real-Time Streaming Pipelines
Timothy Spann
 
PDF
14 November 2024 - Conf 42 - Prompt Engineering - Codeless Generative AI Pipe...
Timothy Spann
 
PDF
2024 Nov 05 - Linux Foundation TAC TALK With Milvus
Timothy Spann
 
PPTX
tspann06-NOV-2024_AI-Alliance_NYC_ intro to Data Prep Kit and Open Source RAG
Timothy Spann
 
PDF
tspann08-Nov-2024_PyDataNYC_Unstructured Data Processing with a Raspberry Pi ...
Timothy Spann
 
PDF
2024-10-28 All Things Open - Advanced Retrieval Augmented Generation (RAG) Te...
Timothy Spann
 
PDF
10-25-2024_BITS_NYC_Unstructured Data and LLM_ What, Why and How
Timothy Spann
 
PDF
2024-OCT-23 NYC Meetup - Unstructured Data Meetup - Unstructured Halloween
Timothy Spann
 
PDF
DBTA Round Table with Zilliz and Airbyte - Unstructured Data Engineering
Timothy Spann
 
PDF
17-October-2024 NYC AI Camp - Step-by-Step RAG 101
Timothy Spann
 
PDF
11-OCT-2024_AI_101_CryptoOracle_UnstructuredData
Timothy Spann
 
PDF
2024-10-04 - Grace Hopper Celebration Open Source Day - Stefan
Timothy Spann
 
PDF
01-Oct-2024_PES-VectorDatabasesAndAI.pdf
Timothy Spann
 
14May2025_TSPANN_FromAirQualityUnstructuredData.pdf
Timothy Spann
 
Streaming AI Pipelines with Apache NiFi and Snowflake NYC 2025
Timothy Spann
 
2025-03-03-Philly-AAAI-GoodData-Build Secure RAG Apps With Open LLM
Timothy Spann
 
Conf42_IoT_Dec2024_Building IoT Applications With Open Source
Timothy Spann
 
2024 Dec 05 - PyData Global - Tutorial Its In The Air Tonight
Timothy Spann
 
2024Nov20-BigDataEU-RealTimeAIWithOpenSource
Timothy Spann
 
TSPANN-2024-Nov-CloudX-Adding Generative AI to Real-Time Streaming Pipelines
Timothy Spann
 
2024-Nov-BuildStuff-Adding Generative AI to Real-Time Streaming Pipelines
Timothy Spann
 
14 November 2024 - Conf 42 - Prompt Engineering - Codeless Generative AI Pipe...
Timothy Spann
 
2024 Nov 05 - Linux Foundation TAC TALK With Milvus
Timothy Spann
 
tspann06-NOV-2024_AI-Alliance_NYC_ intro to Data Prep Kit and Open Source RAG
Timothy Spann
 
tspann08-Nov-2024_PyDataNYC_Unstructured Data Processing with a Raspberry Pi ...
Timothy Spann
 
2024-10-28 All Things Open - Advanced Retrieval Augmented Generation (RAG) Te...
Timothy Spann
 
10-25-2024_BITS_NYC_Unstructured Data and LLM_ What, Why and How
Timothy Spann
 
2024-OCT-23 NYC Meetup - Unstructured Data Meetup - Unstructured Halloween
Timothy Spann
 
DBTA Round Table with Zilliz and Airbyte - Unstructured Data Engineering
Timothy Spann
 
17-October-2024 NYC AI Camp - Step-by-Step RAG 101
Timothy Spann
 
11-OCT-2024_AI_101_CryptoOracle_UnstructuredData
Timothy Spann
 
2024-10-04 - Grace Hopper Celebration Open Source Day - Stefan
Timothy Spann
 
01-Oct-2024_PES-VectorDatabasesAndAI.pdf
Timothy Spann
 
Ad

Recently uploaded (20)

PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Tally software_Introduction_Presentation
AditiBansal54083
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 

Hello, kafka! (an introduction to apache kafka)

  • 1. Hello, Kafka! (An Introduction to Apache Kafka) Timothy Spann - Principal DataFlow Field Engineer July-2021 https://www.meetup.com/futureofdata-boston/ @PaasDev
  • 3. © 2021 Cloudera, Inc. All rights reserved. 3 Welcome to Future of Data - Virtual - 15/July/2021 @PaasDev https://www.meetup.com/futureofdata-princeton/ https://www.meetup.com/futureofdata-newyork/ https://www.meetup.com/futureofdata-philadelphia/ https://www.meetup.com/futureofdata-boston/ From Big Data to AI to Streaming to Containers to Cloud to Analytics to Cloud Storage to Fast Data to Machine Learning to Microservices to ...
  • 4. © 2021 Cloudera, Inc. All rights reserved. 4 https://github.com/tspannhw https://www.datainmotion.dev/
  • 5. © 2021 Cloudera, Inc. All rights reserved. 5
  • 6. © 2021 Cloudera, Inc. All rights reserved. 6 CLOUDERA DATAFLOW DATA-IN-MOTION PLATFORM
  • 7. © 2021 Cloudera, Inc. All rights reserved. 7 AGENDA ● What is Event Streaming? ● What is Apache Kafka? ● What Can You Do With Apache Kafka? ● An Introduction to Apache Kafka ● Demos ● Q&A ● RaïŹ„e ● Closing Remarks
  • 8. © 2021 Cloudera, Inc. All rights reserved. 8 What is Event Streaming? Events are data points that are delivered in a stream. In Event Streaming we work with data in motion often from systems that continuously produce data such as logs, IIoT devices, distributed applications, live orders, CDC from production databases, stock data, temperature, weather feeds, sensors, time series data and more. Events have data and various timestamps that let us know things like creation date/time, processing date/time and more. https://en.wikipedia.org/wiki/Event-driven_architecture
  • 9. © 2021 Cloudera, Inc. All rights reserved. 9 What is Event Streaming? OVERVIEW A comprehensive edge-to-cloud real-time streaming data platform. Cloudera Dataflow (CDF) is a scalable, real-time streaming data platform that ingests, curates, and analyzes data for key insights and immediate actionable intelligence. DataFlow addresses the following challenges: ● Processing real-time data streaming at high volume and high scale ● Tracking data provenance and lineage of streaming data ● Managing and monitoring edge applications and streaming sources ● Gaining real-time insights and actionable intelligence from streaming data
  • 10. © 2021 Cloudera, Inc. All rights reserved. 10 WHAT IS REAL-TIME?
  • 11. © 2021 Cloudera, Inc. All rights reserved. 11 What is Apache Kafka? – Distributed: horizontally scalable (just like Hadoop!) – Partitioned: the data is split-up and distributed across the brokers – Replicated: allows for automatic failover – Unique: Kafka does not track the consumption of messages (the consumers do) – Fast: designed from the ground up with a focus on performance and throughput – Kafka was built at Linkedin in 2011 – Open sourced as an Apache project
  • 12. © 2021 Cloudera, Inc. All rights reserved. 12 Yes, Franz, It’s Kafka Let’s do a metamorphosis on your data. Don’t fear changing data. You don’t need to be a brilliant writer to stream data. Franz Kafka was a German-speaking Bohemian novelist and short-story writer, widely regarded as one of the major figures of 20th-century literature. His work fuses elements of realism and the fantastic. Wikipedia
  • 13. © 2021 Cloudera, Inc. All rights reserved. 13 What is Can You Do With Apache Kafka? ‱ Web site activity: track page views, searches, etc. in real time ‱ Events & log aggregation: particularly in distributed systems where messages come from multiple sources ‱ Monitoring and metrics: aggregate statistics from distributed applications and build a dashboard application ‱ Stream processing: process raw data, clean it up, and forward it on to another topic or messaging system ‱ Real-time data ingestion: fast processing of a very large volume of messages
  • 14. © 2021 Cloudera, Inc. All rights reserved. 14 KAFKA TERMINOLOGY ‱ Kafka is a publish/subscribe messaging system comprised of the following components: – Topic: a message feed – Producer: a process that publishes messages to a topic – Consumer: a process that subscribes to a topic and processes its messages – Broker: a server in a Kafka cluster
  • 15. © 2019 Cloudera, Inc. All rights reserved. 15 Apache Kafka ‱ Highly reliable distributed messaging system ‱ Decouple applications, enables many-to-many patterns ‱ Publish-Subscribe semantics ‱ Horizontal scalability ‱ EïŹƒcient implementation to operate at speed with big data volumes ‱ Organized by topic to support several use cases Source System Source System Source System Kafka Fraud Detection Security Systems Real-Time Monitoring Source System Source System Source System Fraud Detection Security Systems Real-Time Monitoring Many-To-Many Publish-Subscribe Point-To-Point Request-Response
  • 16. © 2021 Cloudera, Inc. All rights reserved. 16 KAFKA COMPONENTS Kafka Cluster producer producer producer consumer consumer consumer brokers Kafka uses ZooKeeper to coordinate brokers with consumers
  • 17. Kafka: Anatomy of a Topic Partition 0 Partition 1 Partition 2 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 11 11 12 Writes Old New APACHE KAFKA
  • 18. Kafka: Under the Hood Broker 1 Topic-1 Partition-0 Zookeeper Stores Information about cluster status and consumer offsets APACHE KAFKA Broker 2 Topic-1 Partition-1 Broker 3 Topic-1 Partition-2 producer consumer Kafka Cluster producer consumer consumer
  • 19. Kafka Basics Kafka has 4 core APIs 1. Producer API 2. Consumer API 3. Streams API 4. Connector API Anatomy of a Kafka Topic Kafka Consumers
  • 20. © 2021 Cloudera, Inc. All rights reserved. 20 OVERVIEW OF TOPICS ‱ A topic is a name assigned to a feed to which messages are published – A topic in Kafka is partitioned ‱ Each partition is an ordered, immutable sequence of messages – it is continually appended to – each message is assigned a sequential id called an offset ‱ Messages are retained for a conïŹgurable amount of time (24 hours, 7 days, etc.) ‱ Each consumer retains its own offset in the partition – allows the consumer to go back and re-read messages without retaining the message – the offset is the only metadata that the consumer retains – different consumers maintain their own offset
  • 21. © 2021 Cloudera, Inc. All rights reserved. 21 PUBLISHING MESSAGES producer message_a message_b message_c message_d message_e message_f 1. A producer publishes messages to a topic 2. The producer decides which partition to send each message to offset -> 0 1 2 3 4 Partition 0 message_b message_f Partition 1 message_a message_c message_ e Partition 2 message_d Old New 3. New messages are written to the end of the partition consumer 4. A consumer fetches messages from a partition by specifying an offset
  • 22. © 2021 Cloudera, Inc. All rights reserved. 22 LEADER AND FOLLOWERS Broker 1 my_topic Partition-1 (follower) Broker 2 my_topic Partition-1 (leader) Broker 3 my_topic Partition-1 (follower) producer consumer producer consumer consumer The leader handles all read and write requests
  • 23. © 2021 Cloudera, Inc. All rights reserved. 23 CONSUMING MESSAGES ‱ Messages are consumed in Kafka by a consumer group ‱ Each individual consumer is labeled with a group name ‱ Each message in a topic is sent to one consumer in the group ‱ In other words, messages are consumed at the group level, not at the individual consumer level – This allows for fault tolerance and scalability of consumers ‱ This design allows for both queue and publish-subscribe models: – If you need a queue behavior, then simply place all consumers into the same group – If you need a publish-subscribe model, then create multiple consumer groups that subscribe to a topic
  • 24. © 2021 Cloudera, Inc. All rights reserved. 24 CONSUMER GROUPS Kafka Cluster Broker 1 my_topic: Partition-0 my_topic: Partition-3 Broker 2 my_topic: Partition-1 my_topic: Partition-2 Consumer Group A consumer consumer consumer consumer Consumer Group B consumer consumer consumer consumer consumer message_1 Each message is consumed by one consumer per group
  • 25. © 2021 Cloudera, Inc. All rights reserved. 25 THE CONSUMER OFFSET It is up to the consumer to maintain its offset in the partition (stored in a special topic named __consumer_offsets) 0 1 2 3 4 5 6 7 8 9 10 11 12 Messages a b c d e f g h i j ‱ This has several key benefits, including: ‱ performance: there is no back-and-forth acknowledging of message consumption ‱ simplicity: the consumer only has to maintain a single integer value for its state, which can be easily stored and shared between consumers (if a failure occurs) ‱ re-consume messages: it becomes trivial for a consumer to re-consume messages consumer offset
  • 26. © 2021 Cloudera, Inc. All rights reserved. 26 MESSAGE DELIVERY GUARANTEES ‱ Kafka guarantees at-least-once delivery by default ‱ At-most-once delivery is possibly by disabling retries on the producer (when a commit fails) ‱ Exactly-once delivery is possible (with clever coordination of your consumers and the consumer offset) ‱ Other guarantees: – Messages in a partition are stored in the order that they were sent by the publisher – Each partition is consumed by exactly one consumer in the group – That consumer is the only reader in the group of that partition in the group – Messages are consumed in order – Messages committed to the log are not lost for up to N-1 broker failures
  • 27. © 2021 Cloudera, Inc. All rights reserved. 27 IN-SYNC REPLICAS ‱ Kafka replicates the messages in each partition across multiple brokers ‱ New messages are always appended to the leader ‱ A follower that keeps up is called an ISR, or in-sync replica, which means: ‱ A message is considered committed when all ISRs have a copy of the message
  • 28. How does Kafka preserve message order ⏹ Partition algorithm is ïŹxed (hash on key) ⏹ Stored as a log sequential write to a ïŹle ⏹ Consume in order based on offset
  • 29. How does Kafka prevent data loss ⏹ Replicate, replicate, replicate ⏹ Acknowledge you got the message ⏹ Keep it even after it is consumed
  • 30. © 2021 Cloudera, Inc. All rights reserved. 30 AT-MOST-ONCE
  • 31. © 2021 Cloudera, Inc. All rights reserved. 31 AT-LEAST-ONCE
  • 32. © 2021 Cloudera, Inc. All rights reserved. 32 EXACTLY-ONCE
  • 33. © 2021 Cloudera, Inc. All rights reserved. 33 Demo Time Produce Messages Consume Messages View Messages in SMM Show Details of Brokers, Topics, Consumer Groups, Producers, Partitions
  • 34. © 2021 Cloudera, Inc. All rights reserved. 34 Download these assets today
  • 35. © 2021 Cloudera, Inc. All rights reserved. 35 TH N Y U