I am using RestTemplate in Spring Boot, and here we have 3 timeout configs we can set on it.
connectTimeout: max time to acquire connection.readTimeout/socketTimeout: max time between two data packets to arrive,connectionRequestTimeout: max time during which a connection must be obtained from the pool. (If pool is being used)
Downstream service has a p99.9 around 200ms, hence I want to set the total timeout for the operation of a request/response cycle for a request to be 200ms at max.
It seems that there's no way of doing this on RestTemplate. If I set readTimeout/socketTimeout = 200ms, it can happen all data packets arrived under 200ms, but still the total req/response cycle took 400ms, if this happens I want to timeout the entire request as soon as it exceeds 200ms.
I feel as a owner of the upstream service I do care more about the entire req/response cycle time after connection is established instead of socketTimeout/readTimeout.
Is that possible with RestTemplate OR should we use some other library to restrict the total timeout of entire req/response cycle?