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

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.

相关文章:

  • Vue3+Vite中lodash-es安装与使用指南
  • 48V带极性反接保护-差共模浪涌防护方案
  • 9.RV1126-OPENCV 视频的膨胀和腐蚀
  • 海信IP810N-海思MV320芯片-安卓9-2+16G-免拆优盘卡刷固件包
  • Electron打包前端和后端为exe
  • 【uniapp开发】picker组件的使用
  • Vim查看文件十六进制方法
  • 4. 数据类型
  • Linux开发工具(apt,vim,gcc)
  • git cherry-pick (28)
  • 生产环境问题排查:日志分析与性能瓶颈定位(二)
  • react+taro 开发第五个小程序,解决拼音的学习
  • 从上下文学习和微调看语言模型的泛化:一项对照研究
  • 我的概要设计模板(以图书管理系统为例)
  • 中国区域30m/15天植被覆盖度数据集(2010-2022)
  • 【Pandas】pandas DataFrame reset_index
  • 关于udp——mqtt运行注意事项
  • js鼠标事件大全
  • 6.4 计算机网络面试题
  • 每日算法刷题Day22 6.4:leetcode二分答案3道题,用时1h30min
  • 开个做网站公司/营销推广方案范文
  • 专门做asmr的网站/2345网址导航用户中心
  • 做盗版电影网站问题/自媒体135免费版下载
  • 网站建设备案优化/百度浏览器官网下载并安装
  • 分销/谷歌seo推广培训班
  • 东莞网站平台价格/宣传推广方案范文