Skip to Content
Kafka权威指南
book

Kafka权威指南

by Neha Narkhede, Gwen Shapira, Todd Palino
January 2018
Beginner to intermediate
234 pages
7h 8m
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南
流式处理
205
理。与其他流式处理框架不一样的是,
Streams
通过使用新的键和分区将事件写到新的主
题来实现重新分区,并启动新的任务从新主题上读取和处理事件。重新分区的步骤是将拓
扑拆分成两个子拓扑,每个子拓扑都有自己的任务集,如图
11-13
所示。第二个任务集依
赖第一个任务集,因为它们处理的是第一个子拓扑的结果。不过,它们仍然可以独立地并
行执行,因为第一个任务集以自己的速率将数据写到一个主题上,而第二个任务集也以自
己的速率从这个主题读取和处理事件。两个任务集之间不需要通信,也没有共享资源,而
且它们也不需要运行在相同的线程里或相同的服务器上。这是
Kafka
提供的最有用的特性
之一——减少管道各个部分之间的依赖。
主题
分区1
分区2
分区1
分区2
任务1
任务2
任务3
任务4
重分区主题
11-13:处理主题分区事件的两组任务
11.5.3
 从故障中存活下来
Streams
的伸缩模型不仅允许伸缩应用,还能优雅地处理故障。首先,包括本地状态在内
的所有数据被保存到有高可用性的
Kafka
上。如果应用程序出现故障需要重启,可以从
Kafka
上找到上一次处理的数据在流中的位置,并从这个位置开始继续处理。如果本地状
态丢失(比如可能需要将服务器替换掉),应用程序可以从保存在
Kafka
上的变更日志重
新创建本地状态。
Streams
还利用了消费者的协调机制来实现任务的高可用性。如果一个任务失败,只要还
有其他线程或者应用程序实例可用,就可以使用另一个线程来重启该任务。这类似于消费
者群组的故障处理,如果一个消费者失效,就把分区分配给其他活跃的消费者。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron
精通特征工程

精通特征工程

Alice Zheng, Amanda Casari
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115473271