Connecting to the Kafka cluster using load balancer

Learn how to connect a client to a Kafka cluster that is located behind a load balancer.

If you have set the Kafka Broker Load Balancer Listener Port property during broker configuration, ensure that you have also configured the load balancer to forward requests to the port number specified in Kafka Broker Load Balancer Listener Port.
To connect to the Kafka cluster using the load balancer host and port, use the following command:
kafka-topics --list --bootstrap-server load_balancer_host:load_balancer_port

The load balancer is only used for connection bootstrap. The clients still need to be able to connect to the brokers directly. This also means that if the client has discovered a cluster and is actively using it and the cluster suddenly stops, the client tries to connect to the bootstrap servers it discovered in the bootstrap phase as metadata, so it does not automatically ask the load balancer for new bootstrap servers and it does not fail over to the other cluster even if the load balancer already routes new requests to the other cluster.