partitioner

The producer component that chooses which partition each record is sent to.

In more detail

The default partitioner hashes a record's key with murmur2 and takes the result modulo the partition count. kafka-python sends unkeyed records to a random available partition, while the Java client uses sticky partitioning. You can pass your own function, for example to route by region.

Example

KafkaProducer(partitioner=region_router)

Related terms

Taught in

References

Certification courses