Message order guarantees on Async producer failures

663 views
Skip to first unread message

Deepak

unread,
Jan 15, 2016, 1:55:56 PM1/15/16
to kafka-clients
Hey Guys,

I've been exploring the 0.8.2.2 java kafka producer recently. Based on my understanding of the "Async" producer, the callbacks for records being sent to the same partition are guaranteed to be executed in order. But to guarantee message order during send failures, I'd expect that "sync" retry calls to be made from inside the callback body. But it looks like, this would slow down the throughput as these calls are made from the i/o thread. The other option would be doing "async" retry calls from the callback body, but since these calls are asynchronous, the ordering of events could be lost.

Can anyone please help explain the recommended way to perform "retries" using "Async" producer such that message ordering is guaranteed ? 

Thanks,
Deepak

Dana Powers

unread,
Jan 15, 2016, 2:49:44 PM1/15/16
to Deepak, kafka-clients
Generally a retriable ProduceRequest error would be at the partition level, not the message level (corrupt messages should not be retried). So my understanding is that a client should retry the entire topic-partition messageset until successful or until configuration says to stop retrying. I'm not sure how the java client handles this specifically -- you might send a message to the users or dev list for confirmation.

-Dana

--
You received this message because you are subscribed to the Google Groups "kafka-clients" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kafka-client...@googlegroups.com.
To post to this group, send email to kafka-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kafka-clients.
To view this discussion on the web visit https://groups.google.com/d/msgid/kafka-clients/cacfa122-6b9c-402b-ba70-e02bfd741f64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ewen Cheslack-Postava

unread,
Jan 15, 2016, 4:23:32 PM1/15/16
to Dana Powers, Deepak, kafka-clients
Deepak,

The producer supports performing retries internally, before any callbacks are made. You probably want to use this mechanism instead of performing retries yourself unless your application needs to know about every send failure. Internally this is implemented to maintain ordering.

MirrorMaker is a good reference for cases like this since it needs to do its best to guarantee ordering and no message loss. Here's a snippet from one of the comments in the MirrorMaker code listing the settings used (note retries = max integer):
* @note For mirror maker, the following settings are set by default to make sure there is no data loss:
* 1. use new producer with following settings
* acks=all
* retries=max integer
* max.block.ms=max long
* max.in.flight.requests.per.connection=1
* 2. Consumer Settings
* auto.commit.enable=false
* 3. Mirror Maker Setting:
* abort.on.send.failure=true

-Ewen


For more options, visit https://groups.google.com/d/optout.



--
Thanks,
Ewen

Deepak Mallya

unread,
Jan 15, 2016, 9:34:46 PM1/15/16
to Ewen Cheslack-Postava, Dana Powers, kafka-clients
Thanks for the reply guys! 

Ewen, I'll take a look at MirrorMaker.

-Deepak
Reply all
Reply to author
Forward
0 new messages