RE: client perfomance question
Hi Evgeny, The Client instance are already thread-safe and reusable, no need to recreate them or to pool them! Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. Best regards, Jerome > -Message d'origine- > De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk > Envoyé : mercredi 27 juin 2007 14:19 > À : discuss@restlet.tigris.org > Objet : client perfomance question > > Hello! > In my application i'm actively using restlet clients for > communicating > with my service(also restlet-based). > So does it make sense to pool client instances and not create > them on any > request. > > -- > Best Regards > Evgeny K. Shepelyuk
Re: client perfomance question
27.06.07 в 22:03 Jerome Louvel в своём письме писал(а): Hello Jerome. The answer about pooling is clear, thxn. But this is not so much clear for me :) Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. If you have some possibilities and free time could you describe this more detailly. Thnx in advance. Hi Evgeny, The Client instance are already thread-safe and reusable, no need to recreate them or to pool them! Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk Envoyé : mercredi 27 juin 2007 14:19 À : discuss@restlet.tigris.org Objet : client perfomance question Hello! In my application i'm actively using restlet clients for communicating with my service(also restlet-based). So does it make sense to pool client instances and not create them on any request. -- Best Regards Evgeny K. Shepelyuk -- Best Regards Evgeny K. Shepelyuk
Re: client perfomance question
27.06.07 в 22:03 Jerome Louvel в своём письме писал(а): Hi Evgeny, The Client instance are already thread-safe and reusable, no need to recreate them or to pool them! Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk Envoyé : mercredi 27 juin 2007 14:19 À : discuss@restlet.tigris.org Objet : client perfomance question Hello! In my application i'm actively using restlet clients for communicating with my service(also restlet-based). So does it make sense to pool client instances and not create them on any request. -- Best Regards Evgeny K. Shepelyuk Hello Jerome. Maybe i will try to describe my situation more detailly to explain what issues i'm facing. I have restlet-based serivce that exposes some XML documents. It's perfomance is tested with ab and satisfies my needs :) At client side i have some JSP that are using my service. In JSP code i'm writing smth like. Client client = new Client(Protocol.HTTP); client.getContext() Response resp = client.get(..); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(resp.getEntity().getStream(), "UTF-8"); And as a result i'm having huge delays for getting the XML text. I've discovered it with tests that measures delays of ccertain operation. My client uses java.net.HttpURLConnection-based connector class. Then i decided to try use simple URLConnection approach. URLConnection con = new URL().openConnection(); ((HttpURLConnection)con).setRequestMethod("GET"); con.setDoOutput(true); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(con.getInputStream(), "UTF-8"); And according to timing delays for getting XML reduced 4-5 times. So i'm not thinking that restlet client is workign so slow and wanted someone to advice if i'm usign Client instances incorrectly. Thnx. -- Best Regards Evgeny K. Shepelyuk
RE: client perfomance question
Hi Evgeny, > > Inside a Restlet Application, the best is to > > leverage the Context.dispatcher mechanism which allows the > > sharing of client connectors between several applications. > > If you have some possibilities and free time could you > describe this more detailly. There is a diagram in the tutorial that provides an overview of the sharing of client connectors between several applications: http://www.restlet.org/documentation/1.0/tutorial#part05 Then, inside a Restlet or a Resource, you can invoke the getContext().getDispatcher() method to get an instance of the Uniform interface. This dispatcher will automatically route the request to the most appropriate client connector, taking into account the Request.protocol property or the Request.resourceRef's scheme. Best regards, Jerome
RE: client perfomance question
Evgeny, > Maybe i will try to describe my situation more detailly to > explain what issues i'm facing. > > I have restlet-based serivce that exposes some XML documents. > It's perfomance is tested with ab and satisfies my needs :) Cool :) > At client side i have some JSP that are using my service. In > JSP code i'm writing smth like. > > Client client = new Client(Protocol.HTTP); > client.getContext() > Response resp = client.get(..); > > XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); > XmlPullParser xpp = factory.newPullParser(); > xpp.setInput(resp.getEntity().getStream(), "UTF-8"); > > And as a result i'm having huge delays for getting the XML text. I've > discovered it with tests that measures delays of ccertain operation. > My client uses java.net.HttpURLConnection-based connector class. > > Then i decided to try use simple URLConnection approach. > > URLConnection con = new URL().openConnection(); > ((HttpURLConnection)con).setRequestMethod("GET"); > con.setDoOutput(true); > > XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); > XmlPullParser xpp = factory.newPullParser(); > xpp.setInput(con.getInputStream(), "UTF-8"); > > And according to timing delays for getting XML reduced 4-5 times. > So i'm not thinking that restlet client is workign so slow > and wanted someone > to advice if i'm usign Client instances incorrectly. Thanks for sharing this experience. The observed performance is very surprising to me, there is really no technical reason for such an overhead, the code inside the connector should be straightforward and cause no noticeable delay. Could you drill down the Restlet source code to give us indication of where this time is spent, maybe using a profiling tool? Best regards, Jerome
Re: client perfomance question
Hi Jerome! Ok so if i understood correctly. I can use Client instance inside my applications (not restlet meaning of application, but just external app that contacts my RESTful service) as singleton ? I can create on instance of clietn, set my settings to it and share it to all my JSP/classes that needs to contact my RESTFul service.
Re: client perfomance question
Hi Evgeny, Yes, you can use a Client instance as a singleton as you describe. There is no need for a full Restlet application for that. Cheers, Jerome Evgeny Shepelyuk a écrit : Hi Jerome! Ok so if i understood correctly. I can use Client instance inside my applications (not restlet meaning of application, but just external app that contacts my RESTful service) as singleton ? I can create on instance of clietn, set my settings to it and share it to all my JSP/classes that needs to contact my RESTFul service.