Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is bootstrap-server in kafka config?

Tags:

apache-kafka

I have just started learning kafka and continuously I am coming across a term bootstrap-server.

Which server does it represent in my kafka cluster?

like image 849
laxman Avatar asked May 07 '20 11:05

laxman


People also ask

What is bootstrap server Kafka?

The bootstrap servers are the initial servers you connect to when establishing connection to Kafka. These servers reveal the full set of brokers available on the cluster.

What is bootstrap server used for?

A Bootstrapping Server Function (BSF) is an intermediary element in Cellular networks which provides application-independent functions for mutual authentication of user equipment and servers unknown to each other and for 'bootstrapping' the exchange of secret session keys afterwards.

What is Kafka bootstrap and broker?

The term bootstrap brokers refers to a list of brokers that an Apache Kafka client can use as a starting point to connect to the cluster. This list doesn't necessarily include all of the brokers in a cluster.


2 Answers

It is the url of one of the Kafka brokers which you give to fetch the initial metadata about your Kafka cluster. The metadata consists of the topics, their partitions, the leader brokers for those partitions etc. Depending upon this metadata your producer or consumer produces or consumes the data.

You can have multiple bootstrap-servers in your producer or consumer configuration. So that if one of the broker is not accessible, then it falls back to other.

like image 165
JavaTechnical Avatar answered Sep 18 '22 14:09

JavaTechnical


We know that a kafka cluster can have 100s or 1000nds of brokers (kafka servers). But how do we tell clients (producers or consumers) to which to connect? Should we specify all 1000nds of kafka brokers in the configuration of clients? no, that would be troublesome and the list will be very lengthy. Instead what we can do is, take two to three brokers and consider them as bootstrap servers where a client initially connects. And then depending on alive or spacing, those brokers will point to a good kafka broker.

So bootstrap.servers is a configuration we place within clients, which is a comma-separated list of host and port pairs that are the addresses of the Kafka brokers in a "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.

A host and port pair uses : as the separator.

localhost:9092
localhost:9092,another.host:9092

So as mentioned, bootstrap.servers provides the initial hosts that act as the starting point for a Kafka client to discover the full set of alive servers in the cluster.

Special Notes:

  • Since these servers are just used for the initial connection to discover the full cluster membership (which may change dynamically), this list does not have to contain the full set of servers (you may want more than one, though, in case a server is down).
  • Clients (producers or consumers) make use of all servers irrespective of which servers are specified in bootstrap.servers for bootstrapping.
like image 29
Ashan Priyadarshana Avatar answered Sep 18 '22 14:09

Ashan Priyadarshana