Event Streaming with Kafka

Kafka Producers Consumers The Message Flow

Producer Acknowledgments Acks and Reliability Guarantees

In Apache Kafka, producer acknowledgments—configured via the acks parameter—determine how producers confirm that messages have been durably written to the cluster. Selecting the right acks level helps you balance throughput, latency, and data durability in your event-streaming applications.

What Are Acknowledgments (acks)?

When a producer sends a record to a Kafka broker, it can request an acknowledgment from the broker before considering the send successful. Acks define how many brokers must confirm receipt:

  • acks=0: No acknowledgment; the producer proceeds immediately.
  • acks=1: Leader broker acknowledgment only.
  • acks=all (or acks=-1): Confirmation from all in-sync replicas (ISRs).

Note

By default, Kafka producers use acks=1, offering a balance between performance and reliability.

Visual Overview

The image illustrates the concept of producer acknowledgments and reliability guarantees in Kafka, showing a producer sending a message to a broker with acknowledgment settings to limit data loss.

acks Configuration Options

acks ValueDescriptionThroughputData GuaranteeTypical Use Case
0No broker acknowledgmentHighestPossible message loss if broker crashesNon-critical logging or metrics streams
1Acknowledgment from leader onlyHighRisk of loss if leader fails before replicationStandard event streams
all / -1Acknowledgment from all in-sync replicas (ISRs)Moderate to LowStrongest durability as long as ≥1 ISR remains upFinancial transactions, audit logs
# Example: strong durability
acks=all

The image is a diagram illustrating producer acknowledgments and reliability guarantees in a data system, showing how producers interact with brokers and partitions to ensure limited data loss.

Choosing the Right Acks Level

Use the table below to select the appropriate acks configuration for your Kafka producer:

ObjectiveRecommended acksRationale
Maximum throughputacks=0No waits → minimal latency
Balanced performanceacks=1Fast with leader confirmation
Maximum durabilityacks=allGuarantees replication to all ISRs

Warning

Using acks=all increases end-to-end latency. Ensure your cluster’s replication factor and in-sync replica settings are properly configured to avoid unintentional message rejections.

The image is a comparison chart of producer acknowledgment levels (acks=0, acks=1, acks=all) and their reliability guarantees, including use cases and potential message loss scenarios.

Best Practices

  • Always align your acks setting with your business requirements for reliability vs. performance.
  • Monitor ISR health to maintain durability when using acks=all.
  • Combine acks with other producer configs like retries and max.in.flight.requests.per.connection for end-to-end guarantees.

Watch Video

Watch video content

Previous
Understanding the Role of Message Keys