kakfa 基本了解

news2025/5/23 9:45:44

部署结构

Kafka 使用zookeeper来协商和同步,但是kafka 从版本3.5正式开始deprecate zookeeper, 同时推荐使用自带的 kraft. 而从4.0 开始则不再支持 zookeeper。
所以 kafka 是有control plane 和 data plane 的。
data plane 就是broker,control plane 旧的就是zookeeper,新的是 kRaft contorller。

kafka cluster的节点(broker)是没有leader 和 follower 之分的。
只是存储messages 的 topic partition 有。
Client只能connect partition 的leader 来写和读。

Partition Connection

kafka 术语

Kafka brokers: Brokers refer to each of the nodes in a Kafka cluster

The broker.id property is the unique and permanent name of each node in the cluster

Record:Records are also called messages or events. A Kafka record consists of headers, a key, a value, and a timestamp.

Headers contain metadata consisting of string-value pairs, which can be read by consumers in order to make decisions based on the metadata. Headers are optional.
Key and value pairs in a Kafka record contains data relevant to your business. The key may have some structure, and can be a string, an integer, or some compound value. The value is structured and is likely an object to be serialized.
Every Kafka record has a timestamp. If you don’t provide one, one is provided by default.

Message streams are persistent in Kafka. This means that messages do not disappear once received. This is in contrast with classic “pub-sub” systems such as JMS, which as soon as the message is received by the subscriber, is removed from the system. In Kafka, message retention periods are configurable, usually based on a length of time or the size of the underlying storage.
kafka 的message 是可以被多次消费的,不是消费后就被删除,而是通过 retention policy 来控制的。

在这里插入图片描述

Topic:Kafka topics are the categories used to organize messages, messages are sent to and read from specific topics.

Each topic has a name that is unique across the entire Kafka cluster.
And producers write data to topics, and consumers read data from topics.
Kafka topics are multi-subscriber.This means that a topic can have zero, one, or multiple consumers subscribing to that topic and the data written to it. There is a many-to-many relation between producers/consumers and topics.

在这里插入图片描述

Partition: Kafka topics are divided into one or more partitions, each of which is a logical segment of the topic’s data.

Each partition holds a subset of the topic’s data, and the producer decides which partition a message is written to, based on factors like a key or round-robin distribution.

client producer根据record 的 key 的hash 来分配topic 的partition. 如果没有key则round-robin 分配partition。
一个partition 只会分配给一个client,但是一个client 可能会handle 多个partition。

在这里插入图片描述

A topic can be divided into multiple partitions to enable parallel processing and improve scalability. Each partition is an ordered sequence of immutable records, with messages within a partition guaranteed to maintain their order. Partitions allow Kafka to distribute the workload of writing and reading messages across multiple brokers in the cluster. This enables consumers to read data in parallel, and producers to write data to different partitions simultaneously, increasing throughput and reducing latency.

Within each partition, messages have a unique offset, which is an integer representing their position in the sequence. This helps consumers track their position and retrieve messages in the correct order.

在这里插入图片描述

Kafka Transaction: A Kafka transaction is a group of operations (usually message writes or reads + writes) that are treated as a single atomic unit. Either all of the operations succeed, or none of them take effect.

** Transactions: Balance Overhead with Latency **

One thing to consider, specifically in Kafka Streams applications, is how to set the commit.interval.ms configuration. This will determine how frequently to commit, and hence the size of our transactions. There is a bit of overhead for each transaction so many smaller transactions could cause performance issues. However, long-running transactions will delay the availability of output, resulting in increased latency. Different applications will have different needs, so this should be considered and adjusted accordingly.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2383794.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Origin绘制多因子柱状点线图

多因子柱状点线图是一种结合柱状图和点线图的复合图表,常用于同时展示多个因子(变量)在不同分组下的分布和趋势变化。 适用场景: (1)比较多个因子在不同分组中的数值大小(柱状图)&a…

Web漏洞扫描服务的特点与优势:守护数字时代的安全防线

在数字化浪潮中,Web应用程序的安全性已成为企业业务连续性和用户信任的核心要素。随着网络攻击手段的不断升级,Web漏洞扫描服务作为一种主动防御工具,逐渐成为企业安全体系的标配。本文将从特点与优势两方面,解析其价值与应用场景…

抛弃传统P2P技术,EasyRTC音视频基于WebRTC打造教育/会议/远程巡检等场景实时通信解决方案

一、方案背景 随着网络通信发展,实时音视频需求激增。传统服务器中转方式延迟高、资源消耗大,WebP2P技术由此兴起。EasyRTC作为高性能实时通信平台,集成WebP2P技术,实现低延迟、高效率音视频通信,广泛应用于教育、医疗…

俄罗斯军总参情报局APT28组织瞄准援乌后勤供应链发起全球网络攻击

2025年5月,由美国、英国、欧盟和北约网络安全与情报机构联合发布的最新网络安全公告披露,俄罗斯军总参情报局(GRU)第85特别服务中心第26165部队(又称APT28、Fancy Bear、Forest Blizzard和BlueDelta)正持续…

杰发科技AC7801——PWM获取固定脉冲个数

测试通道6 在初始化时候打开通道中断 void PWM1_GenerateFrequency(void) {PWM_CombineChConfig combineChConfig[1]; //组合模式相关结构体PWM_IndependentChConfig independentChConfig[2];//独立模式相关结构体PWM_ModulationConfigType pwmConfig; //PWM模式相关结构体PWM…

MacBookPro上macOS安装第三方应用报错解决方案:遇到:“无法打开“XXX”,因为无法确定(验证)开发者身份?怎么解决

MacBook Pro 上 macOS 安装第三方应用报错解决方案 —— 彻底搞定「无法打开“XXX”,因为无法确定开发者身份」 适用系统:macOS Catalina 10.15 ~ macOS Sonoma 14.x 适用机型:Intel / Apple Silicon 全系 MacBook Pro 文章目录 **MacBook P…

RAG(Retrieval-Augmented-Generation)检索增强生成

什么是RAG(检索增强生成)? RAG是一种AI框架,结合传统的数据检索技术和LLM(大语言模型)的优势,通过将外部数据和LLM生成语言技能集合,对LLM的输出进行优化,使输出更准确、…

黑马点评前端Nginx启动失败问题解决记录

Nginx启动失败问题解决记录 问题描述 在学习黑马Redis课程时,启动黑马点评Nginx前端项目发现: 无法访问8080端口检查Windows端口占用情况(无占用)结论:Nginx服务未成功启动 错误日志分析 在nginx安装目录下的logs…

第12天-Python+Qt5开发实战:10大经典案例与深度解析

1. 基础窗口与信号槽机制 python 复制 下载 import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButtonclass MainWindow(QMainWindow):def __init__(self):super().__init__()self.setWindowTitle("信号槽示例")btn = QPushButton("…

人工智能培训:解锁未来职场竞争力的核心路径与课程内容解析

当AI绘画工具在几秒内生成一幅媲美专业画师的作品,当AI程序员自主优化代码逻辑,当AI客服精准解答复杂问题——一个现实愈发清晰:人工智能正在重新定义“专业能力”的边界。 对于普通人而言,这场变革既带来焦虑,也孕育机…

深入解析Java泛型:从定义到实战应用

目录 🚀前言🤔泛型的定义🐧泛型类🌟泛型接口✍️泛型方法、通配符、上下限💯泛型方法💯 通配符与上下限⚙️通配符(Wildcard)⚙️泛型上下限⚙️应用场景 🦜泛型支持的类…

【开源】一个基于 Vue3 和 Electron 开发的第三方网易云音乐客户端,具有与官方客户端相似的界面布局

🎵 XCMusic:高颜值第三方网易云音乐客户端 🎶 📍 项目亮点 XCMusic 是一款基于Vue3Electron开发的开源、跨平台网易云音乐客户端。 此音乐播放器基于 Electron 开发,旨在为用户提供简洁、美观、兼容多平台的音乐体验。…

labview设计一个虚拟信号发生器

目标:设计一个虚拟信号发生器,通过功能键的设置可以产生正弦波、三角波、方波和锯齿波,并可以通过输入控件设置采集信号的频率、幅值、相位等参数。 一、正弦波 (1)创建一个枚举 (2)点击属性后…

工业路由器WiFi6+5G的作用与使用指南,和普通路由器对比

工业路由器的技术优势 在现代工业环境中,网络连接的可靠性与效率直接影响生产效率和数据处理能力。WiFi 6(即802.11ax)和5G技术的结合,为工业路由器注入了强大的性能,使其成为智能制造、物联网和边缘计算的理想选择。…

编译Qt5.15.16并启用pdf模块

编译Qt5.15.16并启用pdf模块 标题1.目录设置 -q-bulid –qt-everywhere-src-5.15.16 –bulid cd bulid 必须,否则会提示Project ERROR: You cannot configure qt separately within a top-level build. create .qmake.stash and .qmake.super in build folder …

Python绘制新冠疫情的知识图谱

from pyvis.network import Network import networkx as nx import pandas as pd import os# 修复模板路径 from pyvis import network as net_moduleos.environ["PATH"] os.pathsep os.path.dirname(net_module.__file__)# 创建紧密连接图 g nx.Graph()# 关键修…

使用RUST在Arduino上进行编程(MacOS,mega板)

近年来,RUST成为了嵌入式编程的热门语言,本文通过实现(1)LED闪灯,以及(2)在console(终端)实现“Hello Rust World”两项功能来完成实操的入门。 深入学习可以参考RUST语言…

大模型微调与高效训练

随着预训练大模型(如BERT、GPT、ViT、LLaMA、CLIP等)的崛起,人工智能进入了一个新的范式:预训练-微调(Pre-train, Fine-tune)。这些大模型在海量数据上学习到了通用的、强大的表示能力和世界知识。然而,要将这些通用模型应用于特定的下游任务或领域,通常还需要进行微调…

OpenCv高阶(十六)——Fisherface人脸识别

文章目录 前言一、Fisherface人脸识别原理1. 核心思想:LDA与Fisher准则2. 实现步骤(1) 数据预处理(2) 计算类内散布矩阵 SW对每个类别(每个人)计算均值向量 μi:(3) 计算类间散布矩阵 SB(4) 求解投影矩阵 W(5) 降维与分类 3. Fish…

二分算法的补充说明

在上一节中我们简单介绍了二分算法,通过区分小于等于,大于或者小于,大于等于我们可以求出它们的边界值。 具体方法是先看一下要求哪里的边界值,分成两部分让如果求小于等于的右边界,我们根据条件让rightmid-1,leftmid…