apache kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe...

27
Apache Kafka... ...”a system optimized for writing” Bernhard Hopfenmüller 18. Oktober 2018

Upload: others

Post on 30-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Apache Kafka......”a system optimized for writing”

Bernhard Hopfenmüller

18. Oktober 2018

Page 2: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

whoami

Bernhard HopfenmüllerIT Consultant @ ATIX AG

IRC: Fobhepgithub.com/Fobhep

#atix #osad2018

Page 3: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

whoarewe

The Linux & Open Source CompanyGarching @ München

over 15 yearsdatacenter automation, Linux

Consulting, Engineering, Support,Training

#atix #osad2018

Page 4: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Kafka

Quora.com

What is the relation between Kafka, the writer, and Apache Kaf-ka, the distributed messaging system?

Jay Kreps: I thought that since Kafka was a system optimized forwriting using a writer’s name would make sense. I had taken a lotof lit classes in colleague and liked Franz Kafka. Plus the namesounded cool for an OS project

#atix #osad2018

Page 5: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

I developed by LinkedIn, Open Source since 2011

I 2014 foundation of Confluent

#atix #osad2018

Page 6: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Messaging-Systems

Why do we need a messaging system?

#atix #osad2018

Page 7: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Messaging-Systems

Why do we need a messaging system?

I Challenge 1: Sender not available

I Challenge 2: Sending too much(DoS)

I Challenge 3: Receiver crash uponprocessing

#atix #osad2018

Page 8: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Queues vs Topics

Supermarket vs Television Source[1]

Supermarket Wait until it’s your turn Television Choose what you want toreceive

#atix #osad2018

Page 9: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Kafka-Basic structure

#atix #osad2018

Page 10: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Use Cases

I Messaging (ActiveMQ or RabbitMQ)

I Website Activity Tracking

I Metrics

I Log Aggregation

I Stream Processing

I Apache Storm and Apache Samza.

I Commit Log

#atix #osad2018

Page 11: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Topics I

I core component of Kafka

I is filled by producer

I consists of one or more partitions

#atix #osad2018

Page 12: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Topics II

I producer can choose partition

I partition has running offset

I message is identified by offset

#atix #osad2018

Page 13: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Topics III

I messages are stored physically!

I key-value principle

I Clean-Up policies:

#atix #osad2018

Page 14: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Topics IV

I Clean-Up policies:

I default: Retention-time(delete old data after x days)

I Retention-size(delete old data if datamemory > x)

#atix #osad2018

Page 15: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Topics V

I Clean-Up policies:

I default: Retention-time(delete old data after x days)

I Retention-size(delete old data if datamemory > x)

I Log-Compaction(replace old value to key withnew)

#atix #osad2018

Page 16: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Topic consumption

I topics are pulled! (no DoS)

I any existing data can be pulled

#atix #osad2018

Page 17: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Consumer Groups

I parallelism allowshigh throughput

I never more consumersthan partitions

I Kafka features exactly-once-semantics!

#atix #osad2018

Page 18: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Wait but who knows what’s read?

I Consumercommit theiroffset

I Upon failurere-processingpossible

#atix #osad2018

Page 19: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Replication

implemented on partition level

Source[3]

#atix #osad2018

Page 20: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Did somebody hear my message?

Producer decides if message was successfully sentConfiguration possibilities:

I as soon as sent

I as soon as received by first broker

I as soon as desired number of replica exist

#atix #osad2018

Page 21: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Broker and ZooKeeper

I Brokers are stateless!

I Which Broker is alive?

I Broker communication?

I → ZooKeeper!

#atix #osad2018

Page 22: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

ZooKeeper

I distributed, hierachical file system

I management of znodes()

I HA via ensemble (=ZooKeepercluster)

Source[4]

#atix #osad2018

Page 23: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Talk to Kafka - Kafka Connect

Source[7]

I I/O for Kakfa

I Connect with externalsystems

I Source –> KafkaTopic

I Kafka Topic –> Sink

#atix #osad2018

Page 24: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Talk to Kafka - Schema Registry

I define standards

I version and store them

source: confluent

#atix #osad2018

Page 25: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Who likes Kafka?

I zalando - microservices

I Cisco Systems - security

I Airbnb - event pipeline

I Netflix (Monitoring!)

I The New York Times ( Kafka as data storage! Super awesome blogpost) [5][6]

I PayPal

I Spotify

I Twitter

I Uber (Kafka = Backbone!!!)

I https://kafka.apache.org/powered-by

#atix #osad2018

Page 26: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Sources

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

2 https://thecattlecrew.net/2017/09/28/apache-kafka-im-detail-teil-1/ andhttps://thecattlecrew.net/2017/09/28/apache-kafka-im-detail-teil-2/

3 https://www.confluent.io/blog/hands-free-kafka-replication-a-lesson-in-operational-simplicity/

4 https://www.infoq.com/articles/apache-kafka

5 https://www.confluent.io/blog/okay-store-data-apache-kafka/

6 https://www.confluent.io/blog/publishing-apache-kafka-new-york-times/

7 https://www.confluent.io/blog/simplest-useful-kafka-connect-data-pipeline-world-thereabouts-part-1/

#atix #osad2018

Page 27: Apache Kafka - 'a system optimized for writing' · 2019-01-08 · whoarewe TheLinux&OpenSourceCompany Garching@München over15years datacenterautomation,Linux Consulting,Engineering,Support,

Kafka vs MQ

I Kafka has no P2P model!

I Messages are Persistent!

I Topic Partitioning!

I Message Sequencing: for one partition (send order=received order)

I Message reading: Choose where to read, Rewind, no FIFO!

I Loadbalancing: automatic distribution easier with metadata

I HA and failover implemented very easily

#atix #osad2018