Middle
What is a partition key in Kafka?
sobes.tech AI
Answer from AI
The partition key in Kafka is the value used to determine which partition of a topic a specific message will go to. It is used for load distribution and to ensure message order within a partition.
When a producer sends a message, Kafka applies a hash function to the partition key to select a specific partition. Messages with the same key will always go to the same partition, guaranteeing their sequential processing.
For example, if you have a topic with 10 partitions and the key is a user ID, then all events of a single user will go to the same partition, maintaining order.