Durability in Kafka
Durabilty in Kafka
Durability in Kafka is acheived by replication. Kafka by design makes sure the message is available to the consumers only after it's acknowledged to the topic successfully.
The replication is defined using replication_factor
Here the message in topic is acknowledged based on acks
. This defines if the message should be available to the consumers or not.
Types of `acks`
acks = 0
This is fire and forget. Once any of the Kafka node recieves the message, it is immediately considered as acknowledged and is available to consumers.
Even though replication factor is configured and will eventually be replicated but it does acknowledge the message immediately.
This is great fot high throughput but bad for durability
acks = 1
Broker acknowdges the message if the leader receives the message
Eventual replication will happen based on the
replication_factor
Little bit of latency is introduced but the durability is much better than
acks = 0
Durability is improved, but when leader re-election happens there is a chance of losing the data
acks = all
Broker acknowledges the message only when all in-sync replicas received the message
Provides you with highest durability but the throughput is affected
min.insync.replicas
Broker acknowledges the message when the
min.insync.replicas
receive the message rather than all in-sync replicas
Last updated
Was this helpful?