Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Customer logic in partitioning#

Sumit Rawal answered on May 31, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Customer logic in partitioning#

0

Kafka also gives its users the ability to specify their own custom logic for how partitioning should take place. Users can specify the property partition.class when creating the producer object, similar to how the key and value serializer properties are specified. There are many possible reasons to have a custom partitioner, the most notable of which is balancing load across partitions. For instance, say we use a customer’s home country as the message key and 30% of our customers are from the USA alone. The partition with US customers will be overburdened as it will receive messages for US customers as well as messages for customers from other countries whose keys hash to the same partition. To alleviate such a situation, we can write a custom partitioner that directs all US data to a particular partition. The customer partitioner class must implement the interface org.apache.kafka.clients.producer.Partitioner.

An example implementation of the partitioner for the scenario we discussed appears below:

Popularity 1/10 Helpfulness 1/10 Language java
Source: Grepper
Tags: java logic
Link to this answer
Share Copy Link
Contributed on May 31 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.