Skip to Content
Kafka权威指南(第2版)
book

Kafka权威指南(第2版)

by Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty
November 2022
Beginner to intermediate
346 pages
11h
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南(第2版)
流式处理
301
即使是一个简单的应用程序也会有不简单的拓扑。拓扑由处理器组成,处理器是拓扑图中
的节点(在图中用椭圆表示)。大部分处理器实现了一个数据操作——过滤、映射、聚合
等。数据源处理器从主题读取数据,并将数据传给其他组件,数据池处理器从处理器接收
数据,并将数据生成到主题上。拓扑总是从一个或多个数据源处理器开始,并以一个或多
个数据池处理器结束。
14.5.2
 优化拓扑
默认情况下,在执行使用
DSL API
构建的应用程序时,
Streams
会将每个
DSL
方法独立映
射到一个底层的等价对象。因为每个
DSL
方法都是独立计算的,所以错失了优化整体拓扑
的机会。
Streams
应用程序的执行分为
3
个步骤。
1.
通过创建
KStream
对象和
KTable
对象并对它们执行
DSL
操作(比如过滤和连接)来定
义逻辑拓扑。
2.
调用
StreamsBuilder.build()
,从逻辑拓扑生成物理拓扑。
3.
调用
KafkaStreams.start()
执行拓扑,这是读取、处理和生成数据的步骤。
在第
2
个步骤中,也就是从逻辑拓扑生成物理拓扑这一步,可以对执行计划进行整体优化。
目前,
Kafka
只提供了一部分优化
,主要与重用主题有关。可以通过将
StreamsConfig.
TOPOLOGY_OPTIMIZATION
设置成
StreamsConfig.OPTIMIZE
并调用
build(props)
来启用这些优
化。如果只调用
build()
但没有传入配置,则仍然无法启用优化。建议对启用了优化和没
有启用优化的应用程序进行测试,比较执行时间和写入 ...
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

时间序列分析实战:基于机器学习和统计学

时间序列分析实战:基于机器学习和统计学

Aileen Nielsen
Spark机器学习实战

Spark机器学习实战

Posts & Telecom Press, Siamak Amirghodsi, Meenakshi Rajendran, Broderick Hall, Shuen Mei
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik
Kubernetes编程

Kubernetes编程

Michael Hausenblas, Stefan Schimanski

Publisher Resources

ISBN: 9787115601421