How do we define kafka request.timeout.ms property in spring kafka properties file
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
In Kafka, request.timeout.ms controls how long the client waits for a broker response before treating the request as timed out. In Spring Boot and Spring Kafka, the right property path depends on which client you want to configure. For a producer setting, the usual location is under the producer-specific properties map rather than at the top level of the Spring configuration.
The Producer-Specific Property Path
If you want to configure the producer's request.timeout.ms, use this in application.properties:
The last line is the important one. It tells Spring Boot to pass the raw Kafka producer property through to the underlying producer configuration.
The same setting in YAML looks like this:
Why the properties Map Matters
Spring Boot has dedicated top-level keys for many common Kafka settings, but not every Kafka client property gets its own Boot-specific shortcut.
For any raw Kafka producer property that Spring does not expose directly, the general pattern is:
- '
spring.kafka.producer.properties.<kafka-property>=value'
That rule works for many producer options beyond request.timeout.ms.
This is why spring.kafka.producer.request.timeout.ms is usually not the right path. The Kafka property needs to go through the producer properties map.
Use the Generic Client Properties Only When Appropriate
Spring also supports a broader pass-through map:
That sends the property to Kafka clients more generally. For a producer-only timeout, the producer-specific form is usually clearer because it documents intent and avoids surprising interactions with other client types.
A practical rule is:
- use
spring.kafka.producer.properties.*for producer-only settings - use
spring.kafka.consumer.properties.*for consumer-only settings - use
spring.kafka.properties.*only when the setting is meant to apply more broadly
What request.timeout.ms Actually Influences
request.timeout.ms is the maximum time the client waits for a broker response to a request. For producers, that interacts with retries, delivery behavior, and the time it takes to surface network or broker problems.
If the timeout is too low:
- transient latency spikes may look like failures
- retries may happen more often than necessary
If the timeout is too high:
- real broker problems may take longer to surface
- application-level failure detection becomes slower
This means the best value depends on network conditions, broker load, and how quickly the application needs to react to trouble.
Example with a Producer Bean
You normally do not need extra Java config if the Spring properties are correct, but it can help to see the equivalent producer factory setup:
This Java version shows the same underlying Kafka property name. Spring Boot properties are simply a cleaner externalized way to express it.
Related Timeout Settings
request.timeout.ms is not the only timeout in play. Depending on the problem you are tuning, you may also need to think about:
- delivery timeout
- retry backoff
- connection setup timing
- consumer polling or session timeouts, if you are tuning consumers instead of producers
That is why timeout tuning should be done in context rather than by changing one number in isolation.
Common Pitfalls
One common mistake is using the wrong Spring property path, such as omitting the producer properties map.
Another mistake is setting the generic spring.kafka.properties.request.timeout.ms when the intent is clearly producer-only. That can make the configuration less explicit.
Developers also sometimes tune request.timeout.ms without considering related producer settings such as retries and delivery timing. Timeout behavior is rarely controlled by one property alone.
Finally, do not assume a timeout problem is always solved by increasing the timeout. Sometimes the real issue is broker reachability, SSL setup, or authentication failure rather than slow responses.
Summary
- In Spring Boot, define the producer timeout as
spring.kafka.producer.properties.request.timeout.ms. - The YAML equivalent goes under
spring.kafka.producer.properties. - Use the producer-specific path when the setting is meant only for producers.
- '
request.timeout.mscontrols how long the Kafka client waits for a broker response.' - Tune it alongside related retry and delivery settings, not in isolation.
Related reading
- How do you correctly write a Kafka Streams healthcheck?
- how do you get default Kafka configs global and per topic from command line?
- How do you handle recovering from a faulty connection using RabbitMQ java client library?
- How do you know when was a topic created on a Kafka broker?
- How do you cast a List of supertypes to a List of subtypes?
- How do you compare two version Strings in Java?
- How do you remove a queue binding from RabbitMQ?
- How does AMQP overcome the difficulties of using TCP directly?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.