title: How many producers to create in kafka?
body: <p>In a high volume real time java web app I'm sending messages to <a href="https://kafka.apache.org/" rel="noreferrer">apache kafka</a>.
  Currently I'm sending to a single topic, but in the future I might need to send messages to multiple topics.</p>
  
  <p>In this case I'm not sure weather to create a producer per topic or should I use a single producer to all my topics?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>props = new Properties();
  props.put("zk.connect", &lt;zk-ip1&gt;:&lt;2181&gt;,&lt;zk-ip3&gt;:&lt;2181&gt;,&lt;zk-ip3&gt;:&lt;2181&gt;);
  props.put("zk.connectiontimeout.ms", "1000000");
  props.put("producer.type", "async");
  
  Producer&lt;String, Message&gt; producer = new kafka.javaapi.producer.Producer&lt;String, Message&gt;(new ProducerConfig(props));
  
  ProducerData&lt;String, Message&gt; producerData1 = new ProducerData&lt;String, Message&gt;("someTopic1", messageTosend);
  ProducerData&lt;String, Message&gt; producerData2 = new ProducerData&lt;String, Message&gt;("someTopic2", messageTosend);
  
  producer.send(producerData1);
  producer.send(producerData2);
  </code></pre>
  
  <p>As you can see, once the producer has been created I can use it to send data to different topics.
  I wonder what is the best practice? If my app sends to multiple topics (each topic gets different data) can/should I use a single producer or should I create multiple producers? When (generaly speaking) should I use more than a single producer?</p>