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 Florent Blondeau <fb...@pingwy.com> on 2007/12/17 18:50:37 UTC

[GlassFish] Using HttpClient from within an App server

Hi there,

I'm using HttpClient to make a lot of connexions to different servers.
I want to design my App as well as possible, and I've got some questions 
about
HttpClient design principles.
I'm using the WorkManager API (JSR 233) in Glassfish to create works ( 1 
work = 1 httpclient connection)
that are consumed by a thread pool. All that stuff with threads is done 
by the server (I use
CommonWorkManager from Sun).

My question is :
As I can't create threads directly in the App server, I can't use the 
MultiThreadedHttpConnectionManager...
Does somebody have an idea or an advice about the implementation of a
MultiThreadedHttpConnectionManager that would use the Work Manager, or 
be used in the
Work Manager ?
[Warning: this question is really dumb->] Can I use as many HttpClient 
instances as the number of
threads I have (about 5000) ?

Thanks for your advices, and for opening the discussion (that would make 
my ideas clearer...)

Florent

-- 

Pingwy
27, rue des arènes
49100 Angers


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: [GlassFish] Using HttpClient from within an App server

Posted by Florent Blondeau <fb...@pingwy.com>.
Thanks for your answers,

5 000 is not a real limit,  It will depends on the load tests, and  I 
don't really expect to reach that number.
As my app is distributed, I can increase the number of machines if 
resources are too much stressed.
I understand better what really is the MTHCM... I think I will have to 
make a custom WorkManager which could 
take care of the connections itself if I want to use a single instance 
of HttpClient and then get better performances...
It's a pretty hard thing to do I think, and I'm going to see that later, 
if the perfs are really a problem.
 I'm going to try the multiple instances  solution. I will keep in mind 
your wise advise about closing connections

Thanks to all

Florent

Raymond Kroeker a écrit :
> You will probably; hit a ceiling in terms of a total number of open file
> handles before you get to 5000.
>
> Raymond
>
> On Dec 17, 2007 11:35 AM, Roland Weber <os...@dubioso.net> wrote:
>
>   
>> Hello Florent,
>>
>>     
>>> As I can't create threads directly in the App server, I can't use the
>>> MultiThreadedHttpConnectionManager...
>>>       
>> MTHCM is not really multithreaded, it is just thread-safe for use
>> in multithreaded applications. Unfortunately though, there is one
>> background thread for connection GC. You could copy MTHCM and
>> remove the connection GC mechanism. It's not easy though, the
>> code is rather complex.
>>
>>     
>>> Can I use as many HttpClient
>>> instances as the number of
>>> threads I have (about 5000) ?
>>>       
>> You can, if you can live with 5000 connections being open
>> at the same time. Just make _very_ sure that you close
>> the connections (SimpleHttpConnectionManager.shutdown,
>> or create with the auto-close flag) once you don't need
>> them anymore.
>>
>> hope that helps,
>>  Roland
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>>     
>
>
>   


-- 
Pingwy
27, rue des arènes
49100 Angers


Re: [GlassFish] Using HttpClient from within an App server

Posted by Raymond Kroeker <ra...@raykroeker.com>.
You will probably; hit a ceiling in terms of a total number of open file
handles before you get to 5000.

Raymond

On Dec 17, 2007 11:35 AM, Roland Weber <os...@dubioso.net> wrote:

> Hello Florent,
>
> > As I can't create threads directly in the App server, I can't use the
> > MultiThreadedHttpConnectionManager...
>
> MTHCM is not really multithreaded, it is just thread-safe for use
> in multithreaded applications. Unfortunately though, there is one
> background thread for connection GC. You could copy MTHCM and
> remove the connection GC mechanism. It's not easy though, the
> code is rather complex.
>
> > Can I use as many HttpClient
> > instances as the number of
> > threads I have (about 5000) ?
>
> You can, if you can live with 5000 connections being open
> at the same time. Just make _very_ sure that you close
> the connections (SimpleHttpConnectionManager.shutdown,
> or create with the auto-close flag) once you don't need
> them anymore.
>
> hope that helps,
>  Roland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
---------------------------------------------------------
Raymond Kroeker

Re: [GlassFish] Using HttpClient from within an App server

Posted by Roland Weber <os...@dubioso.net>.
Hello Florent,

> As I can't create threads directly in the App server, I can't use the
> MultiThreadedHttpConnectionManager...

MTHCM is not really multithreaded, it is just thread-safe for use
in multithreaded applications. Unfortunately though, there is one
background thread for connection GC. You could copy MTHCM and
remove the connection GC mechanism. It's not easy though, the
code is rather complex.

> Can I use as many HttpClient
> instances as the number of
> threads I have (about 5000) ?

You can, if you can live with 5000 connections being open
at the same time. Just make _very_ sure that you close
the connections (SimpleHttpConnectionManager.shutdown,
or create with the auto-close flag) once you don't need
them anymore.

hope that helps,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org