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权威指南
92
6
须让两个不可用分区中的一个重新变为可用的(比如重启
broker
),并等待它变为同步的。
6.4
 在可靠的系统里使用生产者
即使我们尽可能把
broker
配置得很可靠,但如果没有对生产者进行可靠性方面的配置,整
个系统仍然有可能出现突发性的数据丢失。
请看以下两个例子。
broker
配置了
3
个副本,并且禁用了不完全首领选举,这样应该可以保证万无一失。
我们把生产者发送消息的 acks 设为 1(只要首领接收到消息就可以认为消息写入成功)。
生产者发送一个消息给首领,首领成功写入,但跟随者副本还没有接收到这个消息。首
领向生产者发送了一个响应,告诉它“消息写入成功”,然后它崩溃了,而此时消息还
没有被其他副本复制过去。另外两个副本此时仍然被认为是同步的(毕竟判定一个副本
不同步需要一小段时间),而且其中的一个副本成了新的首领。因为消息还没有被写入
这个副本,所以就丢失了,但发送消息的客户端却认为消息已成功写入。因为消费者看
不到丢失的消息,所以此时的系统仍然是一致的(因为副本没有收到这个消息,所以消
息不算已提交),但从生产者角度来看,它丢失了一个消息。
broker
配置了
3
个副本,并且禁用了不完全首领选举。我们接受了之前的教训,把
生产者的 acks 设为 all。假设现在往
Kafka
发送消息,分区的首领刚好崩溃,新的首领
正在选举当中,
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