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 Håkon Sagehaug <Ha...@bccs.uib.no> on 2009/11/24 14:23:50 UTC

Using one HttpClient between many threads

Hi all,

I've got a web service that pulls files for different sources, among http,
and I huse HttpClient for this, so my question is. If I create  a Httpclient
from ThreadSafeClientConnManager, can I then have one instance(static) of
HttpClient that is shared between the instances of the web service. So I can
save some resources and also not creating a new HttpClient for each request.

cheers, Håkon
-- 
Håkon Sagehaug, Scientific Programmer
Parallab, Bergen Center for Computational Science (BCCS)
UNIFOB AS (University of Bergen Research Company)
Hakon.Sagehaug@bccs.uib.no, phone +47 55584125

Re: Using one HttpClient between many threads

Posted by Ken Krugler <kk...@transpac.com>.
On Nov 24, 2009, at 5:23am, Håkon Sagehaug wrote:

> Hi all,
>
> I've got a web service that pulls files for different sources, among  
> http,
> and I huse HttpClient for this, so my question is. If I create  a  
> Httpclient
> from ThreadSafeClientConnManager, can I then have one  
> instance(static) of
> HttpClient that is shared between the instances of the web service.  
> So I can
> save some resources and also not creating a new HttpClient for each  
> request.

Yes, that's correct.

Note that by default the ThreadSafeClientConnManager has a limit of 20  
simultaneous connections, so you might need to increase that limit.

-- Ken

PS - See http://hc.apache.org/httpcomponents-client/tutorial/html/ for  
lots of useful info, especially http://hc.apache.org/httpcomponents-client/tutorial/html/connmgmt.html#d4e629


> cheers, Håkon
> -- 
> Håkon Sagehaug, Scientific Programmer
> Parallab, Bergen Center for Computational Science (BCCS)
> UNIFOB AS (University of Bergen Research Company)
> Hakon.Sagehaug@bccs.uib.no, phone +47 55584125

--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g





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