You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Santhosh Kumar <sa...@gmail.com> on 2019/02/22 06:23:00 UTC

Executor.execute very slow.

Hi - In our project we are using Apache http client and fluent jar to the
hit AWS cloud endpoint where in we pass request and get the response back.
Code snippet is given below.  But the performance is very slow. Connection
establishing and socket read takes more time. Can you please suggest if
there is any way to optimize this?

               Executor executor = Executor.newInstance(httpClient);
//Executor executor = Executor.newInstance(buildHttpClient());
Response channelResponse = null;
Request httpRequest = Request.Post(serviceEndpointUrl)
.addHeader("Service", wizConnectRequest.getTransCode())
.addHeader("consumer", channel).addHeader("Async",
String.valueOf(wizConnectRequest.isAsync()))
.addHeader("TimeOutPeriod",
Integer.toString(wizConnectRequest.getTimeOutPeriod()));


channelResponse = executor.execute(httpRequest.useExpectContinue()
.connectTimeout(endPointTimeout) //in milliseconds TODO is it not managed
through the Spring???
.bodyString(request, ContentType.DEFAULT_TEXT));

I have attached the performance snapshot using Dynatrace tool where the
total time taken is 589.62. Please let me know.

Regards
Shan

Re: Executor.execute very slow.

Posted by Gary Gregory <ga...@gmail.com>.
Hi,

You should make sure to reuse your HttpClient instance.

Gary

On Fri, Feb 22, 2019, 05:08 Santhosh Kumar <santtarius@gmail.com wrote:

> Hi - In our project we are using Apache http client and fluent jar to the
> hit AWS cloud endpoint where in we pass request and get the response back.
> Code snippet is given below.  But the performance is very slow. Connection
> establishing and socket read takes more time. Can you please suggest if
> there is any way to optimize this?
>
>                Executor executor = Executor.newInstance(httpClient);
> //Executor executor = Executor.newInstance(buildHttpClient());
> Response channelResponse = null;
> Request httpRequest = Request.Post(serviceEndpointUrl)
> .addHeader("Service", wizConnectRequest.getTransCode())
> .addHeader("consumer", channel).addHeader("Async",
> String.valueOf(wizConnectRequest.isAsync()))
> .addHeader("TimeOutPeriod",
> Integer.toString(wizConnectRequest.getTimeOutPeriod()));
>
>
> channelResponse = executor.execute(httpRequest.useExpectContinue()
> .connectTimeout(endPointTimeout) //in milliseconds TODO is it not managed
> through the Spring???
> .bodyString(request, ContentType.DEFAULT_TEXT));
>
> I have attached the performance snapshot using Dynatrace tool where the
> total time taken is 589.62. Please let me know.
>
> Regards
> Shan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org