SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
© 2020 anderScore GmbH
Apache Kafka
Gedoplan Expertenkreis Java
25. Juni 2020
29.06.2020
2anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Über anderScore: Wo sitzen wir?
Kölner Altstadt, historisches Stapelhaus
29.06.2020
3anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
● Seit 2005: Kundenprojekte über kompletten Software-Lebenszyklus
● Fokus Java Enterprise:
Systemintegration, Serviceorientierung / Microservices, Web Anwendungen / mobile Apps (z.B. BigBlueButton)
● Trainings (u.a. Gedoplan)
● DevOps, Continuous Integration
● Performance-Optimierungen, Migrationen von Legacy-SW
● Security-Checks & Stabilisierungen (BSI Grundschutz)
! Kein Produkt "von der Stange", sondern Individual-SW
! Agile Methoden, kurze Zyklen  zielorientiert, brauchbare & qualitativ hochwertige Ergebnisse
! Über 20 Großkunden (Branchen u.a. Insurance, Financial, Retail, Telco)
! Partnerschaften: Confluent, Oracle, Cortex (u.a)
! Veranstaltungen: Goldschmiede (u.a.)
Über anderScore: Was tun wir?
29.06.2020
4anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Agenda
1. Was ist Apache Kafka?
2. Die Komponenten
3. Schemas (Apache Avro)
4. Kafka Streams
5. Zusammenfassung
4
9
14
18
22
29.06.2020
5anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Über mich
Jan Lühr
 B. Sc., Computer Science
 Senior Software Engineer & Architect
 anderScore seit 2007
 Fokus
 IT-Trainer
 Pragmatic Architect
 Software Development
 Build- and Deployment Engineering
 Network- and Security-Techniques
 Java, JavaScript, Ruby
29.06.2020
6anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
1. WAS IST APACHE KAFKA?
Überblick
29.06.2020
7anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Motivation | 1. Was ist Apache Kafka?
 Motivation
 Komplexe Datenverteilung
 Batch-Verarbeitung: stark verzögert
 Ansatz
 Middleware für persistierte Logs / Streams
 Ähnlich zu MQTT und Message Queueing
 Ziele von Kafka
 Pipelines vereinfachen
 Data-Stream Handling
Datasource
Datasource
Datasource
Datasource
Datasource
Datasource
DB
Hadoop
Batch
Realtime
29.06.2020
8anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Hintergrund | 1. Was ist Apache Kafka?
 LinkedIn (2010)
 Teil der core-Architektur
 1.4 Billion Nachrichten pro Tag
 Genutzt von:
IBM, Spotify, Uber, Hotels.com, Twitter, …
 Use cases:
 Event Verarbeitung (near realtime)
 Log Aggregation
 Metriken & Analyse
 Messaging / µService Kommunikation
 Keine Realtime- bzw. Echtzeitverarbeitung
(Werbeversprechen)
Bildquelle: https://kafka.apache.org/
29.06.2020
9anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Aufbau | 1. Was ist Apache Kafka?
 Publish-Subscribe-Mechanismus auf
(Producer  Consumer; Topic)
 Producer senden Daten
 Consumer empfangen Daten
 Message (synonym: Record),
Key-Value-Datensatz
 Connectors binden Systeme an (z.B. RDB)
 Stream Processors: Queries auf Streams
(idR. map-reduce)
 Broker (nicht abgebildet): Server-Prozesse;
Storage / Messaging-Komponente
Bildquelle: https://kafka.apache.org/intro
29.06.2020
10anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Topics & Partitions | 1. Was ist Apache Kafka?
 Topic: Logischer Name eines Streams
 Gruppiert Messages; beliebig viele pro Cluster
 Von Kafka verwaltet;
 Beispiel: Printserver mit Kafka
Topic: „Laserjet 1.101“
Topic: „Laserjet 2.202“
 Partition:
 Sharding der Messages durch Producer
 Teilmenge eines Topics
 Ein Topic hat 1..n Partitions
 Auf Broker (Server) verteilt und repliziert
 Lokale Ordnung, append-only
broker1.cluster.local
Topic: Laserjet 1.101
Partition 1
Topic: Laserjet 2.202
Partition 1 Partition 3
broker2.cluster.local
Topic: Laserjet 1.101
Partition 1
Topic: Laserjet 2.202
Partition 2
Producer Consumer
29.06.2020
11anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
2. KOMPONENTEN
Producer, Consumer, Broker, Topics
29.06.2020
12anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Producer | 2. Komponenten
 Teil einer Anwendung
 Anbindung des Producers
 Nativ: Java, C/C++, Python, Go, .Net, JMS
 Rest (Confluent)
 Partitionieren („sharding“) durch Producer
 Motivation: Load-Balancing, semantic partitioning
 Strategie: hash(key) mod #partitions
Falls kein key: round robin
 Eigene Strategien möglich
Quelle: get directly down, Coarsegold Produce Truck, CC-BY,
https://www.flickr.com/photos/65172294@N00/3875462125
29.06.2020
13anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Broker | 2. Komponenten
 Der Broker:
 Ist Server-Prozess (aktiv)
 Empfängt & speichert Nachrichten
 Existiert mehrfach pro Cluster
 Verwaltet mehrere Partitionen
 Message-Speicher: Direkt auf Hard Disk
(Zero Copy)
 Apache Zookeeper hält Quorum
„A replicated group of servers in the same application is called a
quorum, and in replicated mode, all servers in the quorum have
copies of the same configuration file”
https://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html
Waldorf Astoria brokerage, Public Domain,
https://commons.wikimedia.org/wiki/File:Waldorf_Astoria_brokerage.jpg
29.06.2020
14anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Topic & Partition / Log | 2. Komponenten
 Topic
 Entwickler(in) administriert (idR)
 cleanup-policy: compact vs. delete
 Segment Size: head vs. tail
 Besteht aus mehreren Partitions.
 Partition
 Identifier: Offset einer Message, wachsend
 Replication zwischen Brokern möglich
(fault tolerance)
 Clients lesen nur vom Leader
 Drift konfigurierbar
Quelle: https://kafka.apache.org/documentation/
29.06.2020
15anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Consumer | 2. Komponenten
 Abruf von Messages via pull, single-threaded
 Consumer offset
 Nächste zu lesende Nachricht
 Speicher: Spezielles Topic (oder extern)
 Commit: automatisch (default: 5 sec - Obacht!) oder manuell
 Verschiedene Consumer
 Gleichzeitiges Lesen möglich
 Default: Alle Nachrichten im Topic an alle Consumer
 Gruppierung: Consumer Group
 Jede Consumer bearbeitet nur Subset der Partitionen
 Eindeutige Group ID
 Automatisches Error-Handling & Load-Balancing
Quelle: https://kafka.apache.org/documentation/
29.06.2020
16anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
3. SCHEMAS
Apache Avro
29.06.2020
17anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Apache Avro | 3. Schemas
 Apache Avro
 Data Serialization System (& RPC, Container)
 Vergleichbar mit: Thrift, Protocol Buffers
 Aktuell: 1.9.2 (Februar 2020)
 Bindings: Java, Pyhton, C, C++, C#, JavaScript, … (3rd party)
 Teil des Hadoop Projects
 Serialization Format für persistente Daten
 Wire Format für Nodes und Clients
 Schema für Daten in JSON
 Getrennt von den Nutzdaten
 Code-Generatoren (code-first, contract-first)
Quelle: https://avro.apache.org
29.06.2020
18anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Beispiel Avro | 3. Schemas
 Beispiel
Quelle: https://en.wikipedia.org/wiki/Apache_Avro
29.06.2020
19anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Integration in Kafka | 3. Schemas
 Confluent Schema Registry (OpenSource)
 Historisierung, Java & RESTful API, Migration
 Kein Transport mit den Daten (performance)
 Persistenz: Kafka-Topic
 Command Line Client
 Avro als wire-format?
 Einheitliches Schema für Daten zwischen Systemen
 Pro:
 Integration (confluent platform)
 Contra:
 XML & JSON deutlich weiter verbreitet
29.06.2020
20anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
4. KAFKA STREAMS
Streaming-Operationen
29.06.2020
21anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Überblick | 4. Kafka Streams
 Stream-Processing 101
 Stream: unbounded, continous, updating set
 Stream Processor: Transform streamed data
 Processor topology: Data flow through stream
processors
 Kafka Streams
 Java-Library
 Ähnlich zu Spark Streaming, Apache Storm, …
 KafkaStreams DSL (map, flatMap, count, …) vs.
low-level processor API
 Abstraktion: Kstream, Ktable, KSQL
Quelle: https://kafka.apache.org/20/documentation/streams/core-concepts
29.06.2020
22anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Beispiel | 4. Kafka-Streams
Quelle: https://kafka.apache.org/documentation/streams/
29.06.2020
23anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
KStream vs. KTable | 4. Kafka Streams
 KStream: Abstraktion des Record-Streams
 KTable: Abstraktion des Changelog-Streams
 Beispiel: Summation
 Nachricht 1: {id: 'apple', value: 1}
 Nachricht 2: {id: 'apple', value: 2}
 Ergebnis:
 KStream: 3 (Summe der Records)
 KTable: 2 (Update für Nachricht mit ID 'apple')
29.06.2020
24anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
5. Zusammenfassung
1. Apache Kafka: Near-Realtime Streaming Cluster - Kein Message-Queuing System
2. Direkte Verarbeitung kleiner Events
3. Komponenten sind: Producer, Consumer, Broker, Topics, Partitions
4. Schema: Apache Avro Integration via confluent
5. Kafka Streams: Processing API (KTable ./. Kstream) und KSQL
29.06.2020
25anderScore GmbH • Frankenwerft 35 • 50667 Köln
J. Lühr – jan.luehr@anderscore.com
GedoplanKafka.pptx
Fragen
Vielen Dank für Ihre Aufmerksamkeit.
jan.luehr@anderscore.com
… bis zum MiniTraining Kafka?

Contenu connexe

Similaire à Apache Kafka

SplunkLive! Zürich 2016 - Use Case Helvetia
SplunkLive! Zürich 2016 - Use Case HelvetiaSplunkLive! Zürich 2016 - Use Case Helvetia
SplunkLive! Zürich 2016 - Use Case Helvetia
Splunk
 

Similaire à Apache Kafka (20)

Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer InfrastrukturContinuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
 
SplunkLive! Zürich 2016 - Use Case Helvetia
SplunkLive! Zürich 2016 - Use Case HelvetiaSplunkLive! Zürich 2016 - Use Case Helvetia
SplunkLive! Zürich 2016 - Use Case Helvetia
 
SplunkLive! Zürich 2016 - Use Case Helvetia
SplunkLive! Zürich 2016 - Use Case HelvetiaSplunkLive! Zürich 2016 - Use Case Helvetia
SplunkLive! Zürich 2016 - Use Case Helvetia
 
SplunkLive! Frankfurt 2016 - Helvetia Use Case
SplunkLive! Frankfurt 2016 - Helvetia Use CaseSplunkLive! Frankfurt 2016 - Helvetia Use Case
SplunkLive! Frankfurt 2016 - Helvetia Use Case
 
DACHNUG50 CNX3 Monitoring.pdf
DACHNUG50 CNX3 Monitoring.pdfDACHNUG50 CNX3 Monitoring.pdf
DACHNUG50 CNX3 Monitoring.pdf
 
DACHNUG50 CNX2 Troubleshooting hcl connections.pdf
DACHNUG50 CNX2 Troubleshooting hcl connections.pdfDACHNUG50 CNX2 Troubleshooting hcl connections.pdf
DACHNUG50 CNX2 Troubleshooting hcl connections.pdf
 
Entwicklung mit Volt MX und Co. | Teil 1
Entwicklung mit Volt MX und Co. | Teil 1Entwicklung mit Volt MX und Co. | Teil 1
Entwicklung mit Volt MX und Co. | Teil 1
 
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
Fische im Rechenzentrum – Was genau ist eigentlich dieses Redfish und wozu br...
 
On the Portability of Applications in Platform as a Service
On the Portability of Applications in Platform as a ServiceOn the Portability of Applications in Platform as a Service
On the Portability of Applications in Platform as a Service
 
Python in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtPython in der Luft- und Raumfahrt
Python in der Luft- und Raumfahrt
 
Cloud Observability mit Loki, Prometheus, Tempo und Grafana
Cloud Observability mit Loki, Prometheus, Tempo und GrafanaCloud Observability mit Loki, Prometheus, Tempo und Grafana
Cloud Observability mit Loki, Prometheus, Tempo und Grafana
 
Python, Plone und Zope in der Luft- und Raumfahrtforschung
Python, Plone und Zope in der Luft- und RaumfahrtforschungPython, Plone und Zope in der Luft- und Raumfahrtforschung
Python, Plone und Zope in der Luft- und Raumfahrtforschung
 
Cloud Native Computing & DevOps
Cloud Native Computing & DevOpsCloud Native Computing & DevOps
Cloud Native Computing & DevOps
 
Make Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
 
Der Status Quo des Chaos Engineerings
Der Status Quo des Chaos EngineeringsDer Status Quo des Chaos Engineerings
Der Status Quo des Chaos Engineerings
 
Ec2009 Templates
Ec2009 TemplatesEc2009 Templates
Ec2009 Templates
 
Realtime BigData Step by Step mit Lambda, Kafka, Storm und Hadoop
Realtime BigData Step by Step mit Lambda, Kafka, Storm und HadoopRealtime BigData Step by Step mit Lambda, Kafka, Storm und Hadoop
Realtime BigData Step by Step mit Lambda, Kafka, Storm und Hadoop
 
Citrix Day 2014: Panalpina - global und doch nah
Citrix Day 2014: Panalpina - global und doch nahCitrix Day 2014: Panalpina - global und doch nah
Citrix Day 2014: Panalpina - global und doch nah
 
Apache Solr Revisited 2015
Apache Solr Revisited 2015Apache Solr Revisited 2015
Apache Solr Revisited 2015
 
Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
Gewinnung von OPEN SOURCE Techniken für junge UnternehmenGewinnung von OPEN SOURCE Techniken für junge Unternehmen
Gewinnung von OPEN SOURCE Techniken für junge Unternehmen
 

Apache Kafka

  • 1. © 2020 anderScore GmbH Apache Kafka Gedoplan Expertenkreis Java 25. Juni 2020
  • 2. 29.06.2020 2anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Über anderScore: Wo sitzen wir? Kölner Altstadt, historisches Stapelhaus
  • 3. 29.06.2020 3anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx ● Seit 2005: Kundenprojekte über kompletten Software-Lebenszyklus ● Fokus Java Enterprise: Systemintegration, Serviceorientierung / Microservices, Web Anwendungen / mobile Apps (z.B. BigBlueButton) ● Trainings (u.a. Gedoplan) ● DevOps, Continuous Integration ● Performance-Optimierungen, Migrationen von Legacy-SW ● Security-Checks & Stabilisierungen (BSI Grundschutz) ! Kein Produkt "von der Stange", sondern Individual-SW ! Agile Methoden, kurze Zyklen  zielorientiert, brauchbare & qualitativ hochwertige Ergebnisse ! Über 20 Großkunden (Branchen u.a. Insurance, Financial, Retail, Telco) ! Partnerschaften: Confluent, Oracle, Cortex (u.a) ! Veranstaltungen: Goldschmiede (u.a.) Über anderScore: Was tun wir?
  • 4. 29.06.2020 4anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Agenda 1. Was ist Apache Kafka? 2. Die Komponenten 3. Schemas (Apache Avro) 4. Kafka Streams 5. Zusammenfassung 4 9 14 18 22
  • 5. 29.06.2020 5anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Über mich Jan Lühr  B. Sc., Computer Science  Senior Software Engineer & Architect  anderScore seit 2007  Fokus  IT-Trainer  Pragmatic Architect  Software Development  Build- and Deployment Engineering  Network- and Security-Techniques  Java, JavaScript, Ruby
  • 6. 29.06.2020 6anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx 1. WAS IST APACHE KAFKA? Überblick
  • 7. 29.06.2020 7anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Motivation | 1. Was ist Apache Kafka?  Motivation  Komplexe Datenverteilung  Batch-Verarbeitung: stark verzögert  Ansatz  Middleware für persistierte Logs / Streams  Ähnlich zu MQTT und Message Queueing  Ziele von Kafka  Pipelines vereinfachen  Data-Stream Handling Datasource Datasource Datasource Datasource Datasource Datasource DB Hadoop Batch Realtime
  • 8. 29.06.2020 8anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Hintergrund | 1. Was ist Apache Kafka?  LinkedIn (2010)  Teil der core-Architektur  1.4 Billion Nachrichten pro Tag  Genutzt von: IBM, Spotify, Uber, Hotels.com, Twitter, …  Use cases:  Event Verarbeitung (near realtime)  Log Aggregation  Metriken & Analyse  Messaging / µService Kommunikation  Keine Realtime- bzw. Echtzeitverarbeitung (Werbeversprechen) Bildquelle: https://kafka.apache.org/
  • 9. 29.06.2020 9anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Aufbau | 1. Was ist Apache Kafka?  Publish-Subscribe-Mechanismus auf (Producer  Consumer; Topic)  Producer senden Daten  Consumer empfangen Daten  Message (synonym: Record), Key-Value-Datensatz  Connectors binden Systeme an (z.B. RDB)  Stream Processors: Queries auf Streams (idR. map-reduce)  Broker (nicht abgebildet): Server-Prozesse; Storage / Messaging-Komponente Bildquelle: https://kafka.apache.org/intro
  • 10. 29.06.2020 10anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Topics & Partitions | 1. Was ist Apache Kafka?  Topic: Logischer Name eines Streams  Gruppiert Messages; beliebig viele pro Cluster  Von Kafka verwaltet;  Beispiel: Printserver mit Kafka Topic: „Laserjet 1.101“ Topic: „Laserjet 2.202“  Partition:  Sharding der Messages durch Producer  Teilmenge eines Topics  Ein Topic hat 1..n Partitions  Auf Broker (Server) verteilt und repliziert  Lokale Ordnung, append-only broker1.cluster.local Topic: Laserjet 1.101 Partition 1 Topic: Laserjet 2.202 Partition 1 Partition 3 broker2.cluster.local Topic: Laserjet 1.101 Partition 1 Topic: Laserjet 2.202 Partition 2 Producer Consumer
  • 11. 29.06.2020 11anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx 2. KOMPONENTEN Producer, Consumer, Broker, Topics
  • 12. 29.06.2020 12anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Producer | 2. Komponenten  Teil einer Anwendung  Anbindung des Producers  Nativ: Java, C/C++, Python, Go, .Net, JMS  Rest (Confluent)  Partitionieren („sharding“) durch Producer  Motivation: Load-Balancing, semantic partitioning  Strategie: hash(key) mod #partitions Falls kein key: round robin  Eigene Strategien möglich Quelle: get directly down, Coarsegold Produce Truck, CC-BY, https://www.flickr.com/photos/65172294@N00/3875462125
  • 13. 29.06.2020 13anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Broker | 2. Komponenten  Der Broker:  Ist Server-Prozess (aktiv)  Empfängt & speichert Nachrichten  Existiert mehrfach pro Cluster  Verwaltet mehrere Partitionen  Message-Speicher: Direkt auf Hard Disk (Zero Copy)  Apache Zookeeper hält Quorum „A replicated group of servers in the same application is called a quorum, and in replicated mode, all servers in the quorum have copies of the same configuration file” https://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html Waldorf Astoria brokerage, Public Domain, https://commons.wikimedia.org/wiki/File:Waldorf_Astoria_brokerage.jpg
  • 14. 29.06.2020 14anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Topic & Partition / Log | 2. Komponenten  Topic  Entwickler(in) administriert (idR)  cleanup-policy: compact vs. delete  Segment Size: head vs. tail  Besteht aus mehreren Partitions.  Partition  Identifier: Offset einer Message, wachsend  Replication zwischen Brokern möglich (fault tolerance)  Clients lesen nur vom Leader  Drift konfigurierbar Quelle: https://kafka.apache.org/documentation/
  • 15. 29.06.2020 15anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Consumer | 2. Komponenten  Abruf von Messages via pull, single-threaded  Consumer offset  Nächste zu lesende Nachricht  Speicher: Spezielles Topic (oder extern)  Commit: automatisch (default: 5 sec - Obacht!) oder manuell  Verschiedene Consumer  Gleichzeitiges Lesen möglich  Default: Alle Nachrichten im Topic an alle Consumer  Gruppierung: Consumer Group  Jede Consumer bearbeitet nur Subset der Partitionen  Eindeutige Group ID  Automatisches Error-Handling & Load-Balancing Quelle: https://kafka.apache.org/documentation/
  • 16. 29.06.2020 16anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx 3. SCHEMAS Apache Avro
  • 17. 29.06.2020 17anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Apache Avro | 3. Schemas  Apache Avro  Data Serialization System (& RPC, Container)  Vergleichbar mit: Thrift, Protocol Buffers  Aktuell: 1.9.2 (Februar 2020)  Bindings: Java, Pyhton, C, C++, C#, JavaScript, … (3rd party)  Teil des Hadoop Projects  Serialization Format für persistente Daten  Wire Format für Nodes und Clients  Schema für Daten in JSON  Getrennt von den Nutzdaten  Code-Generatoren (code-first, contract-first) Quelle: https://avro.apache.org
  • 18. 29.06.2020 18anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Beispiel Avro | 3. Schemas  Beispiel Quelle: https://en.wikipedia.org/wiki/Apache_Avro
  • 19. 29.06.2020 19anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Integration in Kafka | 3. Schemas  Confluent Schema Registry (OpenSource)  Historisierung, Java & RESTful API, Migration  Kein Transport mit den Daten (performance)  Persistenz: Kafka-Topic  Command Line Client  Avro als wire-format?  Einheitliches Schema für Daten zwischen Systemen  Pro:  Integration (confluent platform)  Contra:  XML & JSON deutlich weiter verbreitet
  • 20. 29.06.2020 20anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx 4. KAFKA STREAMS Streaming-Operationen
  • 21. 29.06.2020 21anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Überblick | 4. Kafka Streams  Stream-Processing 101  Stream: unbounded, continous, updating set  Stream Processor: Transform streamed data  Processor topology: Data flow through stream processors  Kafka Streams  Java-Library  Ähnlich zu Spark Streaming, Apache Storm, …  KafkaStreams DSL (map, flatMap, count, …) vs. low-level processor API  Abstraktion: Kstream, Ktable, KSQL Quelle: https://kafka.apache.org/20/documentation/streams/core-concepts
  • 22. 29.06.2020 22anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Beispiel | 4. Kafka-Streams Quelle: https://kafka.apache.org/documentation/streams/
  • 23. 29.06.2020 23anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx KStream vs. KTable | 4. Kafka Streams  KStream: Abstraktion des Record-Streams  KTable: Abstraktion des Changelog-Streams  Beispiel: Summation  Nachricht 1: {id: 'apple', value: 1}  Nachricht 2: {id: 'apple', value: 2}  Ergebnis:  KStream: 3 (Summe der Records)  KTable: 2 (Update für Nachricht mit ID 'apple')
  • 24. 29.06.2020 24anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx 5. Zusammenfassung 1. Apache Kafka: Near-Realtime Streaming Cluster - Kein Message-Queuing System 2. Direkte Verarbeitung kleiner Events 3. Komponenten sind: Producer, Consumer, Broker, Topics, Partitions 4. Schema: Apache Avro Integration via confluent 5. Kafka Streams: Processing API (KTable ./. Kstream) und KSQL
  • 25. 29.06.2020 25anderScore GmbH • Frankenwerft 35 • 50667 Köln J. Lühr – jan.luehr@anderscore.com GedoplanKafka.pptx Fragen Vielen Dank für Ihre Aufmerksamkeit. jan.luehr@anderscore.com … bis zum MiniTraining Kafka?