# Java Rest Client time cost confusion

**URL:** <https://discuss.elastic.co/t/java-rest-client-time-cost-confusion/213806>\
**Category:** Elasticsearch\
**Created:** [January 5, 2020, 3:00pm UTC](https://discuss.elastic.co/t/java-rest-client-time-cost-confusion/213806 "2020-01-05T15:00:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyzmonday](https://avatars.discourse-cdn.com/v4/letter/x/f07891/32.png) [@xyzmonday](https://discuss.elastic.co/u/xyzmonday)\
**Post date:** [January 5, 2020, 3:00pm UTC](https://discuss.elastic.co/t/java-rest-client-time-cost-confusion/213806/1 "2020-01-05T15:00:25Z")

</div>

Hi,I have been confused by time cost of Java Rest Client . I use Java Rest Client （6.6.0 vesion）to send requst to ES. Here is my basic config for REST Client:  
private static final int CONNECT\_TIMEOUT = 10000;  
private static final int SOCKET\_TIMEOUT = 10000;  
private static final int CONNECTION\_REQUEST\_TIMEOUT = 10000;  
private static final int MAX\_CONNECT\_NUM = 300;  
private static final int MAX\_CONNECT\_PER\_ROUTE = 200;  
We have a api which is a msearch request, and use CAT to detect the api performance. To our surprise,mearcha api time cost is under 60ms at most of the time，however sometime it will be over 400ms. At same time,network IO of ES cluster is normal . Accroding to my study, Java Rest Client use HttpAsyncClient to send request, and has a connection manager pool，so time cost of request should not be tremble. Additionlly, I have tried to use CURL tool to send simple GET periodically by shell on Linux OS, and show that 'time\_starttransfer' is sometime high (over 300ms).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 2, 2020, 3:00pm UTC](https://discuss.elastic.co/t/java-rest-client-time-cost-confusion/213806/2 "2020-02-02T15:00:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
