dev@jersey.java.net

Re: [Jersey] Reducing start up time (Appengine)

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 22 Sep 2010 14:51:15 -0700

Hi Hugo,

On Sep 21, 2010, at 9:04 AM, Hugo Visser wrote:

> Hi,
>
> I'm using Jersey (+Guice) in a few webapps on app engine and I love
> it. The only downside is the initialization time that Jersey needs,
> around 2 seconds on my apps.

Apart from jersey-core, jersey-server and jersey-guice are you using
any other Jersey jars?

I have heard of similar issues, with other non-Jersey app,s on
initialization slowness when using GAE.

One thing that might speed things up is disabling WADL generation:

https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ResourceConfig.html
#FEATURE_DISABLE_WADL

Otherwise it is currently not very easy to isolate or pick and choose
the "system" components defined by Jersey. This is something i want to
tackle in the next major release of Jersey.

It is possible to register your own implementation of a service
iterator provider:

https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/service/ServiceFinder.html
#setIteratorProvider
%28com.sun.jersey.spi.service.ServiceFinder.ServiceIteratorProvider%29

where you limit the set by hardcoding the set of provider classes
(registered in META-INF/service) files.

Paul.

> Unlike a normal container app engine instances are spun down once in
> a while so start up time matters a lot.
>
> I noticed that Jersey is doing a lot of discovering and registering
> of providers, some of which I most likely never use. Is there any
> way to hook in to this mechanism to reduce the number of components
> that get registered?
>
> What would be the best approach for doing lazy initialization of
> resources and providers and is this is feasible?
>
> Thanks,
>
> Hugo