Consider a Kafka producer configured with acks=0. What is the expected behavior when sending a message?
producer.send('topic', b'message') print('Message sent')
Think about what it means to not wait for any acknowledgment from the broker.
With acks=0, the producer does not wait for any acknowledgment from the broker. It sends the message and immediately continues, so 'Message sent' prints right away.
A Kafka producer is set with acks=1. The broker is slow to respond. What will the producer do?
producer.send('topic', b'message') print('Message sent')
Recall what acks=1 means about waiting for acknowledgments.
With acks=1, the producer waits for the leader broker to confirm the message before continuing. If the broker is slow, the producer waits until it receives the acknowledgment or times out.
When a Kafka producer uses acks=all, what is the effect on message durability?
Think about what all means in the context of acknowledgments.
With acks=all, the producer waits for all in-sync replicas to confirm the message, ensuring the highest durability.
Among acks=0, acks=1, and acks=all, which mode has the highest risk of message loss if the broker crashes immediately after receiving the message?
Consider what happens if the producer does not wait for any confirmation.
acks=0 does not wait for any acknowledgment, so if the broker crashes before writing the message, the message is lost.
A Kafka producer is configured with acks=all and sends a message. The program hangs indefinitely. What is the most likely cause?
producer = KafkaProducer(acks='all') producer.send('topic', b'message') producer.flush()
Think about what acks=all requires from the cluster.
If there are no in-sync replicas available, the producer waits indefinitely for acknowledgments that never come, causing the hang.