title: How kafka balances partitions load?
body: <p>i faced a question with load balancing in kafka. So, i created a topic with 10 partitions and created 2 consumers. The 10 partitions were divided and assigned to these consumers (5 partitions to the first and 5 to the second) and it works fine. Sometimes first consumer works, sometimes second.</p>
  
  <p>But at one moment we can face a situation when for example second consumer receives a message and it takes time (for example 10 minutes) to handle this message.</p>
  
  <p><em>So, my question is how kafka will decide to which partition store the message?</em> </p>
  
  <p>Round robin in this case i think is not a good idea, because messages in partitions that are handled by second consumer won't be handled until the second consumer finishes the long work.</p>
  
  <p><strong>Updated!</strong></p>
  
  <p>According to the @Milan Baran answer, the load is balanced on the producer side. But in this case, even if we provide a custom <code>Partitioner</code> realization, it will be the same problem that the message that was stored in the partition which was assigned to the consumer that is doing long-term work, will not be processed until this consumer finishes its long-term work.</p>
  
  <p>May be, there are additional load balancer somewhere else?</p>