« Return to Thread: RestS3Service locking up

Re: RestS3Service locking up

by James Murty-2 :: Rate this Message:

Reply to Author | View in Thread

It just occurred to me, another option may be to replace the MultiThreadedHttpConnectionManager in RestS3Client with a standard HttpConnectionManager that does not try to impose a limit on the number of simultaneous connections, see: http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpConnectionManager.html

The HttpConnectionManager manager will simply block until a connection becomes available, or you can request connections with a pre-set timeout value. This could be the simplest solution for your situation, and if it works it is probably something I could work into the JetS3t library as your use-case seems reasonable.

James


On Wed, Jun 4, 2008 at 11:58 PM, James Murty <jmurty@...> wrote:
Hi Ben,
 
Many thanks for the speedy and helpful reply.

You're welcome
 
I'm pretty confident that I must be hitting the default
"httpclient.max-connections" limit of 10.  Because I'm using jets3t in a web
application, with the standard one-Thread-per-request, the single
RestS3Service would have been handling multiple concurrent calls when the
site is busy, potentially many more than 10.

I see, and the number of simultaneous connections is essentially unbounded because it depends on how many active users you have on the web site.
 
Unfortunately the S3ServiceMulti and S3ServiceSimpleMulti classes don't do
what I'm after - I don't have a batch of S3 requests to do at any one time,
but rather many individual ones, as many Threads (created by the app server
rather than by my application code) do this:

No, the existing multi-threaded classes won't help much in this situation.

I've applied an ugly "brute force" fix, creating a new RestS3Service every
time - not nice, but something I can optimise later.

Hmm, there should be a better way to do this without having to recreate the service instances. Apart from the inefficiency of doing this, you will leave open the possibility that you will one day hit the hard limit on simultaneous HTTP connections imposed by your operating system. Depending on the system you are running on, the maximum number of HTTP connections your OS will allow can be surprisingly low.

In the short term, you may be able to increase the "httpclient.max-connections" limit to match the upper limit of HTTP connections your OS can handle then configure your Tomcat server to serve no more than this number of clients. It's a shame applying a limit to the number of client you can serve, but it's a better option that exceeding your outgoing HTTP connection limit. And this will save you from having to recreate RestS3Service objects. Presumably Tomcat will do something sensible if excess client requests arrive, like queueing them up and replying if/when it can?

Longer term, you may have to centralise the S3 communications to be able to better manage the outgoing connections. If your user base grows and every incoming client request also involves a simultaneous outgoing HTTP request to S3, you may quickly reach your system's network connection limit. This may make your application unable to scale beyond a certain point on a single server.

On the bright side, it's an interesting problem ;)

James

--
http://www.jamesmurty.com




--
http://www.jamesmurty.com

 « Return to Thread: RestS3Service locking up