当前位置: 首页 > 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.

http://www.dtcms.com/a/230795.html

相关文章:

  • 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
  • 华为云Flexus+DeepSeek征文|实战体验云服务器单机部署和CCE高可用的架构AI赋能
  • 硬件学习笔记--66 MCU的DMA简介
  • macOS 上使用 Homebrew 安装redis-cli
  • 力扣面试150题--岛屿数量
  • K8S主机漏洞扫描时检测到kube-服务目标SSL证书已过期漏洞的一种永久性修复方法
  • 机器学习基础相关问题
  • C++ 变量二
  • Linux操作系统shell脚本
  • 论文导读 | 区间数据管理
  • 如何能推进专业度比较高的项目?