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权威指南
78
5
5.4.1
 生产请求
我们在第
3
章讨论如何配置生产者的时候,提到过 acks 这个配置参数——该参数指定了需
要多少个
broker
确认才可以认为一个消息写入是成功的。不同的配置对“写入成功”的界
定是不一样的,如果 acks=1,那么只要首领收到消息就认为写入成功;如果 acks=all,那
么需要所有同步副本收到消息才算写入成功;如果 acks=0,那么生产者在把消息发出去之
后,完全不需要等待
broker
的响应。
包含首领副本的
broker
在收到生产请求时,会对请求做一些验证。
发送数据的用户是否有主题写入权限?
请求里包含的 acks 值是否有效(只允许出现 01 all)?
如果 acks=all,是否有足够多的同步副本保证消息已经被安全写入?(我们可以对
broker
进行配置,如果同步副本的数量不足,
broker
可以拒绝处理新消息。在第
6
章介
Kafka
持久性和可靠性保证时,我们会讨论更多这方面的细节。)
之后,消息被写入本地磁盘。在
Linux
系统上,消息会被写到文件系统缓存里,并不保证
它们何时会被刷新到磁盘上。
Kafka
不会一直等待数据被写到磁盘上——它依赖复制功能
来保证消息的持久性。
在消息被写入分区的首领之后,
broker
开始检查 acks 配置参数——如果 acks 被设为 0 1
那么
broker
立即返回响应;如果 acks 被设为 all,那么请求会被保存在一个叫作
炼狱
的缓冲
区里,直到首领发现所有跟随者副本都复制了消息,响应才会被返回给客户端。 ...
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