Grigory Koshelev - Hast du es mit Kafka versucht?

Apache Kafka ist ein verteilter Software-Nachrichtenbroker, mit dem große Datenmengen in Echtzeit verarbeitet werden. Die besonderen Merkmale von Apache Kafka sind: Zuverlässigkeit, Skalierbarkeit und hohe Leistung. Im Vortrag werden wir die wichtigsten architektonischen Merkmale und Anwendungsfälle für Apache Kafka analysieren. Betrachten Sie die nicht offensichtlichen Momente und Rechen, die wir auf dem Weg nach Osten gesammelt haben.















Hallo, alle miteinander! Ich heiße Grigory! Und heute werden wir über Kafka sprechen.







Wir werden den folgenden Plan haben:







  • Kafka, .
  • , , . . Kafka.
  • .
  • – - . - «, », .
  • . : - .


:







[TOC]







Kafka?



- Vostok.







, . . . Hercules . , , , , .







- , , - .







Kafka .













. . , , . Kafka - . Spark, , . .







Kafka 2 , . . .







? Java stack.







Kafka 0.11, Python, DotNet Kafka 1 . stack – DotNet, . Kafka .







Kafka , . , - . - . .













, Apache Kafka



Apache Kafka



, , , Kafka . – producer. Producer – , -.













consumer. , - .













. , Apache Kafka – . , .













.













.













, producer consumer , . , Message Queue. , .













Publish-Subscribe, . . , consumers . consumers.







, poll-, . . : «, consumer, . ». consumer Kafka : « - ?». .







, , consumers.







Apache Kafka



  • Topic
  • Broker
  • Producer
  • Consumer


4 . , , producer consumer. .







Kafka Topic









– , producers, consumers. - . – .







. . ?













  • .








  • . , .








, offset. 0.







. Offset = 0













.













. , . , .







- .













.













, . . 1 , 2 . .













.













- . , . , . .













.







offset, .













. offset .













, , . data, index, timeindex – .













Data – , . . - . . . Kafka , , .













index? - , . index .













. index 8 . int: relative offset, positon.







Relative offset – .







offset , offset, .







, offset int. , offset int.







position. Position – -.













, relative offset , .













-.













. , . offset relative offset , .







, , - . , . Kafka.













timeindex. ? Kafka - . . Timeindex .







Kafka Broker









, . – .







.













. .













, . . .







Kafka , replication factor . , .













, . , .







4 , .







Kafka .













, , .







– , . producers , .







. , . .













– , . . - , - .













.













, . .







Kafka , , -, . , .













? , , . , , follower. .













, , , in sync replica. , .













, . . in sync replica.







, - . follower, ? ? follower . , .













, ?







3 2, . , .













Kafka , . . , .













. .













, , , , .













. . . .













Kafka , – .













? , . . , . Kafka . , .







Kafka Producer









, . . , .







. , , .







Kafka , – , , . , . consumer , .













? , . MurmurHash , .













, round robin, , . . , ..







point: . . . - , . . , , . .







, Kafka , . – offset, timestamp . .













. . .







. 9 .













, . Kafka, acknowledgement, . . . ,













. ?













. , .













.







Kafka, . - . 0 . . .













. 1.













? . Kafka. Kafka . .













. , .













, .







?













Followers : « ?». : «». . . . , , .













, , . all, .













? .













, .













followers .













, . , .













, , , , .













, .







. min.insync.replicas.













3, , , 3 , . . + 2.







, , , , -1



.







Kafka Consumer









, consumer. . consumer . , . - .













, .































.













?













- .













.













- .































version polled Kafka . , , .







. , , . , . . , Kafka. , commit offset.













?













consumer, .













, , . Kafka: « ». , .













- .













. . . .













consumer , , .













.













, .







- .













consumer, .













. ? , consumer , consumer . , Kafka .













consumers . .













, .













- offset, .













, .













– , -.













? -, .













.













consumer .













.













.













consumer , . .













- , .







, , . , .







Kafka



.







, .







, - .







, Kafka.









. ? . .







Kafka. log.dirs. , , .













. , - .







– , . , , , .













?













1 , . GC .







. , . Kafka , . , .













— unclean.leader.election.enable=false. 0.11 .







KIP-106 — Change Default unclean.leader.election.enabled from True to False (0.11)













. . . ? , .







. , . ? , . . 1 - , 0 .







, 0.













1 , . .







, , . , , .













https://issues.apache.org/jira/browse/KAFKA-3410







Kafka . , 1.1.







. .















. . default.replication.factor = 1.







, . , Kafka , dev- , , default.replication.factor - , . .







, replication.factor, .













– auto.create.topics.enable = true.







. ? , , - , Kafka : «, - ». . , . . replication.factor =1. production, replication.factor, - replication.factor = 1. , - . - .







, , .













. , , , consumer . , .







, Kafka .













, message.max.bytes. 1 000 012 .







? , . , Kafka.













, , . , . consumer , . , consumer , , . - . Kafka Java , Scala.







? - , , , production. , , . . . , .







.















. . , . . , Kafka .







Kafka , batch.size. , . 16 – , Kafka- , . . . Kafka, , . , . .







. , 10. . . 160 performance.







, , .







production. , 10. , 160 , 10 . production 1,5 .







? , , . . , . . - . - . .







?













, Kafka KIP-126 — Allow KafkaProducer to split and resend

oversized batches (0.11)







KIP (Kafka Improvement Proposals) – , Kafka, . . .







KIP 0.11 . Kafka producer, , - , Kafka.







, . , . , . , , , , .







, . . . .







. : « ». . , . .







API — send









API, send. ? , Kafka API, . . , Kafka, future. . , , . , send , . . future , . – , . , , , . . . . , . 60 .







. - , . , , Kafka , .













KIP-286: producer.send() should not block on metadata update (discuss)







, ? , , , . , : « ». KIP discuss. , - . , Kafka . , .







API —









, . , , consumer. , poll-, . . consumer Kafka . , consumer :







, Kafka. - - . , . .







consumer.poll ConsumerRecords. Key Event. - , . - Kafka , ?







, . , , . , . .













? fetcher, stack trace , poll.







, message exception: , - - offset. , - . – , . , . offset, offset.







, exception, , partition, , . , , offset .







, , . , .













, . .













.













, . , , .













. ?













, ? . . .







, ?







, .













, exception, . null, .







, .













. . , , , , , .







, consumer.







API —









. . .







, . .













.













, , , , .













, . .













?













KIP-41: KafkaConsumer Max Records (0.10).







, , . KIP .







round robin, . consumer’ . . , . , . .













KIP-387: Fair Message Consumption Across Partitions in KafkaConsumer (discuss)







Google: « ?». KIP – .







discuss. , , , , -. , , . . .

















. DevOps. .







- : « . ? ». . , .







, . – retention.bytes.







Retention.bytes , . . log.retention.bytes – , .







, , per partition, . . .







. – 1 . 3 – . . . , .







, .















KIP-113: Support replicas movement between log directories (1.1)







, , , Kafka . , KIP, . , , . ! , «».







Kafka - «». . - , . , .







- , - , - . , - .







, . , .













KIP-178: Size-based log directory selection strategy (discuss)







KIP, - , discuss, . . , . , .















, ? . .







. bash-, partition reassignment.







«», , JSON, bash-, - .







:







, - .







. . , , .













«».













preferred leader. , , , , – ? .







, JSON. , , . , . , .















? ?







  • . . .







  • API. , . , .







  • , DevOps







  • , . KIP . , , , .







  • ! Kafka – , . .









, . !













, , ? . . , ? , , – , 3 , 4, ?







. : – . ? , . . , . . . partition reassignments. , , . , . , bash- . 5 , 10 . .







, , . .







! Kafka . , , consumers . -, Kafka. , , bash-, - , , . -. true way, , . , .







! , partitions ? , partitions ?







, . , , , . , , . , ( value ), . compaction. Kafka , , , , 10 . . . , , . .







. - best practices partitions, . . consumers consumer groups?







. , , , – . ? , . , , . , consumer group , . - consumers , , . . . .







! ! , ? . - ?







. , , . . , . , Dot Net . – - -.







! , Kafka, . . Kubernetes? Kubernetes, helm charts ? failed offset commit?







Kubernetes. Kubernetes , . . Kafka Kubernetes . . . . , Kafka Kubernetes, . failed commit offset, , , consumers . Consumer, , , . , : « » . . . . GC consumer, . , , , .







. . , consumer . ? , , . , , consumers . consumers . . . . , consumers. -. . .







! consumers, . . , , , , consumer?







, consumer , . . , consumer 3 , . .







! . user case, Kafka ? Postgres, , Kafka , Postgres. , .







Das Absurdeste wurde dort speziell ausgewählt. Ich wollte eine absurde Situation in dem Sinne zeigen, dass man, wenn man Kafka mit seinen architektonischen Dingen kennenlernt, sieht, wie gut sie gemacht sind und sich einfach in die Technologie verliebt. Die Technologie ist wirklich cool. Das war Punkt. Hier geht es nicht darum, Postgres durch Kafka zu ersetzen. Nein natürlich nicht.







Wofür verwenden wir Kafka? Wir haben eine Reihe von Microservices, Tausende von Instanzen gestartet. Wir sammeln Protokolle von ihnen, und in Zukunft gibt es noch eine Aufgabe für die Rückverfolgung, dh wir möchten Informationen über Netzwerkinteraktionen zwischen Mikrodiensten über Kafka aggregieren. Und auch Metriken, Anwendungen, d. H. Die Anzahl von Anforderungen, Fehlern usw.








All Articles