Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Kafka partition

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. The function of introducing partition under topic:

Topic is a logical concept and partition is a physical concept.

For performance reasons, if the messages in the topic are stored in only one broker, then the broker will become a bottleneck and cannot scale horizontally. Kafka allocates partition to different servers in the cluster as much as possible through the algorithm.

Partition can also be understood as the encapsulation of segment. One partition corresponds to multiple segment. A segment contains a data file and an index file

Second, kafka partition allocation strategy:

Partition.assignment.strategy= range (default) or roundrobin

Range strategy: sort by partition order, consumers by alphabetical order.

The number of partitions divided by the total number of consumer threads determines how many partitions each consumer thread consumes. If not, the first few consumer threads will consume an extra partition.

Suppose there are 3 consumers and 11 divisions.

C1-0 will consume 0, 1, 2, 3 zones

C1-2 will consume 4, 5, 6, 7 zones

C1-3 will consume 8, 9, 10 zones

Roundrobin strategy: partitions are sorted by hashcode, consumers are sorted alphabetically

Suppose there are 3 consumers and 11 divisions.

C1-0 will consume 0, 3, 6, 9 zones

C1-2 will consume 1, 4, 7, 10 zones

C1-3 will consume 2, 5, 8 zones

Note:

1. A partition can only be consumed by one consumer, but a consumer can consume data from multiple partitions.

2. The new api reserves the possibility of implementing the allocation policy class org.apache.kafka.clients.consumer.RangeAssignor.

3. Zone modification. / kafka-topics.sh-- alter-- topic topic1-- zookeeper zkip:2181/kafka-- partitions 6

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report