1.

What is partition key in Kafka?

Answer»

As we know that producers publish messages to a DIFFERENT partition of the topic. Messages consist of chunks of data. Along with the data producer system also send one KEY. This key is called a partition key. The data which comes with unique key always gets stored in the same partition. Consider a real-world system where we have to track the user’s activity while using the application. We can store the user’s data using the partition key in the same partition. So basically the user’s data being tagged with key helps US in ACHIEVING this objective. Let's say if we have to store user u0 data into partition p0 then we can TAG u0 data with some unique key which will ensure that user’s data always gets stored in partition p0. But it does not mean that p0 partition can not store other user’s data. To summarize partition key is used to validate messages and knowing destination partition where messages will be stored. Let's have a look at the below diagram which clearly explains the usage of partition key in Kafka architecture. 



Discussion

No Comment Found