SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Downloaden Sie, um offline zu lesen
1
Putting the ‘Micro’ into
Microservices with Stateful
Stream Processing
Ben Stopford
@benstopford
2
3
Last time: Event Driven Services
•  Interact through events, don’t talk to services
•  Evolve a Cascading Narrative
•  Query views, built inside your bounded context.
Related:
-Event Collaboration
-Service Choreography
-Event storming
4
The narrative should contain business
facts
It should read like:
“a day in the life of your business”
5
Base services on Event Sourcing
Domain Service
Kafka
Local View of
Customers
Service journals
state changes
(Facts)
6
Where stateful, reconstitute from log
Domain Service
Kafka
Local View of
Customers
Reconstitute
state
7
Use the narrative to move away from
legacy apps
Domain Service
Kafka
Local View of
Customers
8
Retain the Narrative
Kafka scales
9
What is this talk about?
Using SSP to build lightweight services that
evolve the shared narrative
1.  What’s in the SSP toolbox?
2.  Patterns for Streaming Services
3.  Sewing together the Big & the Small
4.  The tricky parts
10
Applying tools
from stateful
stream
processing
11
Aside: What is Stateful Stream
Processing?
A machine for converting a set of
streams into something more useful.
Output a stream
or output a table
12
Domain Service
Kafka
Local View of
Customers
View
(1) Drive processing from Events
(2) Build views that answer questions
13
The tools
14
Kafka
Producer
(1) Producer/Consumer APIs
Consumer
•  Simple & easy to
understand
•  Native in many
languages
•  Easy to integrate to
existing services
•  No joins, predicates,
groupings or tables
•  Includes transactions
in Kafka-11.
15
(2) KStreams DSL
•  Joins (including
windowing)
•  Predicates
•  Groupings
•  Processor API
Kafka
KTable
Inbound
Stream
(Windowed)
State Store Outbound Stream
Changelog
Stream
DSL
16
(3) The KTable
•  Recast a stream as a
table via a defined key
•  Tends to be backed
by compacted topic.
•  Materialized locally in
RocksDB
•  Provides guaranteed
join semantics (i.e. no
windowing concerns)
Kafka
KTable
(in RocksDB)
DSL
JVM boundary
17
The KTable
•  Behaves like a regular stream but
retains the latest value for each key,
from offset 0
•  Partitions spread over all available
instances
•  Partition counts must match for joins
•  Triggers processing
•  Initializes lazily.
18
(4) Global KTable
•  All partitions replicated
to all nodes
•  Supports N-way join
•  Blocks until initialized
•  Doesn’t trigger
processing (reference
resource)
Kafka
Global KTable
(in RocksDB)
DSL
19
Global-KTables vs. KTables
P1,3 P6,8 P2,7 P4,5
P1,2,
3,4,5,
6,7,8
P1,2,
3,4,5,
6,7,8
P1,2,
3,4,5,
6,7,8
P1,2,
3,4,5,
6,7,8
KTable
(Sharded)
Global KTable
(Replicated)
Given a service with four instances:
20
(5) State Store
•  RocksDB instance
•  Mutable
•  Backed by Kafka
•  Integrated into DSL
•  Can be instantiated
independently
•  Queryable via
Queryable state
•  Useful for custom
views or stateful
services.Kafka
State Store
(RocksDB)
Changelog
Stream
DSL
21
(6) Hot Replicas
-  By default KStreams
keeps state backed up on
a secondary node.
-  Single machine failure
doesn’t result in a re-
hydration pause.
=> Highly available, stateful
services.
Service instance 1 Service instance 2
22
(7) Transactions
Two problems:
1.  Failures create duplicates
•  Each message gets a unique ID
•  Deduplicate on write
2.  You need to write, atomically, to 2
or more topics
•  Chandy-Lamport Algorithm
NB: Transactions will be in the next Kafka release
23
Snapshot Marker Model
Commit/Abort
Begin
Commit/Abort
Begin
Buffer*
* The buffering is actually done in Kafka no the consumer
Producer Consumer
Topic A
Topic B
Elected Transaction
Coordinator
Consumer only sees
committed messages
24
Simple Example
//Orders -> Stock Requests and Payments
orders = ordersTopic.poll()
payments = paymentsFor(orders)
stockUpdates = stockUpdatesFor(orders)
//Send & commit atomically
producer.beginTransaction()
producer.send(payments)
producer.send(stockUpdates)
producer.sendOffsetsToTransaction(offsets(orders))
producer.endTransaction()
25
State-Stores & Transactions
•  In KStreams Transactions
span stream and
changelog
•  Processing of stream &
state is atomic
•  Example: counting orders.
Kafka
State Store Stream
DSL
Atomic Transaction
Changelog
Stream
26
All these tools scale horizontally and avoid
single points of failure
Sources Kafka KafkaService Layer Service Layer Kafka
27
Service patterns
(building blocks)
28
(1) Stateless Processor
e.g.
- Filter orders by region
-  Convert to local domain model
-  Simple rule
29
(2) Stateless, Data Enabled Processor
Similar to star schema
•  Facts are stream
•  Dimensions are GKTables
e.g. Enrich Orders with Customer Info & Account details
Stream
GKTable
GKTable
Stream-Table
Join
30
(3) Gates
e.g. rules engines or event correlation
When Order & Payment then …
Stream 1
Window
Window Stream-Stream
Join
Stream 2
31
(4) Stateful Processor
e.g.
- Average order amount by region
- Posting Engine (reverse replace of previous position)
State store
backed up to Kafka
32
(5) Stream-Aside Pattern
State store
backed up to Kafka
public static
void main(…){
…
}
JVM
33
(7) Sidecar Pattern
State store
backed up to Kafka
34
Combine them:
1.  Stateless
2.  Data enriched
3.  Gates
4.  Stateful processors
5.  Stream-aside
6.  Sidecar
35
Query patterns covered in last talk
36
Building ON the
narrative
The big and the small
37
Evolutionary approach
Services should:
•  Fit in your head
•  Should be quick to stand up & get going
But sometimes bigger is the right answer
38
Event Driven First
•  Build on an event driven backbone
•  Add Request-Driven interfaces where
needed.
•  Prefer intra-context
REST
Kafka
39
Putting the Micro into Microservices
- Combine simple services that develop
the shared narrative
- Start stateless, make stateful if
necessary
40
Contexts within Contexts
Where services are
tiny, they will typically
be grouped together.
•  Shared domain?
•  Shared deployment?
•  Shared streams?
Several small
services
Single bounded
context
41
Layering within multi-service contexts
Kafka
Data layer:
-Stream enrichment
-View creation
-Streams maintenance
Business layer
encapsulates logic,
integrates with legacy
code etc.
Request-Driven layer
provides REST / RPC /
websotcket etc for UIs
etc
42
Kafka
Different levels of data
visibility within Kafka
Kafka
Contexts within Contexts
Accounting
Fulfillment
Online Services
43
Bringing it
together
44
Good architectures have little to
do with this:
45
It’s more about how systems evolves
over time
46
Sunk Cost vs Future Cost
Architecture: Sunk Cost Change: Future Cost
Balance
47
Part 1: Data dichotomy
Request-Driven Services don’t handle
shared data well
-  God service problem
-  The data erosion problem
Request-Driven Services struggle with
complex flows
-  the service entanglement problem
-  the batch processing problem.
48
Part 2: Building Event Driven Services
Solution is to part 1:
-  Event source facts into a Cascading
Narrative
-  Communication & State transfer
converge
-  Decentralize the role of turning facts
into queryable views
-  Keep these views as lightweight and
disposable as possible.
49
Putting the Micro in Microservices
-  Start lightweight, stateless functions
which compose and evolve
-  Leverage the stateful stream processing
toolkit to blend streams, state, views,
transactions.
-  Use layered contexts that segregate
groups of streams and services.
50
Highly
scalable
architecture
51
All order logic,
stateless service
Orders-by-Customer view
(KStreams + Queryable State API)
UI Service
Stream
Maintenance &
Monitoring
Highly available, stateful service
UI uses Orders-by-
Customer View directly
via Queryable State
History Service pushes data to
a local Elastic Search Instance
Orders
Service
Derived
View
UI joins data
Tables & Streams
Fulfillment Service
Analytics
OrdersProduct Custo-
mers KTables
KTables KTables
Schemas
52
Tips & Tricky parts
•  Reasoning about service choreography
•  Debugging multi-stage topologies
•  Monitoring/debug via the narrative
•  Segregate facts from intermediary streams
•  Retaining data comes at a cost
•  Schema migration etc
•  Accuracy over non trivial topologies
•  Often requires transactions
•  Transactions, causality & the flow of events
•  Avoid side effects
53
Event Driven Services
Create a cascading narrative of events,
then sew them together with stream
processing.
54
Discount code: kafcom17
‪Use the Apache Kafka community discount
code to get $50 off
‪www.kafka-summit.org
Kafka Summit New York: May 8
Kafka Summit San Francisco: August 28
Presented by
55
Thank You!
@benstopford

Weitere ähnliche Inhalte

Was ist angesagt?

Hive spark-s3acommitter-hbase-nfs
Hive spark-s3acommitter-hbase-nfsHive spark-s3acommitter-hbase-nfs
Hive spark-s3acommitter-hbase-nfsYifeng Jiang
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
Introduction to Presto at Treasure Data
Introduction to Presto at Treasure DataIntroduction to Presto at Treasure Data
Introduction to Presto at Treasure DataTaro L. Saito
 
Next-generation MMORPG service architecture
Next-generation MMORPG service architectureNext-generation MMORPG service architecture
Next-generation MMORPG service architectureJongwon Kim
 
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
codecentric AG: CQRS and Event Sourcing Applications with Cassandracodecentric AG: CQRS and Event Sourcing Applications with Cassandra
codecentric AG: CQRS and Event Sourcing Applications with CassandraDataStax Academy
 
Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...
Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...
Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...HostedbyConfluent
 
Windows Registered I/O (RIO) vs IOCP
Windows Registered I/O (RIO) vs IOCPWindows Registered I/O (RIO) vs IOCP
Windows Registered I/O (RIO) vs IOCPSeungmo Koo
 
Data Security at Scale through Spark and Parquet Encryption
Data Security at Scale through Spark and Parquet EncryptionData Security at Scale through Spark and Parquet Encryption
Data Security at Scale through Spark and Parquet EncryptionDatabricks
 
백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스
백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스
백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스NAVER D2
 
Hybrid Apache Spark Architecture with YARN and Kubernetes
Hybrid Apache Spark Architecture with YARN and KubernetesHybrid Apache Spark Architecture with YARN and Kubernetes
Hybrid Apache Spark Architecture with YARN and KubernetesDatabricks
 
Building a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management ApplicationBuilding a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management ApplicationJonathan Katz
 
BigTable And Hbase
BigTable And HbaseBigTable And Hbase
BigTable And HbaseEdward Yoon
 
Analyzing Historical Data of Applications on YARN for Fun and Profit
Analyzing Historical Data of Applications on YARN for Fun and ProfitAnalyzing Historical Data of Applications on YARN for Fun and Profit
Analyzing Historical Data of Applications on YARN for Fun and ProfitDataWorks Summit
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsJean-François Gagné
 
Introduction To Streaming Data and Stream Processing with Apache Kafka
Introduction To Streaming Data and Stream Processing with Apache KafkaIntroduction To Streaming Data and Stream Processing with Apache Kafka
Introduction To Streaming Data and Stream Processing with Apache Kafkaconfluent
 
Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...
Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...
Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...StreamNative
 
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...HostedbyConfluent
 
Maxim Fateev - Beyond the Watermark- On-Demand Backfilling in Flink
Maxim Fateev - Beyond the Watermark- On-Demand Backfilling in FlinkMaxim Fateev - Beyond the Watermark- On-Demand Backfilling in Flink
Maxim Fateev - Beyond the Watermark- On-Demand Backfilling in FlinkFlink Forward
 

Was ist angesagt? (20)

Hive spark-s3acommitter-hbase-nfs
Hive spark-s3acommitter-hbase-nfsHive spark-s3acommitter-hbase-nfs
Hive spark-s3acommitter-hbase-nfs
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Introduction to Presto at Treasure Data
Introduction to Presto at Treasure DataIntroduction to Presto at Treasure Data
Introduction to Presto at Treasure Data
 
Next-generation MMORPG service architecture
Next-generation MMORPG service architectureNext-generation MMORPG service architecture
Next-generation MMORPG service architecture
 
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
codecentric AG: CQRS and Event Sourcing Applications with Cassandracodecentric AG: CQRS and Event Sourcing Applications with Cassandra
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
 
Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...
Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...
Using Modular Topologies in Kafka Streams to scale ksqlDB’s persistent querie...
 
Windows Registered I/O (RIO) vs IOCP
Windows Registered I/O (RIO) vs IOCPWindows Registered I/O (RIO) vs IOCP
Windows Registered I/O (RIO) vs IOCP
 
Data Security at Scale through Spark and Parquet Encryption
Data Security at Scale through Spark and Parquet EncryptionData Security at Scale through Spark and Parquet Encryption
Data Security at Scale through Spark and Parquet Encryption
 
백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스
백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스
백억개의 로그를 모아 검색하고 분석하고 학습도 시켜보자 : 로기스
 
Hybrid Apache Spark Architecture with YARN and Kubernetes
Hybrid Apache Spark Architecture with YARN and KubernetesHybrid Apache Spark Architecture with YARN and Kubernetes
Hybrid Apache Spark Architecture with YARN and Kubernetes
 
Building a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management ApplicationBuilding a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management Application
 
BigTable And Hbase
BigTable And HbaseBigTable And Hbase
BigTable And Hbase
 
Analyzing Historical Data of Applications on YARN for Fun and Profit
Analyzing Historical Data of Applications on YARN for Fun and ProfitAnalyzing Historical Data of Applications on YARN for Fun and Profit
Analyzing Historical Data of Applications on YARN for Fun and Profit
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
Introduction To Streaming Data and Stream Processing with Apache Kafka
Introduction To Streaming Data and Stream Processing with Apache KafkaIntroduction To Streaming Data and Stream Processing with Apache Kafka
Introduction To Streaming Data and Stream Processing with Apache Kafka
 
Rapid json tutorial
Rapid json tutorialRapid json tutorial
Rapid json tutorial
 
Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...
Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...
Exactly-Once Made Easy: Transactional Messaging in Apache Pulsar - Pulsar Sum...
 
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
 
Maxim Fateev - Beyond the Watermark- On-Demand Backfilling in Flink
Maxim Fateev - Beyond the Watermark- On-Demand Backfilling in FlinkMaxim Fateev - Beyond the Watermark- On-Demand Backfilling in Flink
Maxim Fateev - Beyond the Watermark- On-Demand Backfilling in Flink
 
Logstash
LogstashLogstash
Logstash
 

Ähnlich wie Event Driven Services Part 3: Putting the Micro into Microservices with Stateful Stream Processing

Capital One Delivers Risk Insights in Real Time with Stream Processing
Capital One Delivers Risk Insights in Real Time with Stream ProcessingCapital One Delivers Risk Insights in Real Time with Stream Processing
Capital One Delivers Risk Insights in Real Time with Stream Processingconfluent
 
Introducing Events and Stream Processing into Nationwide Building Society (Ro...
Introducing Events and Stream Processing into Nationwide Building Society (Ro...Introducing Events and Stream Processing into Nationwide Building Society (Ro...
Introducing Events and Stream Processing into Nationwide Building Society (Ro...confluent
 
Real Time Insights for Advertising Tech
Real Time Insights for Advertising TechReal Time Insights for Advertising Tech
Real Time Insights for Advertising TechApache Apex
 
AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017
AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017
AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017Monal Daxini
 
Real-Time Data Pipelines with Kafka, Spark, and Operational Databases
Real-Time Data Pipelines with Kafka, Spark, and Operational DatabasesReal-Time Data Pipelines with Kafka, Spark, and Operational Databases
Real-Time Data Pipelines with Kafka, Spark, and Operational DatabasesSingleStore
 
Kafka streams decoupling with stores
Kafka streams decoupling with storesKafka streams decoupling with stores
Kafka streams decoupling with storesYoni Farin
 
Data & Analytics Forum: Moving Telcos to Real Time
Data & Analytics Forum: Moving Telcos to Real TimeData & Analytics Forum: Moving Telcos to Real Time
Data & Analytics Forum: Moving Telcos to Real TimeSingleStore
 
Event Driven Microservices
Event Driven MicroservicesEvent Driven Microservices
Event Driven MicroservicesFabrizio Fortino
 
10 Principals for Effective Event-Driven Microservices with Apache Kafka
10 Principals for Effective Event-Driven Microservices with Apache Kafka10 Principals for Effective Event-Driven Microservices with Apache Kafka
10 Principals for Effective Event-Driven Microservices with Apache KafkaBen Stopford
 
Building Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache KafkaBuilding Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache Kafkaconfluent
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Tammy Bednar
 
Ingestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache ApexIngestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache ApexApache Apex
 
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
Event Driven Services Part 2:  Building Event-Driven Services with Apache KafkaEvent Driven Services Part 2:  Building Event-Driven Services with Apache Kafka
Event Driven Services Part 2: Building Event-Driven Services with Apache KafkaBen Stopford
 
10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven MicroservicesBen Stopford
 
Microservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka EcosystemMicroservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka Ecosystemconfluent
 
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...HostedbyConfluent
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Vinay Kumar
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Vinay Kumar
 
HOP! Airlines Jets to Real Time
HOP! Airlines Jets to Real TimeHOP! Airlines Jets to Real Time
HOP! Airlines Jets to Real Timeconfluent
 
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...Dataconomy Media
 

Ähnlich wie Event Driven Services Part 3: Putting the Micro into Microservices with Stateful Stream Processing (20)

Capital One Delivers Risk Insights in Real Time with Stream Processing
Capital One Delivers Risk Insights in Real Time with Stream ProcessingCapital One Delivers Risk Insights in Real Time with Stream Processing
Capital One Delivers Risk Insights in Real Time with Stream Processing
 
Introducing Events and Stream Processing into Nationwide Building Society (Ro...
Introducing Events and Stream Processing into Nationwide Building Society (Ro...Introducing Events and Stream Processing into Nationwide Building Society (Ro...
Introducing Events and Stream Processing into Nationwide Building Society (Ro...
 
Real Time Insights for Advertising Tech
Real Time Insights for Advertising TechReal Time Insights for Advertising Tech
Real Time Insights for Advertising Tech
 
AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017
AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017
AWS Re-Invent 2017 Netflix Keystone SPaaS - Monal Daxini - Abd320 2017
 
Real-Time Data Pipelines with Kafka, Spark, and Operational Databases
Real-Time Data Pipelines with Kafka, Spark, and Operational DatabasesReal-Time Data Pipelines with Kafka, Spark, and Operational Databases
Real-Time Data Pipelines with Kafka, Spark, and Operational Databases
 
Kafka streams decoupling with stores
Kafka streams decoupling with storesKafka streams decoupling with stores
Kafka streams decoupling with stores
 
Data & Analytics Forum: Moving Telcos to Real Time
Data & Analytics Forum: Moving Telcos to Real TimeData & Analytics Forum: Moving Telcos to Real Time
Data & Analytics Forum: Moving Telcos to Real Time
 
Event Driven Microservices
Event Driven MicroservicesEvent Driven Microservices
Event Driven Microservices
 
10 Principals for Effective Event-Driven Microservices with Apache Kafka
10 Principals for Effective Event-Driven Microservices with Apache Kafka10 Principals for Effective Event-Driven Microservices with Apache Kafka
10 Principals for Effective Event-Driven Microservices with Apache Kafka
 
Building Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache KafkaBuilding Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache Kafka
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
 
Ingestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache ApexIngestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache Apex
 
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
Event Driven Services Part 2:  Building Event-Driven Services with Apache KafkaEvent Driven Services Part 2:  Building Event-Driven Services with Apache Kafka
Event Driven Services Part 2: Building Event-Driven Services with Apache Kafka
 
10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices10 Principals for Effective Event Driven Microservices
10 Principals for Effective Event Driven Microservices
 
Microservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka EcosystemMicroservices in the Apache Kafka Ecosystem
Microservices in the Apache Kafka Ecosystem
 
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20
 
HOP! Airlines Jets to Real Time
HOP! Airlines Jets to Real TimeHOP! Airlines Jets to Real Time
HOP! Airlines Jets to Real Time
 
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
 

Mehr von Ben Stopford

The Future of Streaming: Global Apps, Event Stores and Serverless
The Future of Streaming: Global Apps, Event Stores and ServerlessThe Future of Streaming: Global Apps, Event Stores and Serverless
The Future of Streaming: Global Apps, Event Stores and ServerlessBen Stopford
 
A Global Source of Truth for the Microservices Generation
A Global Source of Truth for the Microservices GenerationA Global Source of Truth for the Microservices Generation
A Global Source of Truth for the Microservices GenerationBen Stopford
 
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017  - The Data Dichotomy- Rethinking Data and Services with StreamsNDC London 2017  - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with StreamsBen Stopford
 
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...Ben Stopford
 
Building Event Driven Services with Stateful Streams
Building Event Driven Services with Stateful StreamsBuilding Event Driven Services with Stateful Streams
Building Event Driven Services with Stateful StreamsBen Stopford
 
Devoxx London 2017 - Rethinking Services With Stateful Streams
Devoxx London 2017 - Rethinking Services With Stateful StreamsDevoxx London 2017 - Rethinking Services With Stateful Streams
Devoxx London 2017 - Rethinking Services With Stateful StreamsBen Stopford
 
Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 1: The Data Dichotomy Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 1: The Data Dichotomy Ben Stopford
 
Strata Software Architecture NY: The Data Dichotomy
Strata Software Architecture NY: The Data DichotomyStrata Software Architecture NY: The Data Dichotomy
Strata Software Architecture NY: The Data DichotomyBen Stopford
 
The Power of the Log
The Power of the LogThe Power of the Log
The Power of the LogBen Stopford
 
Streaming, Database & Distributed Systems Bridging the Divide
Streaming, Database & Distributed Systems Bridging the DivideStreaming, Database & Distributed Systems Bridging the Divide
Streaming, Database & Distributed Systems Bridging the DivideBen Stopford
 
Data Pipelines with Apache Kafka
Data Pipelines with Apache KafkaData Pipelines with Apache Kafka
Data Pipelines with Apache KafkaBen Stopford
 
Microservices for a Streaming World
Microservices for a Streaming WorldMicroservices for a Streaming World
Microservices for a Streaming WorldBen Stopford
 
A little bit of clojure
A little bit of clojureA little bit of clojure
A little bit of clojureBen Stopford
 
Big iron 2 (published)
Big iron 2 (published)Big iron 2 (published)
Big iron 2 (published)Ben Stopford
 
The return of big iron?
The return of big iron?The return of big iron?
The return of big iron?Ben Stopford
 
Big Data & the Enterprise
Big Data & the EnterpriseBig Data & the Enterprise
Big Data & the EnterpriseBen Stopford
 
Where Does Big Data Meet Big Database - QCon 2012
Where Does Big Data Meet Big Database - QCon 2012Where Does Big Data Meet Big Database - QCon 2012
Where Does Big Data Meet Big Database - QCon 2012Ben Stopford
 
Advanced databases ben stopford
Advanced databases   ben stopfordAdvanced databases   ben stopford
Advanced databases ben stopfordBen Stopford
 
Coherence Implementation Patterns - Sig Nov 2011
Coherence Implementation Patterns - Sig Nov 2011Coherence Implementation Patterns - Sig Nov 2011
Coherence Implementation Patterns - Sig Nov 2011Ben Stopford
 

Mehr von Ben Stopford (20)

The Future of Streaming: Global Apps, Event Stores and Serverless
The Future of Streaming: Global Apps, Event Stores and ServerlessThe Future of Streaming: Global Apps, Event Stores and Serverless
The Future of Streaming: Global Apps, Event Stores and Serverless
 
A Global Source of Truth for the Microservices Generation
A Global Source of Truth for the Microservices GenerationA Global Source of Truth for the Microservices Generation
A Global Source of Truth for the Microservices Generation
 
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017  - The Data Dichotomy- Rethinking Data and Services with StreamsNDC London 2017  - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
 
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
Building Event Driven Services with Apache Kafka and Kafka Streams - Devoxx B...
 
Building Event Driven Services with Stateful Streams
Building Event Driven Services with Stateful StreamsBuilding Event Driven Services with Stateful Streams
Building Event Driven Services with Stateful Streams
 
Devoxx London 2017 - Rethinking Services With Stateful Streams
Devoxx London 2017 - Rethinking Services With Stateful StreamsDevoxx London 2017 - Rethinking Services With Stateful Streams
Devoxx London 2017 - Rethinking Services With Stateful Streams
 
Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 1: The Data Dichotomy Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 1: The Data Dichotomy
 
Strata Software Architecture NY: The Data Dichotomy
Strata Software Architecture NY: The Data DichotomyStrata Software Architecture NY: The Data Dichotomy
Strata Software Architecture NY: The Data Dichotomy
 
The Power of the Log
The Power of the LogThe Power of the Log
The Power of the Log
 
Streaming, Database & Distributed Systems Bridging the Divide
Streaming, Database & Distributed Systems Bridging the DivideStreaming, Database & Distributed Systems Bridging the Divide
Streaming, Database & Distributed Systems Bridging the Divide
 
Data Pipelines with Apache Kafka
Data Pipelines with Apache KafkaData Pipelines with Apache Kafka
Data Pipelines with Apache Kafka
 
JAX London Slides
JAX London SlidesJAX London Slides
JAX London Slides
 
Microservices for a Streaming World
Microservices for a Streaming WorldMicroservices for a Streaming World
Microservices for a Streaming World
 
A little bit of clojure
A little bit of clojureA little bit of clojure
A little bit of clojure
 
Big iron 2 (published)
Big iron 2 (published)Big iron 2 (published)
Big iron 2 (published)
 
The return of big iron?
The return of big iron?The return of big iron?
The return of big iron?
 
Big Data & the Enterprise
Big Data & the EnterpriseBig Data & the Enterprise
Big Data & the Enterprise
 
Where Does Big Data Meet Big Database - QCon 2012
Where Does Big Data Meet Big Database - QCon 2012Where Does Big Data Meet Big Database - QCon 2012
Where Does Big Data Meet Big Database - QCon 2012
 
Advanced databases ben stopford
Advanced databases   ben stopfordAdvanced databases   ben stopford
Advanced databases ben stopford
 
Coherence Implementation Patterns - Sig Nov 2011
Coherence Implementation Patterns - Sig Nov 2011Coherence Implementation Patterns - Sig Nov 2011
Coherence Implementation Patterns - Sig Nov 2011
 

Kürzlich hochgeladen

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Kürzlich hochgeladen (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Event Driven Services Part 3: Putting the Micro into Microservices with Stateful Stream Processing

  • 1. 1 Putting the ‘Micro’ into Microservices with Stateful Stream Processing Ben Stopford @benstopford
  • 2. 2
  • 3. 3 Last time: Event Driven Services •  Interact through events, don’t talk to services •  Evolve a Cascading Narrative •  Query views, built inside your bounded context. Related: -Event Collaboration -Service Choreography -Event storming
  • 4. 4 The narrative should contain business facts It should read like: “a day in the life of your business”
  • 5. 5 Base services on Event Sourcing Domain Service Kafka Local View of Customers Service journals state changes (Facts)
  • 6. 6 Where stateful, reconstitute from log Domain Service Kafka Local View of Customers Reconstitute state
  • 7. 7 Use the narrative to move away from legacy apps Domain Service Kafka Local View of Customers
  • 9. 9 What is this talk about? Using SSP to build lightweight services that evolve the shared narrative 1.  What’s in the SSP toolbox? 2.  Patterns for Streaming Services 3.  Sewing together the Big & the Small 4.  The tricky parts
  • 11. 11 Aside: What is Stateful Stream Processing? A machine for converting a set of streams into something more useful. Output a stream or output a table
  • 12. 12 Domain Service Kafka Local View of Customers View (1) Drive processing from Events (2) Build views that answer questions
  • 14. 14 Kafka Producer (1) Producer/Consumer APIs Consumer •  Simple & easy to understand •  Native in many languages •  Easy to integrate to existing services •  No joins, predicates, groupings or tables •  Includes transactions in Kafka-11.
  • 15. 15 (2) KStreams DSL •  Joins (including windowing) •  Predicates •  Groupings •  Processor API Kafka KTable Inbound Stream (Windowed) State Store Outbound Stream Changelog Stream DSL
  • 16. 16 (3) The KTable •  Recast a stream as a table via a defined key •  Tends to be backed by compacted topic. •  Materialized locally in RocksDB •  Provides guaranteed join semantics (i.e. no windowing concerns) Kafka KTable (in RocksDB) DSL JVM boundary
  • 17. 17 The KTable •  Behaves like a regular stream but retains the latest value for each key, from offset 0 •  Partitions spread over all available instances •  Partition counts must match for joins •  Triggers processing •  Initializes lazily.
  • 18. 18 (4) Global KTable •  All partitions replicated to all nodes •  Supports N-way join •  Blocks until initialized •  Doesn’t trigger processing (reference resource) Kafka Global KTable (in RocksDB) DSL
  • 19. 19 Global-KTables vs. KTables P1,3 P6,8 P2,7 P4,5 P1,2, 3,4,5, 6,7,8 P1,2, 3,4,5, 6,7,8 P1,2, 3,4,5, 6,7,8 P1,2, 3,4,5, 6,7,8 KTable (Sharded) Global KTable (Replicated) Given a service with four instances:
  • 20. 20 (5) State Store •  RocksDB instance •  Mutable •  Backed by Kafka •  Integrated into DSL •  Can be instantiated independently •  Queryable via Queryable state •  Useful for custom views or stateful services.Kafka State Store (RocksDB) Changelog Stream DSL
  • 21. 21 (6) Hot Replicas -  By default KStreams keeps state backed up on a secondary node. -  Single machine failure doesn’t result in a re- hydration pause. => Highly available, stateful services. Service instance 1 Service instance 2
  • 22. 22 (7) Transactions Two problems: 1.  Failures create duplicates •  Each message gets a unique ID •  Deduplicate on write 2.  You need to write, atomically, to 2 or more topics •  Chandy-Lamport Algorithm NB: Transactions will be in the next Kafka release
  • 23. 23 Snapshot Marker Model Commit/Abort Begin Commit/Abort Begin Buffer* * The buffering is actually done in Kafka no the consumer Producer Consumer Topic A Topic B Elected Transaction Coordinator Consumer only sees committed messages
  • 24. 24 Simple Example //Orders -> Stock Requests and Payments orders = ordersTopic.poll() payments = paymentsFor(orders) stockUpdates = stockUpdatesFor(orders) //Send & commit atomically producer.beginTransaction() producer.send(payments) producer.send(stockUpdates) producer.sendOffsetsToTransaction(offsets(orders)) producer.endTransaction()
  • 25. 25 State-Stores & Transactions •  In KStreams Transactions span stream and changelog •  Processing of stream & state is atomic •  Example: counting orders. Kafka State Store Stream DSL Atomic Transaction Changelog Stream
  • 26. 26 All these tools scale horizontally and avoid single points of failure Sources Kafka KafkaService Layer Service Layer Kafka
  • 28. 28 (1) Stateless Processor e.g. - Filter orders by region -  Convert to local domain model -  Simple rule
  • 29. 29 (2) Stateless, Data Enabled Processor Similar to star schema •  Facts are stream •  Dimensions are GKTables e.g. Enrich Orders with Customer Info & Account details Stream GKTable GKTable Stream-Table Join
  • 30. 30 (3) Gates e.g. rules engines or event correlation When Order & Payment then … Stream 1 Window Window Stream-Stream Join Stream 2
  • 31. 31 (4) Stateful Processor e.g. - Average order amount by region - Posting Engine (reverse replace of previous position) State store backed up to Kafka
  • 32. 32 (5) Stream-Aside Pattern State store backed up to Kafka public static void main(…){ … } JVM
  • 33. 33 (7) Sidecar Pattern State store backed up to Kafka
  • 34. 34 Combine them: 1.  Stateless 2.  Data enriched 3.  Gates 4.  Stateful processors 5.  Stream-aside 6.  Sidecar
  • 36. 36 Building ON the narrative The big and the small
  • 37. 37 Evolutionary approach Services should: •  Fit in your head •  Should be quick to stand up & get going But sometimes bigger is the right answer
  • 38. 38 Event Driven First •  Build on an event driven backbone •  Add Request-Driven interfaces where needed. •  Prefer intra-context REST Kafka
  • 39. 39 Putting the Micro into Microservices - Combine simple services that develop the shared narrative - Start stateless, make stateful if necessary
  • 40. 40 Contexts within Contexts Where services are tiny, they will typically be grouped together. •  Shared domain? •  Shared deployment? •  Shared streams? Several small services Single bounded context
  • 41. 41 Layering within multi-service contexts Kafka Data layer: -Stream enrichment -View creation -Streams maintenance Business layer encapsulates logic, integrates with legacy code etc. Request-Driven layer provides REST / RPC / websotcket etc for UIs etc
  • 42. 42 Kafka Different levels of data visibility within Kafka Kafka Contexts within Contexts Accounting Fulfillment Online Services
  • 44. 44 Good architectures have little to do with this:
  • 45. 45 It’s more about how systems evolves over time
  • 46. 46 Sunk Cost vs Future Cost Architecture: Sunk Cost Change: Future Cost Balance
  • 47. 47 Part 1: Data dichotomy Request-Driven Services don’t handle shared data well -  God service problem -  The data erosion problem Request-Driven Services struggle with complex flows -  the service entanglement problem -  the batch processing problem.
  • 48. 48 Part 2: Building Event Driven Services Solution is to part 1: -  Event source facts into a Cascading Narrative -  Communication & State transfer converge -  Decentralize the role of turning facts into queryable views -  Keep these views as lightweight and disposable as possible.
  • 49. 49 Putting the Micro in Microservices -  Start lightweight, stateless functions which compose and evolve -  Leverage the stateful stream processing toolkit to blend streams, state, views, transactions. -  Use layered contexts that segregate groups of streams and services.
  • 51. 51 All order logic, stateless service Orders-by-Customer view (KStreams + Queryable State API) UI Service Stream Maintenance & Monitoring Highly available, stateful service UI uses Orders-by- Customer View directly via Queryable State History Service pushes data to a local Elastic Search Instance Orders Service Derived View UI joins data Tables & Streams Fulfillment Service Analytics OrdersProduct Custo- mers KTables KTables KTables Schemas
  • 52. 52 Tips & Tricky parts •  Reasoning about service choreography •  Debugging multi-stage topologies •  Monitoring/debug via the narrative •  Segregate facts from intermediary streams •  Retaining data comes at a cost •  Schema migration etc •  Accuracy over non trivial topologies •  Often requires transactions •  Transactions, causality & the flow of events •  Avoid side effects
  • 53. 53 Event Driven Services Create a cascading narrative of events, then sew them together with stream processing.
  • 54. 54 Discount code: kafcom17 ‪Use the Apache Kafka community discount code to get $50 off ‪www.kafka-summit.org Kafka Summit New York: May 8 Kafka Summit San Francisco: August 28 Presented by