Apache Kafka in Practice cover

Apache Kafka in Practice

Rating 4.2
Word count
1.6M words
Chapters
271
ISBN
9787121337765

Tags

Summary

Combining typical use cases, the author provides a fairly comprehensive explanation of the entire Kafka technical system so that readers can draw inferences and apply it directly in practice. The book also explores in some depth Kafka's design principles and its stream-processing components, and provides detailed case studies. The book is divided into 10 chapters: Chapter 1 comprehensively introduces messaging engine systems and Kafka's basic concepts and features, quickly leading readers into the world of Kafka; Chapter 2 briefly reviews the development history of Apache Kafka; Chapter 3 describes in detail how to set up a Kafka cluster environment; Chapters 4 and 5 explore in depth how to use Kafka clients; Chapter 6 gives readers an overview of Kafka's internal design principles; Chapters 7–9 explain Kafka cluster management, monitoring, and tuning through examples; and Chapter 10 introduces Kafka's newly introduced stream-processing component.

Editor's review

Written by Hu Xi and published by Publishing House of Electronics Industry, Apache Kafka in Action is a hands-on guide to Apache Kafka, a mainstream distributed messaging system. The book has earned strong ratings on Douban, where readers generally praise its detailed content and close alignment with production environments. As a seasoned expert in the Kafka field with extensive practical experience, Hu Xi ensures the book's practicality and authority.

From a professional standpoint, the book's greatest value lies in its clear practical orientation. It not only systematically explains Kafka's core concepts, architectural design, and working principles, but more importantly offers in-depth analysis of concrete approaches to cluster deployment, performance tuning, monitoring and operations, and integration with upstream and downstream ecosystems such as Spark and Flink. The book includes numerous configuration examples, troubleshooting approaches, and best practices drawn from real business scenarios, offering direct reference value for developers and architects who are using or planning to use Kafka in mission-critical business systems. It helps readers bridge the gap between understanding concepts and solving real-world problems.

Reading this book, you gain not only a Kafka user manual but also a methodology for building highly reliable, high-performance data pipelines. The book's coverage of Kafka's new features and its outlook on future trends also reflect the timeliness and forward-looking nature of its content. For technical professionals who wish to delve into messaging queues and stream processing, this is a desk reference worth reading closely.

Who it's for

A good fit for

  • Engineers and architects who are using or planning to use Kafka for system development in production environments.
  • Mid- to senior-level backend developers who want a deeper understanding of the principles of distributed messaging systems and stream processing platforms.
  • Operations engineers responsible for Kafka cluster deployment, performance tuning, and day-to-day maintenance.
  • Data platform developers interested in integrating big data ecosystems such as Spark and Flink with messaging queues.

Not a good fit for

  • Complete programming beginners with no foundational concepts of distributed systems or messaging queues.
  • Shallow users who only need to know Kafka's most basic API calls and do not require in-depth principles or operations knowledge.

Reading tips

  1. It is recommended to read alongside a real development or test environment and to practice the configuration and code examples in the book hands-on.
  2. The book can serve as a reference manual; when specific deployment or performance issues arise, consult the relevant chapters as needed.
  3. Pay attention to the author's discussion of design trade-offs and troubleshooting approaches, which is more valuable than memorizing specific commands.

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. 版权信息
  2. 作者介绍
  3. 前言
  4. 第1章 认识ApacheKafka
  5. 1.1Kafka快速入门
  6. 1.1.1 下载并解压缩Kafka二进制代码压缩包文件
  7. 1.1.2 启动服务器
  8. 1.1.3 创建topic
  9. 1.1.4 发送消息
  10. 1.1.5 消费消息
  11. 1.2 消息引擎系统
  12. 1.2.1 消息设计
  13. 1.2.2 传输协议设计
  14. 1.2.3 消息引擎范型
  15. 1.2.4 Java消息服务
  16. 1.3Kafka概要设计
  17. 1.3.1 吞吐量/延时
  18. 1.3.2 消息持久化
  19. 1.3.3 负载均衡和故障转移
  20. 1.3.4 伸缩性
  21. 1.4Kafka基本概念与术语
  22. 1.4.1 消息
  23. 1.4.2 topic和partition
  24. 1.4.3 offset
  25. 1.4.4 replica
  26. 1.4.5 leader和follower
  27. 1.4.6 ISR
  28. 1.5Kafka使用场景
  29. 1.5.1 消息传输
  30. 1.5.2 网站行为日志追踪
  31. 1.5.3 审计数据收集
  32. 1.5.4 日志收集
  33. 1.5.5 Event Sourcing
  34. 1.5.6 流式处理
  35. 1.6 本章小结
  36. 第2 章 Kafka发展历史
  37. 2.1Kafka的历史
  38. 2.1.1 背景
  39. 2.1.2Kafka横空出世
  40. 2.1.3Kafka开源
  41. 2.2Kafka版本变迁
  42. 2.2.1Kafka的版本演进
  43. 2.2.2Kafka的版本格式
  44. 2.2.3 新版本功能简介
  45. 2.2.4 旧版本功能简介
  46. 2.3 如何选择Kafka版本
  47. 2.3.1 根据功能场景
  48. 2.3.2 根据客户端使用场景
  49. 2.4Kafka与Confluent
  50. 2.5 本章小结
  51. 第3章 Kafka线上环境部署
  52. 3.1 集群环境规划
  53. 3.1.1 操作系统的选型
  54. 3.1.2 磁盘规划
  55. 3.1.3 磁盘容量规划
  56. 3.1.4 内存规划
  57. 3.1.5 CPU规划
  58. 3.1.6 带宽规划
  59. 3.1.7 典型线上环境配置
  60. 3.2 伪分布式环境安装
  61. 3.2.1 安装Java
  62. 3.2.2 安装ZooKeeper
  63. 3.2.3 安装单节点Kafka集群
  64. 3.3 多节点环境安装
  65. 3.3.1 安装多节点ZooKeeper集群
  66. 3.3.2 安装多节点Kafka
  67. 3.4 验证部署
  68. 3.4.1 测试topic创建与删除
  69. 3.4.2 测试消息发送与消费
  70. 3.4.3 生产者吞吐量测试
  71. 3.4.4 消费者吞吐量测试
  72. 3.5 参数设置
  73. 3.5.1 broker端参数
  74. 3.5.2 topic级别参数
  75. 3.5.3 GC参数
  76. 3.5.4 JVM参数
  77. 3.5.5 OS参数
  78. 3.6 本章小结
  79. 第4章 producer开发
  80. 4.1 producer概览
  81. 4.2 构造producer
  82. 4.2.1 producer程序实例
  83. 4.2.2 producer主要参数
  84. 4.3 消息分区机制
  85. 4.3.1 分区策略
  86. 4.3.2 自定义分区机制
  87. 4.4 消息序列化
  88. 4.4.1 默认序列化
  89. 4.4.2 自定义序列化
  90. 4.5 producer拦截器
  91. 4.6 无消息丢失配置
  92. 4.6.1 producer端配置
  93. 4.6.2 broker端配置
  94. 4.7 消息压缩
  95. 4.7.1Kafka支持的压缩算法
  96. 4.7.2 算法性能比较与调优
  97. 4.8 多线程处理
  98. 4.9 旧版本producer
  99. 4.10 本章小结
  100. 第5章 consumer开发
  101. 5.1 consumer概览
  102. 5.1.1 消费者(consumer)
  103. 5.1.2 消费者组(consumer group)
  104. 5.1.3 位移(offset)
  105. 5.1.4 位移提交
  106. 5.1.5__consumer_offsets
  107. 5.1.6 消费者组重平衡(consumer group rebalance)
  108. 5.2 构建consumer
  109. 5.2.1 consumer程序实例
  110. 5.2.2 consumer脚本命令
  111. 5.2.3 consumer主要参数
  112. 5.3 订阅topic
  113. 5.3.1 订阅topic列表
  114. 5.3.2 基于正则表达式订阅topic
  115. 5.4 消息轮询
  116. 5.4.1 poll内部原理
  117. 5.4.2 poll使用方法
  118. 5.5 位移管理
  119. 5.5.1 consumer位移
  120. 5.5.2 新版本consumer位移管理
  121. 5.5.3 自动提交与手动提交
  122. 5.5.4 旧版本consumer位移管理
  123. 5.6 重平衡(rebalance)
  124. 5.6.1 rebalance概览
  125. 5.6.2 rebalance触发条件
  126. 5.6.3 rebalance分区分配
  127. 5.6.4 rebalance generation
  128. 5.6.5 rebalance协议
  129. 5.6.6 rebalance流程
  130. 5.6.7 rebalance监听器
  131. 5.7 解序列化
  132. 5.7.1 默认解序列化器
  133. 5.7.2 自定义解序列化器
  134. 5.8 多线程消费实例
  135. 5.8.1 每个线程维护一个KafkaConsumer
  136. 5.8.2 单KafkaConsumer实例+多worker线程
  137. 5.8.3 两种方法对比
  138. 5.9 独立consumer
  139. 5.10 旧版本consumer
  140. 5.10.1 概览
  141. 5.10.2 high-level consumer
  142. 5.10.3 low-level consumer
  143. 5.11 本章小结
  144. 第6章 Kafka设计原理
  145. 6.1 broker端设计架构
  146. 6.1.1 消息设计
  147. 6.1.2 集群管理
  148. 6.1.3 副本与ISR设计
  149. 6.1.4 水印(watermark)和leader epoch
  150. 6.1.5 日志存储设计
  151. 6.1.6 通信协议(wire protocol)
  152. 6.1.7 controller设计
  153. 6.1.8 broker请求处理
  154. 6.2 producer端设计
  155. 6.2.1 producer端基本数据结构
  156. 6.2.2 工作流程
  157. 6.3 consumer端设计
  158. 6.3.1 consumer group状态机
  159. 6.3.2 group管理协议
  160. 6.3.3 rebalance场景剖析
  161. 6.4 实现精确一次处理语义
  162. 6.4.1 消息交付语义
  163. 6.4.2 幂等性producer(idempotent producer)
  164. 6.4.3 事务(transaction)
  165. 6.5 本章小结
  166. 第7章 管理Kafka集群
  167. 7.1 集群管理
  168. 7.1.1 启动broker
  169. 7.1.2 关闭broker
  170. 7.1.3 设置JMX端口
  171. 7.1.4 增加broker
  172. 7.1.5 升级broker版本
  173. 7.2 topic管理
  174. 7.2.1 创建topic
  175. 7.2.2 删除topic
  176. 7.2.3 查询topic列表
  177. 7.2.4 查询topic详情
  178. 7.2.5 修改topic
  179. 7.3 topic动态配置管理
  180. 7.3.1 增加topic配置
  181. 7.3.2 查看topic配置
  182. 7.3.3 删除topic配置
  183. 7.4 consumer相关管理
  184. 7.4.1 查询消费者组
  185. 7.4.2 重设消费者组位移
  186. 7.4.3 删除消费者组
  187. 7.4.4 kafka-consumer-offset-checker
  188. 7.5 topic分区管理
  189. 7.5.1 preferred leader选举
  190. 7.5.2 分区重分配
  191. 7.5.3 增加副本因子
  192. 7.6Kafka常见脚本工具
  193. 7.6.1 kafka-console-producer脚本
  194. 7.6.2 kafka-console-consumer脚本
  195. 7.6.3 kafka-run-class脚本
  196. 7.6.4 查看消息元数据
  197. 7.6.5 获取topic当前消息数
  198. 7.6.6 查询__consumer_offsets
  199. 7.7 API方式管理集群
  200. 7.7.1 服务器端API管理topic
  201. 7.7.2 服务器端API管理位移
  202. 7.7.3 客户端API管理topic
  203. 7.7.4 客户端API查看位移
  204. 7.7.5 0.11.0.0版本客户端API
  205. 7.8 MirrorMaker
  206. 7.8.1 概要介绍
  207. 7.8.2 主要参数
  208. 7.8.3 使用实例
  209. 7.9Kafka安全
  210. 7.9.1 SASL+ACL
  211. 7.9.2 SSL加密
  212. 7.10 常见问题
  213. 7.11 本章小结
  214. 第8章 监控Kafka集群
  215. 8.1 集群健康度检查
  216. 8.2 MBean监控
  217. 8.2.1 监控指标
  218. 8.2.2 指标分类
  219. 8.2.3 定义和查询JMX端口
  220. 8.3 broker端JMX监控
  221. 8.3.1 消息入站/出站速率
  222. 8.3.2 controller存活JMX指标
  223. 8.3.3 备份不足的分区数
  224. 8.3.4 leader分区数
  225. 8.3.5 ISR变化速率
  226. 8.3.6 broker I/O工作处理线程空闲率
  227. 8.3.7 broker网络处理线程空闲率
  228. 8.3.8 单个topic总字节数
  229. 8.4 clients端JMX监控
  230. 8.4.1 producer端JMX监控
  231. 8.4.2 consumer端JMX监控
  232. 8.5 JVM监控
  233. 8.5.1 进程状态
  234. 8.5.2 GC性能
  235. 8.6 OS监控
  236. 8.7 主流监控框架
  237. 8.7.1 JmxTool
  238. 8.7.2 kafka-manager
  239. 8.7.3KafkaMonitor
  240. 8.7.4KafkaOffset Monitor
  241. 8.7.5 CruiseControl
  242. 8.8 本章小结
  243. 第9章 调优Kafka集群
  244. 9.1 引言
  245. 9.2 确定调优目标
  246. 9.3 集群基础调优
  247. 9.3.1 禁止atime更新
  248. 9.3.2 文件系统选择
  249. 9.3.3 设置swapiness
  250. 9.3.4 JVM设置
  251. 9.3.5 其他调优
  252. 9.4 调优吞吐量
  253. 9.5 调优延时
  254. 9.6 调优持久性
  255. 9.7 调优可用性
  256. 9.8 本章小结
  257. 第10章 KafkaConnect与KafkaStreams
  258. 10.1 引言
  259. 10.2KafkaConnect
  260. 10.2.1 概要介绍
  261. 10.2.2 standalone Connect
  262. 10.2.3 distributed Connect
  263. 10.2.4 开发connector
  264. 10.3KafkaStreams
  265. 10.3.1 流处理
  266. 10.3.2KafkaStreams核心概念
  267. 10.3.3KafkaStreams与其他框架的异同
  268. 10.3.4 Word Count实例
  269. 10.3.5KafkaStreams应用开发
  270. 10.3.6KafkaStreams状态查询
  271. 10.4 本章小结

FAQ

Which version of Kafka are the code examples in this book based on?
The book is mainly based on a relatively recent Kafka version at the time of writing; please refer to the preface or relevant chapter notes for the specific version. Since Kafka iterates quickly, be mindful of potential changes to APIs or configurations, though the core architecture and design philosophy retain long-term reference value.
Does the book cover Kafka security authentication and permission management?
Yes. As a practical guide, the book typically covers security topics essential for production environments, such as the configuration and use of SASL and ACL mechanisms; please refer to the table of contents for specific chapters.
What are the advantages of this book compared with the official documentation?
The official documentation focuses on feature descriptions and API references, whereas this book's strengths lie in its integrated, systematic knowledge framework, best practices from real-world experience, solutions to common problems, and approaches to integrating with other systems, offering context and decision guidance closer to engineering practice.

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

胡夕 Author

Hu Xi is a Chinese author of technical books, about whom limited public information is available; the only confirmed representative work is Apache Kafka in Action. The book focuses on Apache Kafka, a distributed streaming platform, and is a practice-oriented technical title classified under artificial intelligence. Judging from the subject matter, Hu Xi's interests lie in message middleware and real-time data processing, and his writing leans toward hands-on application, aimed at developers and engineers who wish to deploy and use Kafka in real projects. Since only one of his works is held in the collection, no reliable information is available about his nationality, dates of birth and death, education, or professional career, and this introduction makes no inferences on those points. Based on the available material, Hu Xi's writing is oriented toward practical implementation, combining platform mechanisms with engineering practice, and his work offers some reference value among Chinese-language learning materials on Kafka.

Top rated in the same category