On Thu, 2015-06-25 at 12:33 -0700, Check Peck wrote:
> Thanks Oleg. Got the idea now. Basically earlier, I was not using setting
> any timeout value on Http request but I was setting the timeout value on my
> Future and by default the timeout value on http request was -1 so it was
> waiting for most of the time and that's why I was seeing lot of TIME_WAIT.
> I have made the code changes like this now:
>
> This is the request factory I am setting on my RestTemplate now. I wanted
> to check with you to see, do you think these settings are ok for better
> performance?
>
> private ClientHttpRequestFactory clientHttpRequestFactory() {
> HttpComponentsClientHttpRequestFactory requestFactory = new
> HttpComponentsClientHttpRequestFactory();
> RequestConfig requestConfig =
> RequestConfig.custom().setConnectionRequestTimeout(1000).setConnectTimeout(1000)
>
> .setSocketTimeout(1000).setStaleConnectionCheckEnabled(false).build();
> SocketConfig socketConfig =
> SocketConfig.custom().setSoKeepAlive(true).setTcpNoDelay(true).build();
>
> PoolingHttpClientConnectionManager
> poolingHttpClientConnectionManager = new
> PoolingHttpClientConnectionManager();
> poolingHttpClientConnectionManager.setMaxTotal(800);
> poolingHttpClientConnectionManager.setDefaultMaxPerRoute(700);
>
> CloseableHttpClient httpClientBuilder =
> HttpClientBuilder.create()
>
> .setConnectionManager(poolingHttpClientConnectionManager).setDefaultRequestConfig(requestConfig)
> .setDefaultSocketConfig(socketConfig).build();
>
> requestFactory.setHttpClient(httpClientBuilder);
> return requestFactory;
> }
>
Settings look reasonable to me.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]