apache-kafkakafka-producer-api

Apache Kafka Producer Config: 'request.timeout.ms' VS. 'max.block.ms' properties


Given the below synchronous kafka producer

Properties props = new Properties();
props.put("max.block.ms", 30000);
props.put("request.timeout.ms", 30000);
props.put("retries", 5);

KafkaProducer<String, byte[]> produce = new KafkaProducer<>(props);

//Send message
producer.send(producerRecord).get();

help me understand the difference between request.timeout.ms and max.block.ms producer configs. Does either include max time for all retries? Or does each retry have its own timeout?


Solution

  • request.timeout.ms is used to timeout request, I would set this to the maximum time I can wait for the response.

    max.block.ms is used for producer to block buffer time, serialization time etc.

    For details look at this one. https://cwiki.apache.org/confluence/display/KAFKA/KIP-19+-+Add+a+request+timeout+to+NetworkClient