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权威指南
4
1
1.2
 
Kafka
登场
Kafka
就是为了解决上述问题而设计的一款基于发布与订阅的消息系统。它一般被称为
“分布式提交日志”或者“分布式流平台”。文件系统或数据库提交日志用来提供所有事务
的持久记录,通过重放这些日志可以重建系统的状态。同样地,
Kafka
的数据是按照一定
顺序持久化保存的,可以按需读取。此外,
Kafka
的数据分布在整个系统里,具备数据故
障保护和性能伸缩能力。
1.2.1
 消息和批次
Kafka
的数据单元被称为
消息
。如果你在使用
Kafka
之前已经有数据库使用经验,那么可
以把消息看成是数据库里的一个“数据行”或一条“记录”。消息由字节数组组成,所以
对于
Kafka
来说,消息里的数据没有特别的格式或含义。消息可以有一个可选的元数据,
也就是键。键也是一个字节数组,与消息一样,对于
Kafka
来说也没有特殊的含义。当消
息以一种可控的方式写入不同的分区时,会用到键。最简单的例子就是为键生成一个一致
性散列值,然后使用散列值对主题分区数进行取模,为消息选取分区。这样可以保证具有
相同键的消息总是被写到相同的分区上。第
3
章将详细介绍键的用法。
为了提高效率,消息被分批次写入
Kafka
批次
就是一组消息,这些消息属于同一个主题
和分区。如果每一个消息都单独穿行于网络,会导致大量的网络开销,把消息分成批次传
输可以减少网络开销。不过,这要在时间延迟和吞吐量之间作出权衡:批次越大,单位时
间内处理的消息就越多,单个消息的传输时间就越长。批次数据会被压缩,这样可以提升
数据的传输和存储能力,但要做更多的计算处理。 ...
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