SlideShare a Scribd company logo
1
FaaS Composition using Kafka and CloudEvents
Neil Avery,
Office of the CTO,
@avery_neil {...}
What is FaaS?
●
●
●
●
●
●
●
DRIVEN BY EVENTS
{...}
Origins of FaaS
●
●
●
●
“It’s easy to run without managing infrastructure. It will take care of
managing, scaling, monitoring and logging for you. Your applications run
milliseconds after the event has been triggered and thousands of
functions can work in parallel. You run the code only when needed.”
44
55
66
Microservice/FaaS/Stream-Processor
Single atomic unit
does one thing
like
77
Composition
<events don’t exist in isolation>
88
Composition
99
Composition styles
1. Wiring
2. Chaining
3. Orchestration / Workflow
(Step functions, Durable Fns,
Zeebe, Apache Airflow)
4. Choreography
1010
1. Wiring: Infrastructure events
Triggered by
S3 bucket, DynamoDB, SNS or CloudWatch
1111
1. Wiring: REST Endpoint
Http Request payload
1212
2. Call chaining
Send event from one Fn to other(s)
Sync or Async(s)
What could go wrong?
< debug, logs, testing, portability>
1313
3. Orchestration / Workflow
Vendor: AWS Step functions, Azure Durable Fns
OpenSource: Zeebe, Apache Airflow, CNCF Serverless workflow spec
14
15
1616
3. Orchestration using a DataFlow
1717
1818
Rate of adoption
● Serverless is the top-growing extended cloud service for the
second year in a row, with a 50 percent growth over 2018
24 to 36 percent adoption.
● Stream processing is tied for first, increasing from
20 to 30 percent adoption.
Rightscale cloud report 2019
1919
What is stream processing?
Event stream processing, or ESP, is a set of technologies designed to assist the
construction of event-driven information systems. ESP technologies include event
visualization, event databases, event-driven middleware, and event processing
languages, or complex event processing (CEP).
SELECT DataStream
Orders.TimeStamp, Orders.orderId,
Orders.ticker,Orders.amount, Trade.amount
FROM Orders
JOIN Trades OVER (RANGE INTERVAL '1' SECOND
FOLLOWING)
ON Orders.orderId = Trades.orderId;
https://en.wikipedia.org/wiki/Event_stream_processing
20
Streaming processing as SQL
Stream
processor
STREAM
/user-reg
FILTER
SELECT users > 18
PROJECT
SELECT user.name
JOIN
SELECT u.name, a.country
from user-reg u JOIN
address a WHERE u.id = a.id
GROUP BY (TABLE)
SELECT u.country,
count(u.name) FROM user-reg u
GROUP BY u.country
WINDOW (TABLE)
SELECT u.country, count(u.name)
FROM user-reg u WINDOW TUMBLING
(SIZE 1 MIN) group by u.country
STREAM
/address
21
1. Stream processor runs ‘future’ on
local-state of item-bids
auction items
3. Rejoined
removes item
4. Stream triggers FaaS
complete item processor
bid-history
Stream table join
5. FaaS Notify all bidders
bid-notifications
2.
Rewrite ‘completed’ item
status to retrigger join
item status
22
Kafka Streams
● Data driven (dataflow)
● Partition aware
● Scale
● Resilient
● Delivery guarantees
● Replay events and time-travel
[Java, Scala]
23
{
StreamsBuilder builder = new StreamsBuilder();
KStream<String, Payment> incoming = builder.stream(TASK_TOPIC);
incoming.filter(
(key, payment) -> payment.isComplete()).to(TASK_COMPLETE);
…
Topology gateTopology = builder.build();
streams = new KafkaStreams(gateTopology, streamsConfig);
streams.start();
}
24
{
StreamsBuilder builder = new StreamsBuilder();
KStream<String, Payment> incoming = builder.stream(TASK_TOPIC);
incoming.flatMapValues(payment -> {
ArrayList<String> fanTasks = new ArrayList<>();
for (int i = 0; i < payment.getAmount(); i++) {
fanTasks.add("fan-" + i);
}
return fanTasks;
}
).to(TASK_FANOUT); flatMapValues: Many V to the same K
Or
flatMap: Many K,V to one K,V pair
25
builder.stream(TASK_FANOUT)
.groupByKey(Grouped.with(Serdes.String(), Serdes.String()))
.windowedBy(SessionWindows.with(Duration.ofMinutes(1)))
.reduce(new Reducer<String>() {
public String apply(String agg1, String newValue) {
return agg1 + newValue;
}
})
.toStream()
.map((key, value) ->
new KeyValue<>(key.key() + "@" +
key.window().start() + "->" +
key.window().end(), value))
.to(TASK_REDUCE);
or: groupBy(KeyValueMapper)
{...}
{...}
{...}
{ bid:100; sold:1000;}
/bid-history
{
stream-lib.TDigest(values[])
}
{
stream-lib.TDigest(values[])
}
{
stream-lib.TDigest(values[])
}
Calculating percentiles using a ‘unit-of-work’ pattern
{
digest.merge(digest)
}
Stream processor with
a session window to
join related events by
key (k, v[1-10])
Stream
processor
fan out is natural (data-driven)
OR
use a Stream processor flatMap()
27
Stream processing ‘FaaS’ Patterns
● Filter (gate)
● Transform
● Fan-out (one to many)
● Fan-in (many to one - join)
● Branch/Choose (if ‘n’ then)
● Aggregate
● ...more...
2828
A Stream processing DataFlow is
both workflow and choreography
(EDA, SEDA, Event-driven, streaming)
2929
Choreography
1. Fire and forget / Async events
2. Producers emit state (not commands)
3. Consumers react to events
4. There is no master plan, no central brain
LOOSE COUPLING
30
Choreography
31
Choreography and Evolvability
32
An Event
records the fact that something happened
32
A good
was sold
An invoice
was issued
A payment
was made
A new customer
registered
33
Capture behavior
34
Evolvability
user experience?
how many users
affected?
has it happened
before?
new old
supports data change, logic change, logic extension, schema
evolution, loose coupling, add processors, A/B path
35
is a distributed event streaming platform
Publish & Subscribe
to Events
Store
Events
Process & Analyze
Events
3636
Choreography with Kafka
37
payment.incoming.pre
2.
Payment
Inflight
payment.incoming
1.
{...}
Fraudulent
Check
“FaaS Connector”
a bridge between Kafka topic(s) and serverless function(s)
3838
Confluent Hub
confluent.io/hub
39
FaaS Connector modes
1. Sync:
● fire and queue response
● preserve order
2. Async:
● fire and forget
● order agnostic
https://www.confluent.io/hub
→ AWS Lambda Connector (preview)
→ Azure Functions Connector (preview)
→ GCP Functions Connector (preview)
<confluent-platform>
../bin/connect-standalone ./etc/json-standalone.properties ./etc/AwsLambdaSinkConnector.properties
40
payment.incoming.pre
2.
Payment
Inflight
payment.incoming
1.
{...}
Fraudulent
Check
Connector
Bridge between Kaka topic
and Fn invocation
Producer
Write back to Kafka?
{...}
{...}
{...}
{...}
bad stream
42
Bad stream?
As we say in IT...
4343
44
Explain FaaS Connector modes
1. Sync: use case (ordered)
- state change analytics: add then remove values; i.e. CDC
- by topic partition
2. Async: use case (not ordered)
- compute intensive analytics; what-if scenario analysis
- machine learning training
- ETL
<confluent-platform>
../bin/connect-standalone ./etc/json-standalone.properties ./etc/AwsLambdaSinkConnector.properties
45
Kafka Streams is a Java app….
It’s not very ‘Cloud native’ - without
45
Kubeless Cloud Foundry Knative GraalVm Quarkus
4646
Composition at scale?
{faas}
Central nervous system
appappappapp
Payments Department 2
{faas}appappappapp
Department 3 Department 4
Choreography
Choreography
Orchestration
Hierarchical topic naming
4848
At Scale: CloudEvents
{faas}
What is the message format James?
appappappapp
Payments Department 2
I’m so confused!
50
https://cloudevents.io/
51
52
● CNCF
● Version 1.0 October 2019
● Specification (an Event envelope)
● Transport Bindings (Kafka, AMQP, HTTP others)
● SDKs: Java, .NET, Go-lang, Javascript etc
● Useful for exposing to external apps (Events as APIs)
CloudEvents is a specification for describing event data in common formats
to provide interoperability across services, platforms and systems.
5353
CloudEvent semantics
● Self describing / self contained / stand alone
● Suppressed / non-intruisive
● Language, transport, data format independent
● Propagation
● Extensions
● Batteries included
54
{
"specversion" : "0.4-wip",
"type" : "com.github.pull.create",
"source" :
"https://github.com/cloudevents/spec/pull",
"subject" : "123",
"id" : "A234-1234-1234",
"time" : "2018-04-05T17:31:00Z",
"comexampleextension1" : "value",
"comexampleextension2" : {
"othervalue": 5
},
"datacontenttype" : "text/xml",
"data" : "<much wow="xml"/>"
}
55
CloudEvents Producer Consumer
SerDes
Kafka Streams and
KSQL
SerDes
Kafka Connect
Convertor
Cloud Function
Connectors
AWS, GCP, Azure
and the Kafka
Ecosystem
56
KStream<String, CloudEvent<AttributesImpl, Payment>>
payments =
builder.stream(paymentTopic,
Consumed.with(StringSerde,
new CeBinarySerDes<>(Payment.class)));
payments.filter((k,v) -> {
return v.getData().get().getOrigin().contains("UK");
})
CloudEvents with Kafka Streams
{faas}
Central nervous system
appappappapp
Payments Department 2
{faas}appappappapp
Department 3 Department 4
Choreography
Orchestration
Choreography
Orchestration
Zeebe
Hierarchical topic naming
Kafka Streams
Quarkus
GraalVM
KNative
CloudEvents
Confluent Cloud
5858
Where to go from here
for more details on event-driven architectures with Kafka
@avery_neil
59
Questions?
@avery_neil
“Journey to event driven” blog
1. Event-first thinking
2. Programming models
3. Serverless
4. Pillars of event-streaming ms’s
https://bit.ly/2tFfU84
or @avery_neil twitter profile
60
@avery_neil
61
Cloud Native Kafka Streams (wow!)
61
1. StreamsTopology.java → docker-compose up --build. → topology.q-native-container
2. Create a Knative service descriptor topology-java-quarkus.yaml
3. Run locally: ./mvnw compile quarkus:dev
4. Publish docker push {username}/topology-java-quarkus
5. Deploy kubectl apply --filename service.yaml
6. Observe:
kubectl get ksvc topology-java-quarkus
NAME URL :
topology-java-quarkus http://topology-java-quarkus.default.1.2.3.4.xip.io
https://quarkus.io/guides/kafka-streams-guide https://knative.dev/community/samples/serving/helloworld-java-quarkus/

More Related Content

PDF
Apache Kafka and Blockchain - Comparison and a Kafka-native Implementation
PDF
Event streaming: A paradigm shift in enterprise software architecture
PPTX
IIoT with Kafka and Machine Learning for Supply Chain Optimization In Real Ti...
PPTX
JUG Tirana - Introduction to data streaming
PDF
Kai Waehner [Confluent] | Real-Time Streaming Analytics with 100,000 Cars Usi...
PDF
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
PDF
Kafka summit SF 2019 - the art of the event-streaming app
PDF
Build a Bridge to Cloud with Apache Kafka® for Data Analytics Cloud Services
Apache Kafka and Blockchain - Comparison and a Kafka-native Implementation
Event streaming: A paradigm shift in enterprise software architecture
IIoT with Kafka and Machine Learning for Supply Chain Optimization In Real Ti...
JUG Tirana - Introduction to data streaming
Kai Waehner [Confluent] | Real-Time Streaming Analytics with 100,000 Cars Usi...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Kafka summit SF 2019 - the art of the event-streaming app
Build a Bridge to Cloud with Apache Kafka® for Data Analytics Cloud Services

What's hot (20)

PDF
Mainframe Integration, Offloading and Replacement with Apache Kafka
PDF
Event Broker (Kafka) in a Modern Data Architecture
PDF
Apache Kafka for Smart Grid, Utilities and Energy Production
PDF
Concepts and Patterns for Streaming Services with Kafka
PDF
Apache Kafka as Event Streaming Platform for Microservice Architectures
PDF
Streamsheets and Apache Kafka – Interactively build real-time Dashboards and ...
PDF
Telco 4.0 - Payment and FinServ Integration for Data in Motion with 5G and Ap...
PDF
Apache Kafka in the Automotive Industry (Connected Vehicles, Manufacturing 4....
PDF
Serverless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
PDF
Confluent Operator as Cloud-Native Kafka Operator for Kubernetes
PDF
IoT Architectures for a Digital Twin with Apache Kafka, IoT Platforms and Mac...
PDF
Rediscovering the Value of Apache Kafka® in Modern Data Architecture
PDF
Fast Data – Fast Cars: Wie Apache Kafka die Datenwelt revolutioniert
PDF
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
PDF
Kafka for Real-Time Replication between Edge and Hybrid Cloud
PDF
Event Streaming CTO Roundtable for Cloud-native Kafka Architectures
PDF
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
PDF
Apache Kafka in the Airline, Aviation and Travel Industry
PDF
GCP for Apache Kafka® Users: Stream Ingestion and Processing
PDF
App modernization on AWS with Apache Kafka and Confluent Cloud
Mainframe Integration, Offloading and Replacement with Apache Kafka
Event Broker (Kafka) in a Modern Data Architecture
Apache Kafka for Smart Grid, Utilities and Energy Production
Concepts and Patterns for Streaming Services with Kafka
Apache Kafka as Event Streaming Platform for Microservice Architectures
Streamsheets and Apache Kafka – Interactively build real-time Dashboards and ...
Telco 4.0 - Payment and FinServ Integration for Data in Motion with 5G and Ap...
Apache Kafka in the Automotive Industry (Connected Vehicles, Manufacturing 4....
Serverless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
Confluent Operator as Cloud-Native Kafka Operator for Kubernetes
IoT Architectures for a Digital Twin with Apache Kafka, IoT Platforms and Mac...
Rediscovering the Value of Apache Kafka® in Modern Data Architecture
Fast Data – Fast Cars: Wie Apache Kafka die Datenwelt revolutioniert
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
Kafka for Real-Time Replication between Edge and Hybrid Cloud
Event Streaming CTO Roundtable for Cloud-native Kafka Architectures
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Apache Kafka in the Airline, Aviation and Travel Industry
GCP for Apache Kafka® Users: Stream Ingestion and Processing
App modernization on AWS with Apache Kafka and Confluent Cloud
Ad

Similar to Serverless London 2019 FaaS composition using Kafka and CloudEvents (20)

PDF
Serverless and Streaming: Building ‘eBay’ by ‘Turning the Database Inside Out’
PDF
Cloud Native London 2019 Faas composition using Kafka and cloud-events
PDF
The art of the event streaming application: streams, stream processors and sc...
PPTX
Building Event Driven Architectures with Kafka and Cloud Events (Dan Rosanova...
PDF
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
PDF
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
PDF
Now You See Me, Now You Compute: Building Event-Driven Architectures with Apa...
PDF
Building a Streaming Platform with Kafka
PDF
EDA Meets Data Engineering – What's the Big Deal?
PDF
Eventing Things - A Netflix Original! (Nitin Sharma, Netflix) Kafka Summit SF...
PDF
Events, Streams, Devops and Speed - The Next Generation of Application Archit...
PPTX
Kafka Streams for Java enthusiasts
PDF
Events Everywhere: Enabling Digital Transformation in the Public Sector
PDF
Jay Kreps | Kafka Summit NYC 2019 Keynote (Events Everywhere) | CEO, Confluent
PPTX
Kakfa summit london 2019 - the art of the event-streaming app
PDF
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
PDF
The State of Stream Processing
PDF
Kafka Vienna Meetup 020719
PDF
BBL KAPPA Lesfurets.com
PDF
Day in the life event-driven workshop
Serverless and Streaming: Building ‘eBay’ by ‘Turning the Database Inside Out’
Cloud Native London 2019 Faas composition using Kafka and cloud-events
The art of the event streaming application: streams, stream processors and sc...
Building Event Driven Architectures with Kafka and Cloud Events (Dan Rosanova...
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
Now You See Me, Now You Compute: Building Event-Driven Architectures with Apa...
Building a Streaming Platform with Kafka
EDA Meets Data Engineering – What's the Big Deal?
Eventing Things - A Netflix Original! (Nitin Sharma, Netflix) Kafka Summit SF...
Events, Streams, Devops and Speed - The Next Generation of Application Archit...
Kafka Streams for Java enthusiasts
Events Everywhere: Enabling Digital Transformation in the Public Sector
Jay Kreps | Kafka Summit NYC 2019 Keynote (Events Everywhere) | CEO, Confluent
Kakfa summit london 2019 - the art of the event-streaming app
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The State of Stream Processing
Kafka Vienna Meetup 020719
BBL KAPPA Lesfurets.com
Day in the life event-driven workshop
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Programs and apps: productivity, graphics, security and other tools
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation

Serverless London 2019 FaaS composition using Kafka and CloudEvents