Producer Configuration for Reliability
Key Configuration Parameters
-
Idempotence
- enable.idempotence=true prevents network-induced duplicates
- Automatically sets retries and acks for safety
- Small performance impact but stronger guarantees
-
In-Flight Requests
- max.in.flight.requests.per.connection affects ordering
- Higher values improve throughput but risk reordering with retries
- Set to 1 for strict ordering with retries
-
Delivery Timeouts
- delivery.timeout.ms controls total time for retry attempts
- Should be greater than linger.ms + request.timeout.ms
- Affects how long before giving up on failed sends
Best Practices
- Enable idempotence for exactly-once delivery
- Use acks=all with min.insync.replicas for durability
- Consider throughput vs ordering trade-offs
- Implement proper error handling in callbacks
References
Flashcards
What configuration prevents network-induced duplicates in producers?:: enable.idempotence=true
What is the risk of increasing max.in.flight.requests while enabling retries?:: Message order may not be preserved if retries occur
What happens if you use producer.send().get()?:: Throughput decreases because it waits synchronously for broker response