I posted this on GAE for Java group, but I hope to get some answers here quicker :)
I decided to do some long-run performance tests on my application. I created some
in case folks live in AE-land and want a quick-and-dirty keep-alive pinger, this one works like a charm (windows):
http://www.coretechnologies.com/products/http-ping/
I know of some people having a keep-alive thing running in order to have an instance of their app always running. I mean, have a client that sends a request every X seconds so your app doesn't get recycled.
This is a quick thing to implement but seems to go against the spirit of the platform. Make your numbers and check if it is worth it.
Another option would be to refactor your application to make use of more lazy-loading than it does at the moment so it doesn't take that long to kick off.
I don't know if you have any other option apart from these 2.
SDK 1.4.0 has this new feature:
- Developers can now enable Warmup Requests. By specifying a handler in an app's appengine-web.xml, App Engine will attempt to to send a Warmup Request to initialize new instances before a user interacts with it. This can reduce the latency an end-user sees for initializing your application.
Use the new precompilation feature.
<!-- appengine-web.xml -->
<precompilation-enabled>true</precompilation-enabled>
This is definitely a tricky issue with AppEngine applications. The purists will tell you to look at why your application takes so long to start up and work backwards from there. In your case, the answer is obvious: you are using Spring, and it has to load many class files and instantiate many objects.
The pragmatic answer, if you can live without Spring, is to make sure that you app instance stays warm. You can either ping it from an external source frequently enough that AppEngine never unloads it, or you could use an AppEngine cron job that runs frequently enough to keep your app in-memory.
I am sure that Google despises the second option, as that runs against much of the fundamental ideas behind AE, but nevertheless, it is an issue that they and we 9as AE developers) must consider.
Here is a related discussion
What would be good is if we could serialize the DispatcherServlet
to the memcache, and then deserialize it from the memcache on a cold start if it is there. Then the instantiation of Spring would be really short.
DispatcherServlet
is already marked as Serializable
, we just need to find a way to serialize the WebApplicationContext
object that the DispatcherServlet
contains.