📨 Apache Kafka
Beginner
What is a Kafka Producer?
Answer
A Kafka Producer is a client that publishes (writes) messages to Kafka topics. Key concepts: Key: optional message attribute used to determine partition routing — messages with the same key always go to the same partition, enabling per-key ordering. Value: the message payload (bytes). Partition selection: if a key is provided, a hash of the key selects the partition; if no key, partitions are assigned in round-robin. Batching: producers buffer messages and send in batches for efficiency (batch.size, linger.ms). Acknowledgements: acks=0 (fire-and-forget), acks=1 (leader confirms), acks=all (all in-sync replicas confirm — most durable). Compression: producers can compress messages (gzip, snappy, lz4) to reduce network bandwidth.