简体   繁体   中英

Producer Connection Pool - Kafka

I'm not able to understand how kafka maintain connection pool to the broker for the producer.

When i create a new object of producer and send a message to broker

producer = new Producer<Integer, String>(new ProducerConfig(props));
        producer.send(data);

will it return the connection from the connection pool ?

where is the Settings for the producer connection pool maintained in kafka ?

First of all, it depends on whether you are using a sync producer or async one. Let's assume you are using the sync producer.

There is no setting for maintaining producer pool as such. It will maintain as many threads as there are brokers. It will figure out the broker from the partition your key corresponds to and then use the dedicated thread for that broker. For more details please take a look at the field syncProducers in kafka source class ProducerPool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM