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权威指南
76
5
找到首选首领
从分区的副本清单里可以很容易找到首选首领(可以使用
kafka.topics.sh
具查看副本和分区的详细信息,我们将在第
10
章介绍管理工具)。清单里的
第一个副本一般就是首选首领。不管当前首领是哪一个副本,都不会改变这
个事实,即使使用副本分配工具将副本重新分配给其他
broker
。要记住,如
果你手动进行副本分配,第一个指定的副本就是首选首领,所以要确保首选
首领被传播到其他
broker
上,避免让包含了首领的
broker
负载过重,而其他
broker
却无法为它们分担负载。
5.4
 处理请求
broker
的大部分工作是处理客户端、分区副本和控制器发送给分区首领的请求。
Kafka
供了一个二进制协议(基于
TCP
),指定了请求消息的格式以及
broker
如何对请求作出
响应——包括成功处理请求或在处理请求过程中遇到错误。客户端发起连接并发送请求,
broker
处理请求并作出响应。
broker
按照请求到达的顺序来处理它们——这种顺序保证让
Kafka
具有了消息队列的特性,同时保证保存的消息也是有序的。
所有的请求消息都包含一个标准消息头:
Request type
(也就是
API key
Request version
broker
可以处理不同版本的客户端请求,并根据客户端版本作出不同
的响应)
Correlation ID
——一个具有唯一性的数字,用于标识请求消息,同时也会出现在响应消
息和错误日志里(用于诊断问题)
Client ID
——用于标识发送请求的客户端
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