当前位置: 首页 > article >正文

Kafka broker 写消息的过程

Producer → Kafka Broker → Replication → Consumer|Partition chosen (by key or round-robin)|Message appended to end of log (commit log)

上面的流程是kafka 写操作的大体流程。

kafka 不会特意保留message 在内存中,而是直接写入了disk。
那么消费的时候,如果是最近 produced 的message,即使写入了disk,还是会保留在OS的page cache中。 OS page cache 即使是flush 到了disk,也不会被立刻清除,这个是OS 自己的机制。 所以consumer 读最近生产的消息的时候,还是可以从page cache中读取出来的,而不用从disk 中读取。

  1. Kafka Broker Receives the Message
    决定partition

  2. Message is Appended to a Partition Log
    The selected broker appends the message to the end of the partition log (a sequential write).
    Kafka writes messages to disk efficiently using write-ahead logs (WAL).

  3. Replication (for Fault Tolerance)
    Kafka waits for acknowledgments based on the producer’s acks setting:
    acks=0: Producer doesn’t wait.
    acks=1: Wait for leader only.
    acks=all: Wait for all replicas to acknowledge.

  4. Message is Made Available to Consumers
    Once the acks is fulfilled, it becomes available for consumers.
    Consumers read sequentially using offsets.
    Kafka keeps messages for a retention period (e.g., 7 days), regardless of whether they’ve been consumed.

http://www.lryc.cn/news/2400836.html

相关文章:

  • VR博物馆推动现代数字化科技博物馆
  • Python爬虫之数据提取
  • 第2讲、Odoo深度介绍:开源ERP的领先者
  • 【TCP/IP和OSI模型以及区别——理论汇总】
  • 【HarmonyOS 5】生活与服务开发实践详解以及服务卡片案例
  • LEAP模型能源需求/供应预测、能源平衡表核算、空气污染物排放预测、碳排放建模预测、成本效益分析、电力系统优化
  • STM32 I2C通信外设
  • 13. springCloud AlibabaSeata处理分布式事务
  • MySQL 表的内连和外连
  • VR线上展厅特点分析与优势
  • Python基于SVM技术的手写数字识别问题项目实战
  • Elasticsearch的写入性能优化
  • 2024年数维杯国际大学生数学建模挑战赛A题飞行器激光测速中的频率估计问题解题全过程论文及程序
  • AWS 成本异常检测IAM策略
  • 解决Vue3+uni-app导航栏高亮自动同步方案
  • DeepSeek+SpringAI实现流式对话
  • 【Spark征服之路-2.1-安装部署Spark(一)】
  • VS代码生成工具ReSharper v2025.1——支持.NET 10和C# 14预览功能
  • 【Godot】如何导出 Release 版本的安卓项目
  • VSCode 工作区配置文件通用模板(CMake + Ninja + MinGW/GCC 编译器 的 C++ 或 Qt 项目)
  • js鼠标事件大全
  • Java八股文——Redis篇
  • 爬虫接口类型判断与表单需求识别全解析
  • Photoshop智能图层 vs 普通图层:核心差异与适用场景对比
  • Chainlink:连接 Web2 与 Web3 的去中心化桥梁
  • [Java 基础]面向对象-继承
  • 编译一个Mac M系列可以用的yuview
  • LeetCode - 876. 链表的中间结点
  • 概率单纯形(Probability Simplex)
  • Go语言爬虫系列教程4:使用正则表达式解析HTML内容