Hi Oleg,
Thankx for the quick reply. I will turn off logging and check it out.
I wasn't too sure about to post it in dev-forum or in users-forum. So posted
it in both places. Will post it in users-forum from now on. Thankx again for
the reply.
~Rajesh.B
On Tue, Apr 22, 2008 at 12:49 AM, Oleg Kalnichevski <[EMAIL PROTECTED]>
wrote:
>
> On Mon, 2008-04-21 at 14:36 +0530, Rajesh Balamohan wrote:
> > Folks,
> >
>
> Rajesh,
>
> First off, please _DO NOT_ cross post dev and users lists.
>
>
> > I am using HttpClient 3.0 in one of our projects. I have tried to give
> the
> > code snippet below.
> >
> > We try to initialize mutithreaded http connection manager once in our
> code
> > like the following.
> >
> > MultiThreadedHttpConnectionManager mthcm = new
> > MultiThreadedHttpConnectionManager();
> > mthcm.setMaxConnectionsPerHost(maxConnections);
> > mthcm.setMaxTotalConnections(100);
> > httpClient = new HttpClient(mthcm);
> >
> >
> > And we try to reuse httpClient multiple times (SAME INSTANCE) in another
> > method like the following.
> >
> > PostMethod postMethod = new PostMethod("http://" + serverName + ":" +
> port +
> > Constants.URL);
> > BinaryEncoder be = new BinaryEncoder(); //ignore this since its our
> > proprietary code
> > ByteBuffer bb = be.encodeRequest(request);
> > postMethod.setRequestBody(new String(bb.array()));
> > try {
> > httpClient.executeMethod(postMethod);
> > } catch (Exception e) {
> > throw new MethodExecuteException(e);
> > }
> >
> > While doing the profiling with JProbe, most of the time was being spent
> in
> > httpClient.executeMethod(). Further analysis showed that most of the
> time
> > spent INSIDE executeMethod() was in
> > org.apache.commons.httpclient.Wire.wire(String,InputStream).
> >
>
> Wire#wire is not meant to be executed unless you have wire logging on.
> There is no point running any benchmarks with wire logging on, because
> you just end up measuring performance of the underlying logging toolkit,
> not that of HTTP transport.
>
> > And this method is spending most of the time in StringBuffer.append()
> > internally.
> >
> > *Observerations and Questions:
> > *1. We are sending 2Kb payload in the POST method as binary content
> using
> > BinaryEncoder we have got. Kindly note that this is not reported as
> > timeconsuming method. So let us ignore the BinaryEncoder part.
> > 2. Is there any other way to make better usage of HttpClient for 2Kb
> > payloads. Maximum i can set is to "disable" nagle's algorithm so that
> the
> > data can get flushed immediately. Also, set the MTU in OS to 1500 or so.
> > 3. Is there a way to optimize Wire.wire()?
> > 4. Are there any other parameters we can set to optimize httpClient
> further?
> >
>
> Please refer to the HttpClient optimization guide
>
> http://hc.apache.org/httpclient-3.x/performance.html
>
> Hope this helps
>
> Oleg
>
> > It would be great if you could give pointers on this. Please let me know
> if
> > you need more information on this.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
~Rajesh.B