Kafka4.0.0版本的内容可参考https://cwiki.apache.org/confluence/display/KAFKA/Release+Plan+4.0.0
Apache Kafka 4.0 作为分布式流处理平台的重要版本,带来了架构和功能上的重大革新。该版本不仅实现了关键的架构转型,还涉及多项功能的弃用与更新,是 Kafka 演进历程中的一个重要里程碑。本文将深入探讨版本变更内容、迁移策略以及未来 Kafka 4.x 系列的发展方向。
0.发布时间
KIP Freeze时间:2024年11月20日
Feature Freeze时间:2024年12月11日
Code Freeze时间:2025年1月29日
至少两周的稳定性测试后,期待在2025年1月29日之后发布。
1.版本演进:Kafka 3.x 为 4.0 奠定基础
Kafka 3.x 系列通过多项重要更新为 4.0 版本的发布做好了充分准备,主要演进包括:
1.1.KRaft 模式正式引入
自 3.6 版本起,KRaft(Kafka Raft Metadata Mode)作为 ZooKeeper 的替代方案达到生产就绪状态,提供了更简洁高效的集群元数据管理机制。
1.2.JBOD 存储支持增强
3.7 版本优化了 KRaft 集群的存储配置,显著提升了集群迁移的灵活性。
1.3.功能演进与预览
逐步弃用 Java 11 和 Log4j appender
通过 KIP-848 引入新一代消费者组再平衡协议
为 4.0 版本的核心功能奠定技术基础
1.4.动态 KRaft Quorum
3.9 版本引入的控制器节点动态调整能力,实现了集群的无缝扩展,使其成为向 Kafka 4.0 过渡的关键版本。
1.5.完整需求列表
KIP-1043: Administration of groups
KIP-1089: Allow disabling heartbeats replication in MirrorSourceConnector
KIP-1074: Allow the replication of user internal topics
KIP-1073: Return fenced brokers in DescribeCluster response
KIP-1112: allow custom processor wrapping
KIP-1106: Add duration based offset reset option for consumer clients
KIP-1105: Make remote log manager thread-pool configs dynamic
KIP-1104: Allow Foreign Key Extraction from Both Key and Value in KTable Joins
KIP-1099: Extend kafka-consumer-groups command line tool to support new consumer group
KIP-1091: Improved Kafka Streams operator metrics
KIP-1085: Fix leaking *_DOC variables in StreamsConfig
KIP-1087: Removing intermediateTopicsOption from StreamsResetter
KIP-1082: Require Client-Generated IDs over the ConsumerGroupHeartbeat RPC
KIP-1079: Deprecate delete-config
of TopicCommand
KIP-1078: Remove Leaking Getter Methods in Joined Helper Class
KIP-1077: Deprecate ForeachProcessor
and move to internal package
KIP-1076: Metrics for client applications KIP-714 extension
KIP-1075: Introduce delayed remote list offsets purgatory to make LIST_OFFSETS async
KIP-1070: deprecate MockProcessorContext
KIP-1065: Add "retry" return-option to ProductionExceptionHandler
KIP-1058: Txn consumer exerts pressure on remote storage when collecting aborted transactions
KIP-1056: Remove default.
prefix for exception handler StreamsConfig
KIP-950: Tiered Storage Disablement
KIP-1041: Drop offsets.commit.required.acks
config in 4.0 (deprecate in 3.8)
KIP-1032: Upgrade to Jakarta and JavaEE 10 in Kafka 4.0
KIP-1030: Change constraints and default values for various configurations
KIP-1013: Drop broker and tools support for Java 11 in Kafka 4.0 (deprecate in 3.7)
KIP-1011: Use incrementalAlterConfigs when updating broker configs by kafka-configs.sh
KIP-970: Deprecate and remove Connect's redundant task configurations endpoint
KIP-996: Pre-Vote
KIP-966: Eligible Leader Replicas
KIP-932: Queues for Kafka
KIP-896: Remove old client protocol API versions in Kafka 4.0
KIP-890: Transactions Server-Side Defense (Phase 2)
KIP-848: The Next Generation of the Consumer Rebalance Protocol
KIP-724: Drop support for message formats v0 and v1
KIP-653: Upgrade log4j to log4j2
2.Kafka 4.0 核心变更解析
主要有以下核心变更:
(1)全面转向 KRaft 模式
(2)ZooKeeper 依赖被彻底移除,KRaft 成为唯一的元数据管理协议
2.1.转向KRaft模式
KRaft模式有以下几点优势:
(1)简化集群架构,降低运维复杂度
(2)提升系统可扩展性和可靠性
(3)优化元数据操作性能
迁移支持:3.6-3.9 版本提供的迁移工具链可平滑完成 ZooKeeper 到 KRaft 的过渡
2.2.MirrorMaker 1 正式退役
MirrorMaker 2 完全取代 MirrorMaker 1
影响范围:主要涉及仍在使用旧版 MirrorMaker 的用户群体
意义:推动数据复制方案向更现代化、更高效的架构演进
2.3.日志系统升级至 Log4j2
完成从 Log4j 到 Log4j2 的全面迁移,有以下改进点:
(1)修复 Log4Shell 等安全漏洞
(2)提升日志系统性能
(3)实现与现代日志标准的完全兼容
3.Kafka 4.0 迁移和升级指南
下面是迁移到Kafka 4.0版本的基本方法。
3.1.迁移路径规划
对于仍在使用 ZooKeeper 集群的组织,升级到 Kafka 4.0 需要遵循特定的迁移路径:
3.1.1.版本升级
首先升级至 Kafka 3.9 版本;对于运行 Kafka 2.3 或更早版本的集群,需先升级至兼容的 ZooKeeper 版本(建议 3.8+)。
3.1.2.架构迁移
完成从 ZooKeeper 到 KRaft 模式的迁移;建议在生产环境进行充分验证。
3.1.3.最终升级
迁移完成后,升级至 Kafka 4.0 版本。
3.2.基础设施考量
主要针对不同的环境。
3.2.1.生产环境
必须配置专用的 KRaft 控制器节点;建议采用三节点或五节点的控制器仲裁(Quorum)配置。
3.2.2.非生产环境
可暂时采用混合模式运行(注意混合模式仅适用于开发和测试环境);允许在过渡期间同时使用 ZooKeeper 和 KRaft。
3.3.兼容性验证
迁移后需要进行客户端测试和功能测试。
3.3.1.客户端测试
:验证客户端应用程序与新版本协议的兼容性;重点关注 KIP-848 引入的协议变更。
3.3.2.功能验证
:建议在 Kafka 3.x 版本中预先测试 KIP-848 等新特性;识别并解决潜在的兼容性问题。
4.Kafka 4.x 未来展望
Kafka 社区正在积极推进以下方向的改进:
4.1.容器化支持增强
优化 Kubernetes 等容器平台的部署体验;改进 StatefulSet 支持;增强容器环境下的监控和运维能力。
4.2.可观测性提升
提供更细粒度的监控指标;优化性能监控体系;增强诊断和调试能力。
4.3.消费者架构优化
全面实现 KIP-848 协议;采用事件驱动架构优化消费者再平衡流程;提升消费者组的稳定性和性能。