Load balancing with Kafka is a straightforward process and is handled by the Kafka producers by default. While it isn’t traditional load balancing, it does spread out the message load between partitions while preserving messaging ordering.
By default, producers choose the partition assignment for each incoming message within a topic, following a round-robin approach.
As a reminder, partitions allow users to parallelize topics. This means that data for any topic can be divided over multiple machines, allowing multiple consumers to read topics in parallel. The system of partitions is part of what makes Kafka ideal for high message throughput use cases.
However, if your use case would benefit from an approach other than the round-robin parsing of messages into different partitions, you’re in luck. With Kafka, users can specify the exact partition for a message. If such a specification is made, then the message will be guaranteed to go the specified partition.