当前位置:网站首页>Chapter 5 detailed explanation of consumer groups
Chapter 5 detailed explanation of consumer groups
2022-07-06 16:34:00 【Can't keep the setting sun】
5.1 Consumer group concept
What is? consumer group?
consumer group yes kafka The scalable and fault-tolerant consumer mechanism provided . Since it's a group , There must be multiple consumers or consumer instances in the group (consumer instance), They share a common ID, namely group ID. All consumers in the group coordinate to consume the theme of subscription (subscribed topics) All partitions of (partition). Each partition can only be made up of one... In the same consumption group consumer To consume .
consumer group Three characteristics
- consumer group There can be one or more consumer instance,consumer instance It can be a process , It can also be a thread
- group.id Is a string , A unique logo consumer group
- consumer group Subscribe to the topic Each partition of can only be assigned to one group Under a consumer( Of course, the partition can also be assigned to other group)
5.2 Consumer location
In the process of consumption, consumers need to record how much data they consume , Consumption location information . stay Kafka There is a special term for this location information in : Displacement (offset). Many message engines store this information on the server (broker End ). The advantage of this is that it is easy to realize , But there are three main problems :
- broker From then on, it becomes stateful , Will affect scalability ;
- Need to introduce a response mechanism (acknowledgement) To confirm the success of consumption .
- Because we need to save a lot consumer Of offset Information , It is inevitable to introduce complex data structures , Waste of resources .
and Kafka Choose a different way , Every consumer group Save your displacement information , Then only an integer is needed to represent the position ; At the same time, we can introduce checkpoint The mechanism is persistent on a regular basis , It simplifies the implementation of the response mechanism .
5.3 Displacement Management
5.3.1 Automatically VS Manual
Kafka The default is to automatically submit displacement reports periodically (enable.auto.commit = true
), Of course, you can choose to submit the displacement manually . in addition kafka I'll put it on a regular basis group Save the consumption , Make one offset map, As shown in the figure below
5.3.2 Displacement submission
The displacement of the old version is submitted to zookeeper in , The directory structure is /consumers/<group.id>/offsets/<topic>/<partitionId>
, however zookeeper In fact, it is not suitable for mass reading and writing operations , Especially write operations . therefore kafka Provides another solution : increase __consumer_offsets
topic, take offset Write this message topic, Get rid of right zookeeper Dependence ( Refers to preservation offset This matter ).__consumer_offsets The message in saves each consumer group Submitted at a certain moment offset Information . Still in the above figure consumer group For example , The format is something like this
边栏推荐
- useEffect,函數組件掛載和卸載時觸發
- 300th weekly match - leetcode
- Codeforces Round #801 (Div. 2)A~C
- Oneforall installation and use
- Pull branch failed, fatal: 'origin/xxx' is not a commit and a branch 'xxx' cannot be created from it
- Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
- 875. Leetcode, a banana lover
- Install Jupiter notebook under Anaconda
- Problem - 922D、Robot Vacuum Cleaner - Codeforces
- Investigation report of bench type Brinell hardness tester industry - market status analysis and development prospect prediction
猜你喜欢
Openwrt build Hello ipk
力扣:第81场双周赛
QT realizes window topping, topping state switching, and multi window topping priority relationship
Li Kou: the 81st biweekly match
Spark独立集群动态上线下线Worker节点
860. Lemonade change
QT implementation window gradually disappears qpropertyanimation+ progress bar
Advancedinstaller installation package custom action open file
(POJ - 3579) median (two points)
Codeforces Round #799 (Div. 4)A~H
随机推荐
Study notes of Tutu - process
图图的学习笔记-进程
(POJ - 3685) matrix (two sets and two parts)
QWidget代码设置样式表探讨
Base dice (dynamic programming + matrix fast power)
It is forbidden to trigger onchange in antd upload beforeupload
Market trend report, technical innovation and market forecast of China's desktop capacitance meter
Codeforces Round #798 (Div. 2)A~D
Local visualization tools are connected to redis of Alibaba cloud CentOS server
Research Report on hearing health care equipment industry - market status analysis and development prospect prediction
(POJ - 1458) common subsequence (longest common subsequence)
Tert butyl hydroquinone (TBHQ) Industry Research Report - market status analysis and development prospect forecast
875. Leetcode, a banana lover
<li>圆点样式 list-style-type
1689. Ten - the minimum number of binary numbers
Advancedinstaller installation package custom action open file
Codeforces Round #799 (Div. 4)A~H
Codeforces Round #803 (Div. 2)A~C
Pytorch extract skeleton (differentiable)
Li Kou: the 81st biweekly match