Search code examples
gosarama

Do I need one or many sarama.SyncProducer inside my Golang app?


I am new in Golang, I need to write the app that will publish events to kafka, I can't find the answers on the following questions:

  1. How many sarama.SyncProducer do I need?
  2. Is it fine to use one across all app? Shall I have some kind of producer pool?

Solution

  • Unless you get the data to be published on a much higher rate than the publisher can publish it (?), given the sarama publisher is asynchronous and concurrent , I'd say you don't need more than one publisher. So to answer straight your questions:

    1. I'd go with one, without knowing your requirements.
    2. Yes. I'd imagine it's more likely that one needs a pool of consumers, given of course, there's high rate of messages being published.