partitioner.class — Kafka Producer Configuration
Determines which partition to send a record to when records are produced. Available options are:If not set, the default partitioning logic is used
Description
Determines which partition to send a record to when records are produced. Available options are:If not set, the default partitioning logic is used. This strategy send records to a partition until at least batch.size bytes is produced to the partition. It works with the strategy:If no partition is specified but a key is present, choose a partition based on a hash of the key.If no partition or key is present, choose the sticky partition that changes when at least batch.size bytes are produced to the partition.If client.rack is specified and partitioner.rack.aware=true, the sticky partition is chosen from partitions with the leader broker in the same rack, if at least one is available. If none are available, it falls back on selecting from all available partitions.org.apache.kafka.clients.producer.RoundRobinPartitioner: A partitioning strategy where each record in a series of consecutive records is sent to a different partition, regardless of whether the 'key' is provided or not, until partitions run out and the process starts over again. Note: There's a known issue that will cause uneven distribution when a new batch is created. See KAFKA-9965 for more detail.Implementing the org.apache.kafka.clients.producer.Partitioner interface allows you to plug in a custom partitioner.Type:classDefault:nullValid Values:Importance:medium
Default Values by Kafka Version
| Component | Kafka version line | Documented default |
|---|---|---|
| Producer | 0.7 | kafka.producer.DefaultPartitioner<T> - uses the partitioning strategy hash(key)%num_partitions. If key is null, then it picks a random partition. |
| Producer | 0.8.0 | kafka.producer.DefaultPartitioner |
| Producer | 0.8.1 | kafka.producer.DefaultPartitioner |
| Producer | 0.8.2 | kafka.producer.DefaultPartitioner |
| Producer | 0.9.0 | class org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 0.10.0 | class org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 0.10.1 | class org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 0.10.2 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 0.11.0 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 1.0 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 1.1 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.0 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.1 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.2 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.3 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.4 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.5 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.6 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.7 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 2.8 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 3.0 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 3.1 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 3.2 | org.apache.kafka.clients.producer.internals.DefaultPartitioner |
| Producer | 3.3 | null |
| Producer | 3.4 | null |
| Producer | 3.5 | null |
| Producer | 3.6 | null |
| Producer | 3.7 | null |
| Producer | 3.8 | null |
| Producer | 3.9 | null |
| Producer | 4.0 | null |
| Producer | 4.1 | null |
| Producer | 4.2 | null |
| Producer | 4.3 | null |
| Producer | 4.4 | null |
Related Configs
partitioner.adaptive.partitioning.enable · partitioner.ignore.keys