Is Producer thread-safe?

81 views
Skip to first unread message

wkuranowski

unread,
Aug 8, 2014, 7:16:03 AM8/8/14
to sarama...@googlegroups.com
Hi.

I would like to create a single Producer and share it between workers (goroutines). Is it safe and efficient? Is it better to create many clients/producers?

Regards.

Evan Huus

unread,
Aug 8, 2014, 9:32:59 AM8/8/14
to sarama...@googlegroups.com
Yes, it should be both safe and efficient.

dh...@udacity.com

unread,
Oct 3, 2014, 7:21:23 PM10/3/14
to sarama...@googlegroups.com
So does this mean that if a sendMessage in one goroutine is blocking for a given producer, it wont affect that same producer's calls to sendMessage in other goroutines?

Thanks,

Dhruv

Evan Huus

unread,
Oct 3, 2014, 10:53:49 PM10/3/14
to sarama...@googlegroups.com
Depends on what you mean by "affect" - both messages should absolutely be safely delivered, but I'm not sure the performance impact. There are definitely some synchronization points between the goroutines, but I don't think they wrap any of the major work (specifically the network round-trip) so it should be relatively performant. It won't be as fast as fully-asynchronous producing (with QueueMessage) of course. The best way to find out for sure would be to try it and see :)
Reply all
Reply to author
Forward
0 new messages