I know that kafka producer will batch messages into batches. Each batch belongs to a particular partition.
My questiones are
Producers assign the target partition to each record (if it's not provided by the application) so yes they know the partition for batches.
When starting up, producers will retrieve the cluster metadata. This contains the current leader of partitions. Producers also refresh metadata periodically so they are able to discover updates or new partitions.
A Produce request can contain batches for multiple partitions. You can see there's a RECORDS field for each partition in the protocol.
Producers directly send records to the broker that is the partition leader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With