• Keine Ergebnisse gefunden

Agile Integration

N/A
N/A
Protected

Academic year: 2021

Aktie "Agile Integration"

Copied!
75
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Agile

Integration

PA Agile Integration, Kafka and Event-Streaming Oliver Berger, Nadja Hagen

Tobias Dehn, Christopher Weiß, Uwe Eisele

(2)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(3)

Integration

..of distributed systems is a complex challenge

(4)

Integration in Distributed Systems,

complex challenge lots of things to consider

6

Technologies

Standards (SOAP, REST , JMS)

Data formats (JSON, XML, Avro)

Frameworks

Proprietary Interfaces

Programming Language

Java

C, C#, .Net

Python

Cobol

Application Architecture

Client Server

Monolith

SOA

Microservices

Serverless

Communication Paradigms

Batch

Realtime

Request- Response

Pub-Sub

Fire & Forget

(5)

7

Service

App App App

Service

Service Service Service Service

Cache

Backup Metrics

App Hadoop

Search App

API Gateway

DWH

(6)

8 geheim

(7)

Service

9

App App App

Service

Service Service Service Service

Backup Metrics

App App Hadoop Search

API Gateway

Event Stream

DWH

(8)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(9)

Event-Streaming Platform Kafka

Why should you be interested?

(10)

developed at LinkedIn in 2011 and made open source

can process several trillion (10^12) events per day

originally designed as a messaging queue

based on an abstraction of a distributed commit log

evolved from a messaging queue to a full-fledged event streaming platform

de facto standard for Event-Streaming Platform (> 95%

of Event-Streaming-Projects rely on kafka)

Apache Kafka: The Event Streaming Platform

12

(11)

Thousends of Enterprises rely on Kafka and Event-Streaming

13 Source: https://kafka.apache.org/powered-by

(12)

Possible Applications of Apache Kafka

14

(13)

3 Key Functionalities of a Streaming Platform

15

Pub-Sub Store Process

(14)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(15)

Asynchronous Communication

Why do you need a Messaging System?

(16)

Why do you need a Messaging System ?

31

Sender Receiver

REST RPC Sockets

Challenge 1: Availability

Challenge 2: Processing Velocity

Challenge 3: Processing Acknowledgement

(17)

Solution: Messaging

32

Decoupling via Messaging

Examples for Messaging-Systems:

MQ-Series,

JMS-Messaging ( ActiveMQ, Rabbit-MQ),

Kafka.

Transfermode: Queue or Topic

Messaging System

Sender Receiver

(18)

Queue Mode

1 to 1 Topologie

33

each message gets processed exactly once Queue Producer

Consumer 1

Consumer 2

(19)

Topic Mode

1 to n Topologie

34

each message can be consumed by independeant consumers

each consumer receives all messages after subscription

sequence of messages is guaranteed

only new messages are delivered Topic Producer

Consumer 1

Consumer 2

(20)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(21)

Kafka

Basics & Components

(22)

How would an ideal Publish-Subscribe System look like?

38

Queue

Publisher A Subscriber A

Subscriber B Publisher B

Publisher C

Publish Subscribe

System

Subscriber C Ideal Publish-

Subscribe-System

Unlimited Lookback

Message Retention

Unlimited Storage

No Downtime

Unlimited Scaling

(23)

Key Differences

Messaging is implemented on top of a replicated, distributed

unmutable commit log.

The client has more functionality and, therefore, more

responsibility.

Messaging is optimized for batches instead of individual messages.

Messages are retained even after they are consumed; they can be consumed again.

Kafka Architecture in Comparison to the ideal Pub-Sub System

39

Consequences of these Design Decisions

extreme horizontal scalability

very high throughput

high availability

but different semantics and message delivery guarantees

(24)

Topics in a Publish-Subscribe System

40

Queue Topic A

Producer 1

Topic A Consumer 1

Topic A Consumer M1

Topic B Producer 1

Publish-Subscribe System

Topic B Consumer 1 Topic A Messages

Topic B Messages Topic A

Producer N1

Topic B Producer N2

Topic B Consumer M2

(25)

Broker in a Publish-Subscribe System

41

Topic A Producer 1

Topic A Consumer 1

Topic A Consumer M1

Topic B Producer 1

Topic B Consumer 1 Queue

Broker 1 Topic A Topic B Topic A

Producer N1

Topic B Producer N2

Topic B Consumer M2 Queue

Broker N Topic A Topic B

Zookeeper Cluster

(26)

Partitions: Partition Count 4

42

Topic A Producer 1

Topic A Consumer 1

Topic A Producer 3

Topic A Consumer 2.2 Queue

Broker 1 Topic A

Partition A1 Partition A3

Queue Broker 2 Topic A

Partition A2 Partition A4

Topic A Consumer 2.3

Topic A Consumer 2.1 Consumer Group 1

Consumer Group 2

(27)

The Record The Atomic Unit of Kafka Synonyms: Message or Event

43

Record

key value header

timestamp

optional headers

Creation-time LogAppend-time Business relevant data

(28)

Example: Payment Processing

44

P0:

P1:

Payments Pays 100€ to Bob

Key: Alice

Withdraws 50€

Key: Alice

Deposits 80€

Key: Jenny

Pays 200€ to Jenny Key: Mike

Consumer Group 2 Money Transfer

Instance

Money Transfer Instance Consumer Group 1

Monitoring Instance

(29)

Serialisation

Kafka stores Byte Arrays

45

Serializers Deserializers

Avro JSON

String Custom

(30)

Kafka Commit Log

Abstraction to understand Streaming

46

Immutable, append-only data structure (record,event)

Offset: the position of the record/event in the log

Log

0 1 2 3 4 5 6 7 8 9 10 11 …..

old new

first entry written

next entry to write

(31)

Decoupling Data Producers from Data Consumers

47

Log

0 1 2 3 4 5 6 7 8 9 10 11 ….

Consumer 1 (offset 5)

Consumer 2 (offset 10) reads

reads

Producer 1 writes

(32)

Logical View of Topics, Partitions & Segments Each Partition is a Commit Log

48

Topic A Partition 0 Partition 1

Partition 3

Partition n Partition 2

Partition 0 Segment 0 Segment 1

Segment 3

Segment n Segment 2 Kafka cluster

Topic A Topic B Topic C Topic D Topic E

Topic Z

(33)

Physical View of Topics, Partitions & Segments

50

Broker 102

Partition 1

Partition 2 Segment 0 Segment 1 Segment 2

Segment 0 Segment 1 Segment 2

Partition 0 Partition 1 Broker 101

Partition 1

Partition 1 Partition 0 Broker 102

Broker 103

Partition 0

Broker n ...

Kafka Cluster Topic A

Topic B Topic C

Parallelisation

Scalability

Rolling Files Partition 2

(34)

Brokers in several Data Centers

51

B2 B5

B1

B4 B3

B6

Data Center 1 Data Center 2

Data Center 3

(35)

Managing Log File Growth Retention-Policies

52

Cleanup.policy

delete (default)

Segments too old: retention.ms (default 7 days)

Partitions too large: retention.bytes (default: -1 unlimited)

compact (keep only the freshest value

delete and compact (Example: Order Management)

Cleanup applies to Segment-Files.

messages are guaranteed to live at least as long as retention time

only non-active segment files get deleted upon Cleanup

(36)

Log Compaction

53

Compacted Log 9

5

2 10 11

k3 …..

k2

k1 k5 k4

v6 v10

v3 v11 v12

Log

0 1 2 3 4 5 6 7 8 9 10 11

k1 k2 k1 k3 k4 k2 k5 k5 k3 k3 k5 k4 …..

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 offset

key value

offset key value

time

compating

(37)

Reliability & Durability: Replication of Partitions

54

Kafka cluster

Broker 102 Partition 0

Follower Broker 101

Partition 0 Leader

Broker 103 Partition 0

Follower

Producer 1 Consumer 1

replication factor 3

(38)

Clients interact with Leaders

55

Kafka cluster

Broker 102 Partition 0

Follower Broker 101

Partition 0 Leader

Broker 103 Partition 0

Follower

Producer 1 Consumer 1

Producer 2

Consumer 2

(39)

Leader Failover

56

Kafka cluster

Broker 102 Partition 0

Follower Broker 101

Partition 0 Leader

Broker 103 Partition 0

Follower

Producer 1 Consumer 1

Broker 103 Partition 0

Leader

(40)

In-Sync Replicas

57

Kafka cluster

Broker 101 Leader

Partition 0

0 1 2 3 4 5 6 7 8 9 10

Broker 102 In-sync follower

Partition 0

0 1 2 3 4 5 6 7 8 9

Broker 103 Stuck follower

Partition 0

0 1 2 3 4 5 6 7

ISR

High water mark Log end offset committed

(41)

Load Balancing: Partition Leadership

58

Kafka cluster

Broker 102 Partition 0

Follower Broker 101

Partition 0 Leader

Broker 103 Partition 0

Follower

Producer 2

Consumer 1

Producer 2 Consumer 2

Consumer 3 Consumer 2 Producer 1

(42)

Load Balancing Partitions Leadership (2)

59

Kafka cluster

Producer 1

Consumer 1

Producer 2

Consumer 2

Broker 101 P0

P1 P2

Broker 102 P0

P1 P2

Broker 103 P0

P1 P2

Consumer 3 Consumer Group

(43)

Controller

Election Cluster

Membership Topic

Configuration

Quotas Access

Control Lists

Zookeeper: What is it good for?

60

(44)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(45)

Kafka APIs

(46)

Kafka Core Components: 4 Core-APIs

63

Producer Consumer

Consumer Queue

Producer

Stream

Processor Stream Processor

DB DB

Producer API: Enables to write messages

Consumer API: Enables to read messages

Streams API: Enables to analyze and transform messages

Connect API: Enables the creation of reusable Clients

Consumer Groups

(47)

Kafka Clients supported by Confluent

https://github.com/confluentinc/

examples/tree/5.3.1- post/clients/cloud

client code in many languages

JVM: Java, Groovy, Scala, Kotlin, Clojure

C-Library: C, C#, Go, NodeJS, Python, Ruby,

(48)

Kafka Core Components: Producer API

65

Producer Consumer

Consumer Queue

Producer

Stream

Processor Stream Processor

DB DB Consumer

Groups

(49)

Producer KafkaProducer

Producer API: High Level Architecture &

Design

66

Producer Record

[Partition]

[Headers]

Topic

[key]

Serializer Partitioner

Topic A Partition 0

Batch 0 Batch 1 Batch 2

value [timestamp]

Topic B Partition 1

Batch 0 Batch 1 Batch 2 Fail

? Retry

? send()

No Yes

Yes Can‘t retry

Throw excep Success

return metadata

(50)

Default Partitioner

67

Partition = hash(key) % # partitions

partition 0

partition 1

partition 2

Producer

Partitioner

key1 key 2

key 3 key 4

(51)

Acknowledgement

69

Broker 101 Broker 102 Broker 103 Producer

leader follower follower

1 send

acks=0

Broker 101 Broker 102 Broker 103 Producer

leader follower follower

1 send

acks=1 ack 2

Broker 101 Broker 102 Broker 103 Producer

leader follower follower

1 send

acks=all (-1) ack 4

Broker 104 out of sync replica

2

3

fetch acks

(52)

Development: A Basic Producer in Java

70

(53)

Kafka Core Components: Consumer API

71

Producer Consumer

Consumer Queue

Producer

Stream

Processor Stream Processor

DB DB Consumer

Groups

(54)

Consuming from Kafka: Single Consumer

72

Consumer

P0

P1

P2

P3

(55)

Consuming from Kafka: Consumer Group

73

Consumer 3

P0

P1

P2

P3

Consumer 2

Consumer 4 Consumer 1 Consumer Group

(56)

Consuming from Kafka: Multiple Groups

74

P0

P1

P2

P3

Consumer n group-id = grp-1

Consumer 1 group-id = grp-1 Consumer Group 1

Consumer n group-id = grp-2

Consumer 1 group-id = grp-2 Consumer Group 2

(57)

number of useful consumers in a group is constrained by the

number of partitions

Scalability is limited by Number of Partitions

75

Consumer

P0 P1 P2 P3

Consumer 3

P0 P1 P2 P3

Consumer 2

Consumer 4 Consumer 1

Consumer Group

Consumer 3

P0 P1 P2

Consumer 2

Consumer 4 Consumer 1

Consumer Group

Consumer 5

(58)

How are Partitions assigned to Consumers 1

76

P0 P1 P2

Consumer 3 Consumer 2

Consumer 4 Consumer 1

Consumer Group

Topic A

key1 key 2

key 3 key 4 Producer

Partitioner

key1 key 2

key 3 key 4

(59)

How are Partitions assigned to Consumers 2

77

P0 P1 P2

Consumer 3 Consumer 2

Consumer 4 Consumer 1

Consumer Group

Topic A

key1 key 2

key 3 key 4

Topic B P0

P1 P2

Producer

Partitioner

key1 key 2

key 3 key 4

(60)

How are Partitions assigned to Consumers 3

78

P0 P1 P2

Consumer 3 Consumer 2

Consumer 4 Consumer 1

Consumer Group

Topic A

key1 key 2

key 3 key 4

Topic B P0

P1 P2

partition.assignment.strategy consumer property:

RangeAssignor (used in stream-processing for co- partitioned topics)

RoundRobinAssignor

StickyAssignor

(61)

Consumer Liveliness 1-3

82

Broker 101 Broker 102 Broker 103

Group

coordinator

Broker m

….

Consumer 2

Consumer n Consumer 1

Consumer Group

Group leader

heartbeat

delegates calculation session.timeout.ms

heartbeat.intervall.ms

manages consumer group and partition assignments

calculates partition assignments

Poll

max.poll.intervall.ms

(62)

Offset: Position of a record in the partition

Group_id, topic, partition is tracked in topic: __consumer_offsets

Consumer Offset Topic tracks which message should be read next

Consumers and Offsets

84

Consumer 3

P0

P1

P2

Consumer 2 Consumer 1 Consumer Group

__consumer_offsets

read

write offsets

(63)

Development: Basic Consumer in .NET/C#

85

(64)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(65)

Kafka Examples

Bosch Powertools & Deutsche Bahn Passenger Information

(66)

2.2 X 10^12 messages per day (6 x 10^15 Byte Petabyte)

up to 400 Microservices per cluster

20 – 200 Broker per cluster

Todays Ecosystems are pretty big

88

(67)

RefinemySite Bosch

90

Digital platform for Lean Managemant in construction

Collaborative planning, coordination and communication

Real-time

> 400 Projects, >550 Companies and >100k Daycards

Key functions:

Planing tool

Calendar

Dynamic task design and assignment

Documentation

Statistics (KPIS)

(68)

Kafka as Single Source

of Truth Confluent Cloud Kafka as Event-

Sourcing Backbone

Replication of Data between

Microservices via Topics

Simple Bootstrapping of new Services by

reprocessing the Event Stream

Real-Time & Near Realtime Notifications

of Users

19 independently deployable Units

29 People across Europe, started in

2016

Topics with different Avro-Schemas

RefinemySite: Lean Construction SaaS

91

(69)

Passenger Information of Deutsche Bahn

92

Talk at Confluent Streaming event 11.11.2019

(70)

Facts and Figures

~100 persons in 12 Scrum Teams

24/7 running (DevOps)

multiple daily deployments in production

~100 virtual servers

~100 Microservices

Kafka-Project: DB Passenger Information

93

Kafka

Msg In (Avg)

/sec4k

Broker

6 in 3 AZs

Topic/

Partition

/3,3k320

Msg In

300M/day

Volume In

/day1TB

Volume In

13MB/sec

February 2020 (OOP Talk DB/Novatec)

(71)

Content

Integration

Event-Streaming Platform Kafka

Asynchronous Communication

Kafka Basics & Components

Kafka APIs

Kafka Examples

Kafka Exercises

(72)

Kafka Exercises

Introduction and preparation of the next unit

(73)

Sources

(74)

Sources

1. https://www.enterpriseintegrationpatterns.com/patterns/messaging/

2. Enterprise Integration Patterns, Gregor Hohpe and Bobby Woolf: ISBN 0321200683

3. https://kafka.apache.org/

4. https://www.confluent.io/what-is-apache-kafka/

5. https://www.confluent.io/resources/

6. https://www.informatik-aktuell.de/betrieb/verfuegbarkeit/apache-kafka- eine-schluesselplattform-fuer-hochskalierbare-systeme.html

7. https://www.slideshare.net/KaiWaehner/apache-kafka-vs-integration-middleware-mq- etl-esb?ref=https://www.kai-waehner.de/blog/2019/03/07/apache-kafka-middleware- mq-etl-esb-comparison/

8. https://www.confluent.io/blog/apache-kafka-vs-enterprise-service-bus-esb-friends- enemies-or-frenemies/

9. https://microservices.io

97

(75)

Novatec Consulting GmbH

Dieselstraße 18/1

D-70771 Leinfelden-Echterdingen T. +49 711 22040-700

info@novatec-gmbh.de www.novatec-gmbh.de

Senior Consultant

Christopher Uldack

Christopher.Uldack@novatec-gmbh.de

Senior Managing Consultant

Oliver Berger

Oliver.Berger@novatec-gmbh.de

Referenzen

ÄHNLICHE DOKUMENTE

Please type the title of your abstract for the PSND 2018 Workshop using a Times New Roman 12 font, single-spaced, bold, centered and in lower-case characters.. (1

This work has been digitalized and published in 2013 by Verlag Zeitschrift für Naturforschung in cooperation with the Max Planck Society for the Advancement of Science under

The goal of this work is to develop an application (master) that delegates building and testing to different machines (slaves) with different kinds of operating systems

Berendschot TT, van Norren D (2004) Objective determination of the macular pigment optical density using fundus reflectance spectroscopy.. Berendschot TT, van Norren

Firstly, a thematic division of meanings will be applied to the authentic multimodal explanations taken from two general dictionaries (verbal definition and

Sanja Deletis (sanja.deletis@gmail.com) –pour ce qui concerne Split et Hvar Jadranka Bagarić (jadranka_bagaric@hotmail.com) – pour ce qui

From an economic and environmental point of view, fracking is thus unlikely to bring large benefits for Europe and shale gas might just substitute for conventional gas

The main proposition of Baskerville and Myers, that IS research should participate more actively in the process of setting research topics, leads to the question which