SlideShare a Scribd company logo
Big, Fast, Easy Data:
Distributed stream processing
for everyone with KSQL
The Streaming SQL Engine for Apache Kafka
Michael G. Noll, Confluent
@miguno
Founded by the creators
of Apache Kafka
Technology Developed
while at LinkedIn
Largest Contributor and
tester of Apache Kafka
• Founded in 2014
• Raised $84M from Benchmark, Index, Sequoia
• Transacting in 20 countries
• Commercial entities in US, UK, Germany, Australia
Apache Kafka Databases
SQLStream Processing
Booked hotel, flight Ordered a taxi
Chatted with friends
Listened to musicPaid money
Played a video game
Read a newspaper <add your example>
Billing Information
Purchases
Geolocation Updates
And more such data
STREAMS of
customer data
(continuously flowing)
TABLE of
customer profiles
(continuously updated)
Motivating example
KSQLis the
Streaming
SQL Engine
for
Apache Kafka
5+5
KSQL is the Easiest Way to Process with Kafka
Kafka
(data)
KSQL
(processing)
read,
write
network
All you need is Kafka – no complex deployments of
bespoke systems for stream processing!
CREATE STREAM
CREATE TABLE
SELECT
…and more…
KSQL is the Easiest Way to Process with Kafka
Runs
Everywhere
Elastic, Scalable,
Fault-Tolerant,
Distributed, S/M/L/XL
Powerful Processing incl.
Filters, Transforms, Joins,
Aggregations, Windowing
Supports Streams
and Tables
Free and
Open Source
Kafka Security
Integration
Event-Time
Processing
Zero Programming
in Java, Scala
0
Exactly-Once
Processing
Stream processing with Kafka
Example: Using Kafka’s Streams API for writing
elastic, scalable, fault-tolerant Java and Scala applications
Main
Logic
Stream processing with Kafka
CREATE STREAM fraudulent_payments AS
SELECT * FROM payments
WHERE fraudProbability > 0.8;
Same example, now with KSQL.
Not a single line of Java or Scala code needed.
Easier, faster workflow
write code in
package app
run app
write (K)SQL
Java or Scala
ksql>
Kafka Streams API KSQL
…
(1 or many instances)
Interactive KSQL usage
ksql> POST /query
CLI REST API1 3UI2
KSQL REST API example
POST /query HTTP/1.1
{
"ksql": "SELECT * FROM users WHERE name LIKE ‘a%’;"
"streamsProperties": {
"your.custom.setting": "value"
}
}
Here: run a query and stream back the results
KSQL
are some
what
use cases?
10+5
KSQL for Data Exploration
SELECT page, user_id, status, bytes
FROM clickstream
WHERE user_agent LIKE 'Mozilla%';
An easy way to inspect data in Kafka
SHOW TOPICS;
PRINT 'my-topic' FROM BEGINNING;
KSQL for Data Enrichment
CREATE STREAM enriched_payments AS
SELECT payment_id, u.country, total
FROM payments_stream p
LEFT JOIN users_table u
ON p.user_id = u.user_id;
Join data from a variety of sources to see the full picture
1 Stream-table join
KSQL for Streaming ETL
CREATE STREAM clicks_from_vip_users AS
SELECT user_id, u.country, page, action
FROM clickstream c
LEFT JOIN users u ON c.user_id = u.user_id
WHERE u.level ='Platinum';
Filter, cleanse, process data while it is moving
KSQL for Anomaly Detection
CREATE TABLE possible_fraud AS
SELECT card_number, COUNT(*)
FROM authorization_attempts
WINDOW TUMBLING (SIZE 30 SECONDS)
GROUP BY card_number
HAVING COUNT(*) > 3;
Aggregate data to identify patterns or anomalies in real-time
2 … per 30sec windows
1 Aggregate data
KSQL for Real-Time Monitoring
CREATE TABLE failing_vehicles AS
SELECT vehicle, COUNT(*)
FROM vehicle_telemetry_stream
WINDOW TUMBLING (SIZE 1 MINUTE)
WHERE event_type = 'ERROR’
GROUP BY vehicle
HAVING COUNT(*) >= 3;
Derive insights from events (IoT, sensors, etc.) and turn them into actions
KSQL for Data Transformation
CREATE STREAM clicks_by_user_id
WITH (PARTITIONS=6,
TIMESTAMP='view_time’
VALUE_FORMAT='JSON') AS
SELECT * FROM clickstream
PARTITION BY user_id;
Quickly make derivations of existing data in Kafka
1 Re-partition the data
2 Convert data to JSON
Where is KSQL not such a great fit?
BI reports
• Because no indexes
• No JDBC (most BI tools are not good
with continuous results!)
Ad-hoc queries
• Because no indexes
to facilitate efficient
random lookups on
arbitrary record fields
KSQL
does
How
work?
15+7
Shoulders of Streaming Giants
Consumer,
Producer
KSQL
Kafka Streams
powers
powers
Flexibility
Ease of Use
CREATE STREAM, CREATE TABLE,
SELECT, JOIN, GROUP BY, SUM, …
KStream, KTable,
filter(), map(), flatMap(),
join(), aggregate(), …
subscribe(), poll(), send(),
flush(), beginTransaction(), …
Shoulders of Streaming Giants
CREATE STREAM fraudulent_payments AS
SELECT * FROM payments
WHERE fraudProbability > 0.8;
KSQL
Kafka
Streams
$ ksql-server-start
KSQL Architecture
KSQL
Engine
REST
API
Processing happens here,
powered by Kafka Streams
ksql>
Programmatic access from
Go, Python, .NET, Java,
JavaScript, …
UI
CLI
KSQL Server (JVM process)
Physical
…
Runs Everywhere, Viable for S/M/L/XL Use Cases
Physical
…and many more…
KSQL Architecture
Kafka
(your data)
KSQL
read,
write
…
More KSQL
…
FraudTeam
…
MobileTeam
KSQLCluster
Servers form a
Kafka consumer group
to process data
collaboratively
network
KSQL Interactive Usage
Start 1+ KSQL servers
$ ksql-server-start
Interact with
KSQL CLI, UI, etc.
$ ksql http://ksql-server:8088
ksql>
REST API
KSQL Headless, Non-Interactive Usage
$ ksql-server-start --queries-file application.sql
ksql>
Typically version
controlled for auditing,
rollbacks, etc.
REST API
disabled
Start 1+ KSQL servers with .sql file containing pre-defined queries.
Example Journey from Idea to Production
Interactive KSQL
for development and testing
Headless KSQL
for Production
Desired KSQL queries
have been identified
and vetted
REST
“Hmm, let me try
out this idea...”
Stream-Table
The
Duality
22+15
Stream-Table Duality
CREATE STREAM enriched_payments AS
SELECT payment_id, u.country, total
FROM payments_stream p
LEFT JOIN users_table u
ON p.user_id = u.user_id;
CREATE TABLE failing_vehicles AS
SELECT vehicle, COUNT(*)
FROM vehicle_monitoring_stream
WINDOW TUMBLING (SIZE 1 MINUTE)
WHERE event_type = 'ERROR’
GROUP BY vehicle
HAVING COUNT(*) >= 3;
Stream Table
(from previous slides)
Do you think that’s a table you are querying ?
Stream Table
Stream-Table Duality
Alice 1
Alice 1
Charlie 5
Alice 3
Charlie 5
(Alice, 1)
(Charlie, 5)
(Alice, 3)
Alice 1
Alice 1
Charlie 5
Alice 3
Charlie 5
Table
https://www.confluent.io/blog/introducing-kafka-streams-stream-processing-made-simple/
https://www.michael-noll.com/blog/2018/04/05/of-stream-and-tables-in-kafka-and-stream-processing-part1/
Stream-Table Duality
CREATE TABLE current_location_per_user
WITH (KAFKA_TOPIC='input-topic’, ...);
This is actually an animation, but the
PDF format does not support this.
Stream-Table Duality
CREATE TABLE current_location_per_user
WITH (KAFKA_TOPIC='input-topic’, ...);
This is actually an animation, but the
PDF format does not support this.
Stream-Table Duality
CREATE TABLE visited_locations_per_user AS
SELECT username, COUNT(*)
FROM location_updates
GROUP BY username;
This is actually an animation, but the
PDF format does not support this.
Stream-Table Duality
CREATE TABLE visited_locations_per_user AS
SELECT username, COUNT(*)
FROM location_updates
GROUP BY username;
This is actually an animation, but the
PDF format does not support this.
Stream-Table Duality
aggregation
changelog
“materialized view”
of the stream
(like SUM, COUNT)
Stream Table
(CDC)
Apache Kafka Databases
Stream-Table Duality
How you benefit from this as a KSQL user.
Example: CDC from DB via Kafka to Elastic
customers
Kafka Connect
streams data in
Kafka Connect
streams data out
KSQL processes
table changes
in real-time
Example: Real-time Data Enrichment
Kafka Connect
streams data in
<wherever>
Kafka Connect
streams data out
Devices write
directly via
Kafka API
KSQL joins the stream
and table in real-time
customers
How KSQL itself benefits from this – a closer technical look
Fault-Tolerance, powered by Kafka
Server A:
“I do stateful stream
processing, like tables,
joins, aggregations.”
“streaming
restore” of
A’s local state to BChangelog Topic
“streaming
backup” of
A’s local state
KSQL
Kafka
A key challenge of distributed stream processing is fault-tolerant state.
State is automatically migrated
in case of server failure
Server B:
“I restore the state and
continue processing where
server A stopped.”
Fault-Tolerance, powered by Kafka
Processing fails over automatically, without data loss or miscomputation.
1 Kafka consumer group
rebalance is triggered
2 Processing and state of #3
is migrated via Kafka to
remaining servers #1 + #2
#3 died so #1 and #2 take over
1 Kafka consumer group
rebalance is triggered
2 Part of processing incl.
state is migrated via Kafka
from #1 + #2 to server #3
#3 is back so the work is split again
Elasticity and Scalability, powered by Kafka
You can add, remove, restart servers in KSQL clusters during live operations.
1 Kafka consumer group
rebalance is triggered
2 Part of processing incl.
state is migrated via Kafka
to additional server processes
“We need more processing power!”
Kafka consumer group
rebalance is triggered
1
2 Processing incl. state of
stopped servers is migrated
via Kafka to remaining servers
“Ok, we can scale down again.”
Want to take a deeper dive?
https://kafka.apache.org/documentation/streams/architecture
KSQL is built on top of Kafka Streams:
Read up on Kafka Streams’ architecture
including threading model, elasticity,
fault-tolerance, state stores for stateful
computation, etc. to learn more about how
all this works behind the scenes.
Wrapping up
37
KSQLis the
Streaming
SQL Engine
for
Apache Kafka
KSQL is the Easiest Way to Process with Kafka
Runs
Everywhere
Elastic, Scalable,
Fault-Tolerant,
Distributed, S/M/L/XL
Powerful Processing incl.
Filters, Transforms, Joins,
Aggregations, Windowing
Supports Streams
and Tables
Free and
Open Source
Kafka Security
Integration
Event-Time
Processing
Zero Programming
in Java, Scala
0
Exactly-Once
Processing
Where to go from here
http://confluent.io/ksql
https://slackpass.io/confluentcommunity #ksql
https://github.com/confluentinc/ksql

More Related Content

What's hot (20)

PDF
Kafka streams - From pub/sub to a complete stream processing platform
Paolo Castagna
 
PDF
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
Kai Wähner
 
PDF
Steps to Building a Streaming ETL Pipeline with Apache Kafka® and KSQL
confluent
 
PDF
ksqlDB - Stream Processing simplified!
Guido Schmutz
 
PDF
Real-Time Stream Processing with KSQL and Apache Kafka
confluent
 
PDF
KSQL – An Open Source Streaming Engine for Apache Kafka
Kai Wähner
 
PDF
Crossing the Streams: Rethinking Stream Processing with Kafka Streams and KSQL
confluent
 
PDF
KSQL: Open Source Streaming for Apache Kafka
confluent
 
PDF
Data Driven Enterprise with Apache Kafka
confluent
 
PDF
Dissolving the Problem (Making an ACID-Compliant Database Out of Apache Kafka®)
confluent
 
PDF
Introduction to apache kafka, confluent and why they matter
Paolo Castagna
 
PDF
The State of Stream Processing
confluent
 
PDF
Apache kafka-a distributed streaming platform
confluent
 
PDF
Real-world Streaming Architectures
confluent
 
PPTX
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
Michael Noll
 
PDF
Using Location Data to Showcase Keys, Windows, and Joins in Kafka Streams DSL...
confluent
 
PDF
Introduction to Apache Kafka and Confluent... and why they matter
confluent
 
PPTX
IoT and Event Streaming at Scale with Apache Kafka
confluent
 
PPTX
Exploring KSQL Patterns
confluent
 
PDF
UDF/UDAF: the extensibility framework for KSQL (Hojjat Jafapour, Confluent) K...
confluent
 
Kafka streams - From pub/sub to a complete stream processing platform
Paolo Castagna
 
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
Kai Wähner
 
Steps to Building a Streaming ETL Pipeline with Apache Kafka® and KSQL
confluent
 
ksqlDB - Stream Processing simplified!
Guido Schmutz
 
Real-Time Stream Processing with KSQL and Apache Kafka
confluent
 
KSQL – An Open Source Streaming Engine for Apache Kafka
Kai Wähner
 
Crossing the Streams: Rethinking Stream Processing with Kafka Streams and KSQL
confluent
 
KSQL: Open Source Streaming for Apache Kafka
confluent
 
Data Driven Enterprise with Apache Kafka
confluent
 
Dissolving the Problem (Making an ACID-Compliant Database Out of Apache Kafka®)
confluent
 
Introduction to apache kafka, confluent and why they matter
Paolo Castagna
 
The State of Stream Processing
confluent
 
Apache kafka-a distributed streaming platform
confluent
 
Real-world Streaming Architectures
confluent
 
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
Michael Noll
 
Using Location Data to Showcase Keys, Windows, and Joins in Kafka Streams DSL...
confluent
 
Introduction to Apache Kafka and Confluent... and why they matter
confluent
 
IoT and Event Streaming at Scale with Apache Kafka
confluent
 
Exploring KSQL Patterns
confluent
 
UDF/UDAF: the extensibility framework for KSQL (Hojjat Jafapour, Confluent) K...
confluent
 

Similar to Big, Fast, Easy Data: Distributed Stream Processing for Everyone with KSQL, the Streaming SQL Engine for Apache Kafka (Berlin Buzzwords 2018) (20)

PDF
Building a Real-time Streaming ETL Framework Using ksqlDB and NoSQL
ScyllaDB
 
PPTX
Event streaming webinar feb 2020
Maheedhar Gunturu
 
PDF
APAC ksqlDB Workshop
confluent
 
PDF
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
Kai Wähner
 
PDF
Riviera Jug - 20/03/2018 - KSQL
Florent Ramiere
 
PDF
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
Kai Wähner
 
PDF
Un'introduzione a Kafka Streams e KSQL... and why they matter!
Paolo Castagna
 
PPTX
KSQL and Kafka Streams – When to Use Which, and When to Use Both
confluent
 
PDF
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Codemotion
 
PDF
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Codemotion
 
PPTX
Real Time Stream Processing with KSQL and Kafka
David Peterson
 
PDF
KSQL: The Streaming SQL Engine for Apache Kafka
Chris Mueller
 
PDF
Streaming ETL with Apache Kafka and KSQL
Nick Dearden
 
PDF
ksqlDB Workshop
confluent
 
PDF
KSQL - Stream Processing simplified!
Guido Schmutz
 
PDF
Now You See Me, Now You Compute: Building Event-Driven Architectures with Apa...
Michael Noll
 
PPTX
Webinar: Unlock the Power of Streaming Data with Kinetica and Confluent
Kinetica
 
PDF
ksqlDB: Building Consciousness on Real Time Events
confluent
 
PDF
Big Data LDN 2017: Look Ma, No Code! Building Streaming Data Pipelines With A...
Matt Stubbs
 
PDF
All Streams Ahead! ksqlDB Workshop ANZ
confluent
 
Building a Real-time Streaming ETL Framework Using ksqlDB and NoSQL
ScyllaDB
 
Event streaming webinar feb 2020
Maheedhar Gunturu
 
APAC ksqlDB Workshop
confluent
 
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
Kai Wähner
 
Riviera Jug - 20/03/2018 - KSQL
Florent Ramiere
 
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
Kai Wähner
 
Un'introduzione a Kafka Streams e KSQL... and why they matter!
Paolo Castagna
 
KSQL and Kafka Streams – When to Use Which, and When to Use Both
confluent
 
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Codemotion
 
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Codemotion
 
Real Time Stream Processing with KSQL and Kafka
David Peterson
 
KSQL: The Streaming SQL Engine for Apache Kafka
Chris Mueller
 
Streaming ETL with Apache Kafka and KSQL
Nick Dearden
 
ksqlDB Workshop
confluent
 
KSQL - Stream Processing simplified!
Guido Schmutz
 
Now You See Me, Now You Compute: Building Event-Driven Architectures with Apa...
Michael Noll
 
Webinar: Unlock the Power of Streaming Data with Kinetica and Confluent
Kinetica
 
ksqlDB: Building Consciousness on Real Time Events
confluent
 
Big Data LDN 2017: Look Ma, No Code! Building Streaming Data Pipelines With A...
Matt Stubbs
 
All Streams Ahead! ksqlDB Workshop ANZ
confluent
 
Ad

Recently uploaded (20)

PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PDF
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
PDF
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
PPTX
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna36
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
PDF
Data Retrieval and Preparation Business Analytics.pdf
kayserrakib80
 
PDF
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
PPTX
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
PDF
Research Methodology Overview Introduction
ayeshagul29594
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna36
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
Data Retrieval and Preparation Business Analytics.pdf
kayserrakib80
 
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
Research Methodology Overview Introduction
ayeshagul29594
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
Ad

Big, Fast, Easy Data: Distributed Stream Processing for Everyone with KSQL, the Streaming SQL Engine for Apache Kafka (Berlin Buzzwords 2018)

  • 1. Big, Fast, Easy Data: Distributed stream processing for everyone with KSQL The Streaming SQL Engine for Apache Kafka Michael G. Noll, Confluent @miguno
  • 2. Founded by the creators of Apache Kafka Technology Developed while at LinkedIn Largest Contributor and tester of Apache Kafka • Founded in 2014 • Raised $84M from Benchmark, Index, Sequoia • Transacting in 20 countries • Commercial entities in US, UK, Germany, Australia
  • 4. Booked hotel, flight Ordered a taxi Chatted with friends Listened to musicPaid money Played a video game Read a newspaper <add your example>
  • 5. Billing Information Purchases Geolocation Updates And more such data STREAMS of customer data (continuously flowing) TABLE of customer profiles (continuously updated) Motivating example
  • 7. KSQL is the Easiest Way to Process with Kafka Kafka (data) KSQL (processing) read, write network All you need is Kafka – no complex deployments of bespoke systems for stream processing! CREATE STREAM CREATE TABLE SELECT …and more…
  • 8. KSQL is the Easiest Way to Process with Kafka Runs Everywhere Elastic, Scalable, Fault-Tolerant, Distributed, S/M/L/XL Powerful Processing incl. Filters, Transforms, Joins, Aggregations, Windowing Supports Streams and Tables Free and Open Source Kafka Security Integration Event-Time Processing Zero Programming in Java, Scala 0 Exactly-Once Processing
  • 9. Stream processing with Kafka Example: Using Kafka’s Streams API for writing elastic, scalable, fault-tolerant Java and Scala applications Main Logic
  • 10. Stream processing with Kafka CREATE STREAM fraudulent_payments AS SELECT * FROM payments WHERE fraudProbability > 0.8; Same example, now with KSQL. Not a single line of Java or Scala code needed.
  • 11. Easier, faster workflow write code in package app run app write (K)SQL Java or Scala ksql> Kafka Streams API KSQL … (1 or many instances)
  • 12. Interactive KSQL usage ksql> POST /query CLI REST API1 3UI2
  • 13. KSQL REST API example POST /query HTTP/1.1 { "ksql": "SELECT * FROM users WHERE name LIKE ‘a%’;" "streamsProperties": { "your.custom.setting": "value" } } Here: run a query and stream back the results
  • 15. KSQL for Data Exploration SELECT page, user_id, status, bytes FROM clickstream WHERE user_agent LIKE 'Mozilla%'; An easy way to inspect data in Kafka SHOW TOPICS; PRINT 'my-topic' FROM BEGINNING;
  • 16. KSQL for Data Enrichment CREATE STREAM enriched_payments AS SELECT payment_id, u.country, total FROM payments_stream p LEFT JOIN users_table u ON p.user_id = u.user_id; Join data from a variety of sources to see the full picture 1 Stream-table join
  • 17. KSQL for Streaming ETL CREATE STREAM clicks_from_vip_users AS SELECT user_id, u.country, page, action FROM clickstream c LEFT JOIN users u ON c.user_id = u.user_id WHERE u.level ='Platinum'; Filter, cleanse, process data while it is moving
  • 18. KSQL for Anomaly Detection CREATE TABLE possible_fraud AS SELECT card_number, COUNT(*) FROM authorization_attempts WINDOW TUMBLING (SIZE 30 SECONDS) GROUP BY card_number HAVING COUNT(*) > 3; Aggregate data to identify patterns or anomalies in real-time 2 … per 30sec windows 1 Aggregate data
  • 19. KSQL for Real-Time Monitoring CREATE TABLE failing_vehicles AS SELECT vehicle, COUNT(*) FROM vehicle_telemetry_stream WINDOW TUMBLING (SIZE 1 MINUTE) WHERE event_type = 'ERROR’ GROUP BY vehicle HAVING COUNT(*) >= 3; Derive insights from events (IoT, sensors, etc.) and turn them into actions
  • 20. KSQL for Data Transformation CREATE STREAM clicks_by_user_id WITH (PARTITIONS=6, TIMESTAMP='view_time’ VALUE_FORMAT='JSON') AS SELECT * FROM clickstream PARTITION BY user_id; Quickly make derivations of existing data in Kafka 1 Re-partition the data 2 Convert data to JSON
  • 21. Where is KSQL not such a great fit? BI reports • Because no indexes • No JDBC (most BI tools are not good with continuous results!) Ad-hoc queries • Because no indexes to facilitate efficient random lookups on arbitrary record fields
  • 23. Shoulders of Streaming Giants Consumer, Producer KSQL Kafka Streams powers powers Flexibility Ease of Use CREATE STREAM, CREATE TABLE, SELECT, JOIN, GROUP BY, SUM, … KStream, KTable, filter(), map(), flatMap(), join(), aggregate(), … subscribe(), poll(), send(), flush(), beginTransaction(), …
  • 24. Shoulders of Streaming Giants CREATE STREAM fraudulent_payments AS SELECT * FROM payments WHERE fraudProbability > 0.8; KSQL Kafka Streams
  • 25. $ ksql-server-start KSQL Architecture KSQL Engine REST API Processing happens here, powered by Kafka Streams ksql> Programmatic access from Go, Python, .NET, Java, JavaScript, … UI CLI KSQL Server (JVM process) Physical …
  • 26. Runs Everywhere, Viable for S/M/L/XL Use Cases Physical …and many more…
  • 27. KSQL Architecture Kafka (your data) KSQL read, write … More KSQL … FraudTeam … MobileTeam KSQLCluster Servers form a Kafka consumer group to process data collaboratively network
  • 28. KSQL Interactive Usage Start 1+ KSQL servers $ ksql-server-start Interact with KSQL CLI, UI, etc. $ ksql http://ksql-server:8088 ksql> REST API
  • 29. KSQL Headless, Non-Interactive Usage $ ksql-server-start --queries-file application.sql ksql> Typically version controlled for auditing, rollbacks, etc. REST API disabled Start 1+ KSQL servers with .sql file containing pre-defined queries.
  • 30. Example Journey from Idea to Production Interactive KSQL for development and testing Headless KSQL for Production Desired KSQL queries have been identified and vetted REST “Hmm, let me try out this idea...”
  • 32. Stream-Table Duality CREATE STREAM enriched_payments AS SELECT payment_id, u.country, total FROM payments_stream p LEFT JOIN users_table u ON p.user_id = u.user_id; CREATE TABLE failing_vehicles AS SELECT vehicle, COUNT(*) FROM vehicle_monitoring_stream WINDOW TUMBLING (SIZE 1 MINUTE) WHERE event_type = 'ERROR’ GROUP BY vehicle HAVING COUNT(*) >= 3; Stream Table (from previous slides)
  • 33. Do you think that’s a table you are querying ?
  • 34. Stream Table Stream-Table Duality Alice 1 Alice 1 Charlie 5 Alice 3 Charlie 5 (Alice, 1) (Charlie, 5) (Alice, 3) Alice 1 Alice 1 Charlie 5 Alice 3 Charlie 5 Table https://www.confluent.io/blog/introducing-kafka-streams-stream-processing-made-simple/ https://www.michael-noll.com/blog/2018/04/05/of-stream-and-tables-in-kafka-and-stream-processing-part1/
  • 35. Stream-Table Duality CREATE TABLE current_location_per_user WITH (KAFKA_TOPIC='input-topic’, ...); This is actually an animation, but the PDF format does not support this.
  • 36. Stream-Table Duality CREATE TABLE current_location_per_user WITH (KAFKA_TOPIC='input-topic’, ...); This is actually an animation, but the PDF format does not support this.
  • 37. Stream-Table Duality CREATE TABLE visited_locations_per_user AS SELECT username, COUNT(*) FROM location_updates GROUP BY username; This is actually an animation, but the PDF format does not support this.
  • 38. Stream-Table Duality CREATE TABLE visited_locations_per_user AS SELECT username, COUNT(*) FROM location_updates GROUP BY username; This is actually an animation, but the PDF format does not support this.
  • 39. Stream-Table Duality aggregation changelog “materialized view” of the stream (like SUM, COUNT) Stream Table (CDC)
  • 41. How you benefit from this as a KSQL user.
  • 42. Example: CDC from DB via Kafka to Elastic customers Kafka Connect streams data in Kafka Connect streams data out KSQL processes table changes in real-time
  • 43. Example: Real-time Data Enrichment Kafka Connect streams data in <wherever> Kafka Connect streams data out Devices write directly via Kafka API KSQL joins the stream and table in real-time customers
  • 44. How KSQL itself benefits from this – a closer technical look
  • 45. Fault-Tolerance, powered by Kafka Server A: “I do stateful stream processing, like tables, joins, aggregations.” “streaming restore” of A’s local state to BChangelog Topic “streaming backup” of A’s local state KSQL Kafka A key challenge of distributed stream processing is fault-tolerant state. State is automatically migrated in case of server failure Server B: “I restore the state and continue processing where server A stopped.”
  • 46. Fault-Tolerance, powered by Kafka Processing fails over automatically, without data loss or miscomputation. 1 Kafka consumer group rebalance is triggered 2 Processing and state of #3 is migrated via Kafka to remaining servers #1 + #2 #3 died so #1 and #2 take over 1 Kafka consumer group rebalance is triggered 2 Part of processing incl. state is migrated via Kafka from #1 + #2 to server #3 #3 is back so the work is split again
  • 47. Elasticity and Scalability, powered by Kafka You can add, remove, restart servers in KSQL clusters during live operations. 1 Kafka consumer group rebalance is triggered 2 Part of processing incl. state is migrated via Kafka to additional server processes “We need more processing power!” Kafka consumer group rebalance is triggered 1 2 Processing incl. state of stopped servers is migrated via Kafka to remaining servers “Ok, we can scale down again.”
  • 48. Want to take a deeper dive? https://kafka.apache.org/documentation/streams/architecture KSQL is built on top of Kafka Streams: Read up on Kafka Streams’ architecture including threading model, elasticity, fault-tolerance, state stores for stateful computation, etc. to learn more about how all this works behind the scenes.
  • 51. KSQL is the Easiest Way to Process with Kafka Runs Everywhere Elastic, Scalable, Fault-Tolerant, Distributed, S/M/L/XL Powerful Processing incl. Filters, Transforms, Joins, Aggregations, Windowing Supports Streams and Tables Free and Open Source Kafka Security Integration Event-Time Processing Zero Programming in Java, Scala 0 Exactly-Once Processing
  • 52. Where to go from here http://confluent.io/ksql https://slackpass.io/confluentcommunity #ksql https://github.com/confluentinc/ksql