What is the purpose of bootstrap.servers, and why don't you need to list every broker?
answer
- seed, not full list
- first Metadata request
- client learns all brokers + leaders
- 2-3 entries for redundancy
- real addresses come from advertised.listeners
basics
~20 sbootstrap.servers is the initial list of broker host:port pairs a client contacts to discover the full cluster. After the first metadata fetch the client learns all brokers, so the list only needs a few entries for redundancy.
solid answer
~40 sbootstrap.servers tells a Kafka client where to make its first connection. The client connects to any one of the listed brokers and issues a Metadata request; the broker responds with the full cluster topology: every broker's id and advertised address, plus which broker leads each partition. From then on the client connects directly to the relevant leaders and ignores bootstrap.servers except to re-bootstrap if all connections drop. That's why you don't enumerate the whole cluster: the list is only a discovery seed. You still provide 2-3 entries (often a load balancer or several brokers) so the client can bootstrap even if one seed broker is down. Crucially, the addresses brokers return come from advertised.listeners, not from bootstrap.servers, so the bootstrap host being reachable doesn't guarantee the advertised addresses are.
go deeper
Know it's the initial connection seed and a partial list suffices.
Explain the Metadata request and that real addresses come from advertised.listeners.
Diagnose the advertised-address mismatch failure and bootstrap-vs-data-path distinction.
Design client connectivity across NAT/LB/multi-network topologies and reason about SPOFs.
## The discovery problem A Kafka cluster has many brokers, and partition leadership moves around (failover, rebalancing). A client must always send each produce/fetch to the *current leader* of the target partition. Hardcoding all brokers and leaders would be brittle. Kafka solves this with **bootstrap + metadata discovery**. ## bootstrap.servers `bootstrap.servers` is a client config: a comma-separated list of `host:port` entries, e.g. `b1:9092,b2:9092`. On startup the client: 1. Connects to one reachable entry. 2. Sends a **Metadata** request. 3. Receives the full picture: all broker ids and their **advertised** addresses, and the leader broker for every partition of the topics it cares about. 4. Opens direct connections to the leaders it needs. After this, bootstrap.servers is essentially unused unless the client loses all connections and must re-bootstrap. ## Why a partial list is enough Because any broker can answer the Metadata request with the *entire* cluster view, you only need one reachable seed. You list 2-3 for **availability** (so bootstrapping survives a single broker outage), not for completeness. Listing all brokers is unnecessary and adds maintenance burden as the cluster grows. ## The advertised-address gotcha The addresses the client uses *after* bootstrap come from each broker's **advertised.listeners**, not from bootstrap.servers. A classic failure: bootstrap.servers points at a reachable address (e.g. via a NAT or load balancer), the Metadata request succeeds, but the advertised addresses returned are internal hostnames the client cannot resolve/reach. The client then fails on the first produce/fetch despite a "successful" bootstrap. Always ensure advertised.listeners are reachable by clients. ## Edge cases - A single load-balancer DNS name as the only bootstrap entry works but is a SPOF for *bootstrapping* if the LB fails; the data path still uses advertised addresses directly. - Wrong port or listener (e.g. pointing at an inter-broker listener) bootstraps to the wrong security protocol and fails.
- After bootstrapping, where does the client get the addresses it actually connects to?From each broker's advertised.listeners, returned in the Metadata response; bootstrap.servers is only the initial seed.
- Why list more than one bootstrap server?Redundancy: if one seed broker is down, the client can still bootstrap from another. It is not for completeness.
saying these in an interview costs you the question
- Saying you must list every broker
- Claiming the client keeps using bootstrap.servers for all requests
- Confusing bootstrap.servers with advertised.listeners
- Thinking a reachable bootstrap address guarantees the data path works