Hi Eugene, First, please post questions like this to the users list in the future. The dev list is much busier and it's easier for your email to get lost. And, this list is meant for development on Kafka internals.
As far as your question, EC2 is a great example of when you may want to configure an advertised hostname. Partially this is because often EC2 instances don't have reasonable hostname defaults, and partially because often the hostname your clients (producers/consumers) connect to will be different from what the broker binds to. In my own tests in EC2, the broker will bind to localhost, but clients connect to either an internal IP or a CNAME DNS record. I should also explain how client configuration works. ZooKeeper stores the hostnames of all brokers (either the hostname or the advertised hostname if it's configured). In 0.9 and the 0.8 producer, clients are configured with a bootstrapped list of Kafka brokers. The 0.8 consumer is configured with ZooKeeper. In both cases, the client makes requests (either to a broker, or to ZooKeeper), to fetch all broker hostnames and begin interacting with the cluster. As such, in EC2, the advertised hostname is required unless you setup the hostname such that clients can connect to it and the broker can bind to it. Does that make sense? Alex On Thu, Feb 18, 2016 at 1:31 PM, eugene miretsky <eugene.miret...@gmail.com> wrote: > The FAQ says: > > "When a broker starts up, it registers its ip/port in ZK. You need to make > sure the registered ip is consistent with what's listed in > metadata.broker.list in the producer config. By default, the registered ip > is given by InetAddress.getLocalHost.getHostAddress. Typically, this should > return the real ip of the host. However, sometimes (e.g., in EC2), the > returned ip is an internal one and can't be connected to from outside. The > solution is to explicitly set the host ip to be registered in ZK by setting > the "hostname" property in server.properties. In another rare case where > the binding host/port is different from the host/port for client > connection, you can set advertised.host.name and advertised.port for > client > connection." > > Can somebody give an example for that "rare case" where the binding > host/port is different from the host/port for client connection? > > Cheers, > Eugene > -- *Alex Loddengaard | **Solutions Architect | Confluent* *Download Apache Kafka and Confluent Platform: www.confluent.io/download <http://www.confluent.io/download>*