Hi Benjamin,

When ClientResource are instantiated inside an Application and Component, the 
client connectors declared at the Component level are automatically reused (via 
Context#clientDispatcher). Otherwise, you should indeed attach the same Client 
instance to each ClientResource using the #setNext(...) as you did. This is the 
proper way to scale your Restlet client app. 

The NPEs that you mention must be bugs. Could you give details about them?

Otherwise, in Restlet 2.1, we are developing our own internal HTTP client 
leveraging non-blocking NIO which is showing great scalability and latency with 
low thread usage. For now, org.restlet.ext.httpclient and org.restlet.ext.net 
should work fine.

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.o​rg
Noelios Technologies ~ http://www.noelios.com




-----Message d'origine-----
De : Benjamin Erb [mailto:[email protected]] 
Envoyé : vendredi 6 août 2010 16:01
À : [email protected]
Objet : RE: High performance Restlet client

Hi again,

sorry for pushing this, but these performance issues are about to become the 
show stopper for using Restlet in our application. 

We want to utilize the full features of HttpClient by using a connection pool 
and persistent connections. Here is the code how I configure HttpClient for 
restlet:

Context restletContext = new Context();         
restletContext.getParameters().set("maxTotalConnections", "16");                
restletContext.getParameters().set("maxConnectionsPerHost", "8");

Then client resources are created like this:

ClientResource cr = new ClientResource(restletContext, uri);

However, each client resource instantiation spawns a new Http Client instead of 
reusing available instances. This tremendously slows down our application. And 
I can't reuse client resource as long as they are not threadsafe.

On stackoverflow, I read the hint that I might spawn my own Client instance and 
add it to the client resource using 

Client client = new Client(restletContext, Protocol.HTTP); cr.setNext(client);

But as soon as the number of calls increases, this starts to throw NPEs so this 
also might not be the right solution.

Is there any way to instantiate the underlying HttpClient instance by myself 
and then attach it as the Restlet client? 

To sum it up, I'd like to use the nice abstractions and features of Restlet 
while still being able to use the full power of a HttpClient with a 
ThreadSafeClientConnManager. If I can't get to work the latter, I'll have to 
fall back to HttpClient alone and do the low level stuff on my own, which would 
make Restlet unfortunately obsolete for this use case.

So thanks in advance for help or any hints!

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2643825

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2667206

Reply via email to