views:

363

answers:

5

Hi,

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 small client hitting app every 5-30 minutes and I run 3-5 of threads with such client.

I noticed huge differenced in response times and started to investigate issue. I found reason very quick. I am experiencing same issues as described in following topics:

Uneven response time between connection to server to first byte sent

Application instances seem to be too aggressively recycled

Getting 'Request was aborted after waiting too long to attempt to service your request.' after application idle

I am using Springframework, it tkes around 18-20s to start app instance, which is causing response times to take from 1s (when requests hits running app - very rare) to 22s when fresh application is created.

Is there any solution for this? I was thinking about creating most basic servlet performing critical tasks (serving API call) and leave UI as is. But then I would loose all benefits of Springframework.

Is there any solution for this?

After solving (hacking) numerous constrains of App Engine which I hit while developing my app that is the one I think will make me move out of App Engine... that's simply to much to all the time think how to win with GAE problems than how to solve my application problems...

Any help?

Regards Konrad

+3  A: 

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.

Iker Jimenez
Hi, thanks for your answer, but I don't think so that instance running will be always used to serve requests, GAE is kind of cloud solution, so your requests could be served even on different machines.
Konrad
I suspect that if you send requests at regular intervals your app's instance would be kept on the same server. Even if it was changed to another one, all you really care about is that your app is ready when a real request comes from a real user. Just make sure you send requests fast enough so your app is always "hot" and alive.
Iker Jimenez
Any ideas what interval should be? I am going to try 2 minutes for start ...
Konrad
I've not implemented this myself, so I don't know. Other people have done it, search for their comments. You can also detect by checking the server's response time if your interval has been too long and change it dynamically.
Iker Jimenez
A: 

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

Adam Crossland
Hi, thanks for your help. Even if app would start in 3s - that would not be solution.I am bit frustrated with GAE after this, shame on me that I did not found this issue before building my app (fortunately I think it won't be to much work to run it on regular infrastructure). Hope some other people will read this type of posts before engaging with GAE for good.I will try to solve it by creating basic servlet for serving API calls, but this seams to be like going back to CGI and shell script :D
Konrad
Konrad, sorry to hear that you made this discovery about App Engine late in your development cycle. Must be very frustrating. App Engine is certainly a different kind of web application platform than people the sort which we a generally accustomed to, and there are gotchas that are not readily apparent or well-communicated. Id o hope that will change as AE matures and becomes more well-understood by the programming populace.
Adam Crossland
+2  A: 

Use the new precompilation feature.

<!-- appengine-web.xml -->

<precompilation-enabled>true</precompilation-enabled>
+1  A: 

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.

Kyle
Interesting if DispatcherServlet is marked as Serializable but contains attributes which are not serializable. Damn.
pjesi
+1  A: 

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/

Marco