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权威指南
90
6
倍的磁盘空间。我们一般会在可用性和存储硬件之间作出权衡。
那么该如何确定一个主题需要几个副本呢?这要看主题的重要程度,以及你愿意付出多少
成本来换取可用性。有时候这与你的偏执程度也有点关系。
如果因
broker
重启导致的主题不可用是可接受的(这在集群里是很正常的行为),那么把
复制系数设为
1
就可以了。在作出这个权衡的时候,要确保这样不会对你的组织和用户造
成影响,因为你在节省了硬件成本的同时也降低了可用性。复制系数为
2
意味着可以容忍
1
broker
发生失效,看起来已经足够了。不过要记住,有时候
1
broker
发生失效会导
致集群不稳定(通常是旧版的
Kafka
),迫使你重启另一个
broker
——集群控制器。也就是
说,如果将复制系数设为
2
,就有可能因为重启等问题导致集群不可用。所以这是一个两
难的选择。
基于以上几点原因,我们建议在要求可用性的场景里把复制系数设为
3
。在大多数情况下,
这已经足够安全了——不过我们也见过有些银行使用
5
个副本,以防不测。
副本的分布也很重要。默认情况下,
Kafka
会确保分区的每个副本被放在不同的
broker
上。
不过,有时候这样仍然不够安全。如果这些
broker
处于同一个机架上,一旦机架的交换
机发生故障,分区就会不可用,这时候把复制系数设为多少都不管用。为了避免机架级别
的故障,我们建议把
broker
分布在多个不同的机架上,并使用 broker.rack 参数来为每个
broker
配置所在机架的名字。如果配置了机架名字,
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