Simple message queue
Partition
Electric
Meter
Auditing
Electric
Readings
Partition replica
Partition replica
Kafka Terminology:
- Partition Count: 1
Slide 28
Slide 28 text
Simple message queue - fanout
Partition
Electric
Meter
Auditing
Electric
Readings
Partition replica
Partition replica
Billing
Kafka Terminology:
- Partition Count: 1
- Multiple Consumer Groups
Slide 29
Slide 29 text
DB
Simple message queue - consumer
Auditing
Service
Consumer
Client
App logic
Kafka Partition
1. Consume a batch of messages from Kafka
2. Process messages and send results to wherever necessary (e.g. another Kafka topic)
3. Confirm delivery to Kafka
Kafka Terminology:
- Commit Mode: Manual
Parallel workers
Partition #1
Partition #2
Partition #N
Electric
Meter
Auditing node #1
Auditing node #2
Auditing node #N
Electric
Readings
Electric
Meter
Electric
Meter
Kafka Terminology:
- Partition Count: >1
- Single Consumer Group
Slide 33
Slide 33 text
Kafka Partition
Kafka Partition
Consumer for parallel processing
DB
Auditing
Service
Consumer
Client
App logic
Kafka Partition
● Same arrangement from consumer perspective
Kafka Terminology:
- Partition Count: >1
- Commit Mode: Manual
Slide 34
Slide 34 text
Orchestration
● Provide Scaling Capability
● Restart or replace failed nodes
Partition #1
Partition #2
Partition #N
Electric
Meter
Auditing node #1
Auditing node #2
Auditing node #N
Electric
Readings
Electric
Meter
Electric
Meter
Mesos/
Marathon New node
Slide 35
Slide 35 text
Stateful Processing
● Example:
Average electricity consumption per meter for the last hour
Electric
Meter
Aggregation
Electric
Readings
Partition
Partition
Partition
Electric
Meter
Electric
Meter
Slide 36
Slide 36 text
Aggregator for
Stream and state
Partition #1
Partition #2
Aggregator for
Electric
Readings
● Data locality
Slide 37
Slide 37 text
Aggregator for
Stream and state
Partition #1
Partition #2
Aggregator for
Key: "meter 1"
Value: 9.2
Key: "meter 2"
Value: 2.7
Electric
Readings
● Data locality
Slide 38
Slide 38 text
Aggregator for
Fault tolerance
Partition #1
Partition #2
Aggregator for
Electric
Readings
● State persistence and recovery
Slide 39
Slide 39 text
Aggregator for
Fault tolerance
Partition #1
Partition #2
Aggregator for
Electric
Readings
Persistence
● State persistence and recovery
Streaming Patterns
Stateful Processing
● Self-managed processing
state
Single Partition Topic
● Strong ordering guarantees
● Limited failure recovery
● Scalability is limited
Multi Partition Topic
● Parallel processing
● Limited ordering guarantees
● Kafka managed processing
state
Fanout
● Independent consumer
groups
Slide 46
Slide 46 text
Kafka libraries
● Kafka client support in many languages
● Scala, Java, C
● C bindings -> Haskell, OCaml, Python etc.
Source Microservice 1 Kafka Microservice 2
Microservice 1
Microservice 1
Microservice 2
Microservice 2
Sink
Slide 47
Slide 47 text
Reactive Streaming APIs
● Similar paradigm as in real-time streaming platforms
● Reactive Kafka
○ Based on Akka Reactive Streams API
○ Scala + Java
○ Developed by Akka team
● Kafka Streams
○ Official streaming API for Kafka
○ Java
○ Developed by Confluent
Slide 48
Slide 48 text
scala-kafka-client
● Kafka client developed for Scala
● Async and non-blocking
● Built on top off the official Java driver
● Easy API with high performance
/cakesolutions /scala-kafka-client
Slide 49
Slide 49 text
scala-kafka-client
● Leverage extensive Akka feature set
● Processing logic implemented using
Actor Model
Kafka
Consumer
Actor
Kafka
Producer
Actor
Receiver
Actor
Kafka Kafka
/cakesolutions /scala-kafka-client
Slide 50
Slide 50 text
Summary
● Leverage Microservice based techniques.
● Streaming topologies can be varied and complex
○ Many use-cases fall under a small set of consumer
patterns.
● Challenges around scalable and reactive data pipelines
● Kafka provides first-class support for reactive streaming to
your applications.
● Stateful processing remains a challenging area.
Slide 51
Slide 51 text
We didn’t discuss...
● Data serialisation
● Application rolling updates
● Complex streaming topologies
Slide 52
Slide 52 text
Questions?
MANCHESTER LONDON NEW YORK
/cakesolutions /scala-kafka-client
@cakesolutions
+44 845 617 1200
[email protected]