What is the partitioning strategy of Kafka?

First review the architecture diagram of Kafka

The essence of kafka partition is to solve the load balancing and fault tolerance of data when writing and consuming data.

The producer sends the data to the topic corresponding to kafka. The data stored in the topic is stored in partitions; the data in the corresponding topic is also consumed by partitions when consumers are required to consume it. In further thinking, how does he partition the data? What about? This is the problem of kafka's partitioning strategy to be discussed below.

This mechanism also determines how the producer sends the message to the designated partition, and how the consumer consumes the data in the partition.

Kafka producer's partition strategy

1 Random strategy

2 Polling strategy (kafka default)

3 According to the key partition strategy, Key-ordering 

4 To customize the partition strategy, you need to implement  org.apache.kafka.clients.producer.Partitioner the partition method in the interface

The partition consumption strategy of kafka consumers

1 Range Startegy (consumption according to range)

2 round-robin consumers are partitioned by hash

 

Remarks

Producer write partition strategy

Consumer security zone consumption strategy

 

Guess you like

Origin blog.csdn.net/u013963379/article/details/106607019