Re: Best Practice to Use HttpClient in Multithreaded Environment

2009-08-17 Thread Ken Krugler
On Aug 16, 2009, at 7:45pm, yccheok wrote: Hi Ken, Can you elaborate more on "and if these exceeds a (configurable) limit, you'll get an exception."? At least in HttpClient 4.0, if you make a request, and there's no free connection in the pool, then your request blocks until a connecti

Re: Best Practice to Use HttpClient in Multithreaded Environment

2009-08-17 Thread Ken Krugler
Hi Yan Cheung, See below - but one caveat...Oleg could very well correct all of my comments below :) On Aug 16, 2009, at 6:17pm, yccheok wrote: Hi Ken, So, in my case, I should set httpConnectionManagerParams.setDefaultMaxConnectionsPerHost(50); Yes, if all of your requests will be comi

Re: Best Practice to Use HttpClient in Multithreaded Environment

2009-08-16 Thread yccheok
t;> May I know which method (A or B) is better, for application using 50+ >> + threads? >> >> I am using HttpClient 3.1 >> >> Thanks and Regards >> Yan Cheng Cheok >> >> >> >> >> >> ----------------- >&g

Re: Best Practice to Use HttpClient in Multithreaded Environment

2009-08-16 Thread yccheok
t; >> --------------------- >> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org >> For additional commands, e-mail: httpclient-users-h...@hc.apache.org >> > > -- > Ken Krugle

Re: Best Practice to Use HttpClient in Multithreaded Environment

2009-08-16 Thread Ken Krugler
Hi Yan Cheng, I haven't used HttpClient 3.x for a while - switched to 4.0 and haven't looked back. But in general method A is going to work better. You can configure the MultiThreadedHttpConnectionManager with a maximum number of threads - e.g. you could pick a number equal to the max # o

Re: Best Practice to Use HttpClient in Multithreaded Environment

2009-08-16 Thread Yan Cheng Cheok
(); } Thanks and Regards Yan Cheng Cheok --- On Sun, 8/16/09, Yan Cheng Cheok wrote: > From: Yan Cheng Cheok > Subject: Best Practice to Use HttpClient in Multithreaded Environment > To: httpclient-users@hc.apache.org > Date: Sunday, August 16, 2009, 9:11 PM > Hi all, > >

Best Practice to Use HttpClient in Multithreaded Environment

2009-08-16 Thread Yan Cheng Cheok
Hi all, All the while, I am using HttpClient in multithreaded environment. For every threads, when they initiate a connection, they will create a complete new HttpClient instance. Recently, I discover, by using this approach, it can cause the user is having too many port being opened, and most