0
0
Kafkadevops~20 mins

Acknowledgment modes (acks=0, 1, all) in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Acknowledgment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output when using acks=0?

Consider a Kafka producer configured with acks=0. What is the expected behavior when sending a message?

Kafka
producer.send('topic', b'message')
print('Message sent')
AThe producer waits for the broker to confirm the message before printing 'Message sent'.
BThe producer retries sending the message until it receives an acknowledgment.
CThe producer sends the message and immediately prints 'Message sent' without waiting for any acknowledgment.
DThe producer raises an error because acks=0 is invalid.
Attempts:
2 left
💡 Hint

Think about what it means to not wait for any acknowledgment from the broker.

Predict Output
intermediate
2:00remaining
What happens with acks=1 when broker is slow?

A Kafka producer is set with acks=1. The broker is slow to respond. What will the producer do?

Kafka
producer.send('topic', b'message')
print('Message sent')
AThe producer waits for the leader broker to acknowledge before printing 'Message sent'.
BThe producer raises a timeout error immediately.
CThe producer waits for all replicas to acknowledge before printing 'Message sent'.
DThe producer does not wait and prints 'Message sent' immediately.
Attempts:
2 left
💡 Hint

Recall what acks=1 means about waiting for acknowledgments.

Predict Output
advanced
2:00remaining
What is the effect of acks=all on message durability?

When a Kafka producer uses acks=all, what is the effect on message durability?

AThe message is considered durable after all in-sync replicas have acknowledged it.
BThe message is sent without waiting for any acknowledgment, so durability is not guaranteed.
CThe message is considered durable only after the leader broker writes it to its local log.
DThe message is durable only if the producer retries sending it multiple times.
Attempts:
2 left
💡 Hint

Think about what all means in the context of acknowledgments.

🧠 Conceptual
advanced
2:00remaining
Which acknowledgment mode risks message loss on broker failure?

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?

A<code>acks=1</code> because it waits only for the leader broker's acknowledgment.
B<code>acks=0</code> because it does not wait for any acknowledgment.
CAll modes have the same risk of message loss.
D<code>acks=all</code> because it waits for all replicas and can lose messages if replicas are slow.
Attempts:
2 left
💡 Hint

Consider what happens if the producer does not wait for any confirmation.

🔧 Debug
expert
3:00remaining
Why does this Kafka producer hang with acks=all?

A Kafka producer is configured with acks=all and sends a message. The program hangs indefinitely. What is the most likely cause?

Kafka
producer = KafkaProducer(acks='all')
producer.send('topic', b'message')
producer.flush()
AThe topic does not exist, so the producer immediately raises an error.
BThe producer is missing the <code>flush()</code> call, so messages are not sent.
CThe <code>acks</code> parameter is invalid and causes a configuration error.
DThere are no in-sync replicas available, so the producer waits forever for acknowledgments.
Attempts:
2 left
💡 Hint

Think about what acks=all requires from the cluster.