In order to make our Kafka cluster available both from Internet and from our private network, we thought fine to configure Kafka this way :

Private VIP:9000 => All brokers:9092 (topology query only)
Private VIP:9001 => Broker #1:9092
Private VIP:9002 => Broker #2:9092
Public VIP:9000 => All brokers:9092 (topology query only)
Public VIP:9001 => Broker #1:9092
Public VIP:9002 => Broker #2:9092

We configured our Load balancer this way, and then our brokers :


Now, as you would expect, Kafka brokers don't start :

ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
java.lang.IllegalArgumentException: requirement failed: Each listener must have a different port, listeners: INTERNAL://<private_VIP>:9001,EXTERNAL://<public_vip>:9001

From my Administrator point of view, my approach was totally logical, although I expected a problem where producer/consumers would get both addresses wherever they contacted the broker from. Using the same port on 2 different addresses seems logical and promotes clarity...

First question : Why is this wrong ?
Second question : How can I achieve my goal if not this way? (most options are on the table)


We have talked to a Kafka expert and here is what came out of it.

Simply put, while kafka has the Listener Names in its knowledge to differentiate 2 listeners, he needs to know which one the client that connects wants to reach and can only do so using the incoming port.

Also listeners and advertised listeners are mapped to one another if they have the same port so you need them to match.

In the end, here is what we did :


Where "N" is the broker ID (counting from 1 forwards)

On the Load balancer, we map each port of the VIP to the broker's IP address plus a Virtual IP on port 9000(internal network) and 9100 (external network) which map to the relevant listener of each broker.

That's a bit overkill, but it works as expected (as long as kafka internal metadata topics like __consumer_offset are replicated)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.