One of the more common complaints I have read about the AppEngine database (for Java) is that it is extremely slow when it come to “cold start time”. What does this mean? And is it something I should be worried about?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is something you should be worried about.
Google App Engine spins up a new JVM to service requests when your app has not had any requests for a certain time period. Getting a handle on the datastore from “cold” – i.e. for the first time in a JVM – can take a considerable amount of time, as much as 5+ seconds.
After you have a handle on the datastore (normally an instance of
PersistenceManager), everything is fine (for the life of the JVM!).EDIT:
Spinning up a fresh JVM in GAE-Java is also slow. Read http://code.google.com/appengine/docs/java/datastore/overview.html and you will see that they use a Singleton class for the availability of a
PersistenceManagerFactory, as they describe the operation of instantiating one as “expensive”.You could test it out for yourself. Create a brand new application on GAE-Java that merely returns “Hello World!” and you will find that the first request to the application takes a number of seconds.
Add a request for the
PersistenceManagerFactoryand you will find that the first request takes a few seconds more.EDIT EDIT:
I have now created this test for your viewing pleasure:
http://stackoverflowanswers.appspot.com/helloworld
You will either instantly see “Hello, world 0” or “Hello, world xxxx” where xxxx is a count in MS of how long it took to get a handle on the datastore. I think that the complexity and number of indexes in the datastore may have an impact on how long it takes to get a handle on the datastore, as it is quicker in this app than in some of my other apps.
PMF is an exact copy of the one provided in the app engine docs.
EDIT EDIT EDIT:
I changed my code so that it instantiates a
PersistenceManagerFactorywith each request and now it throws 500 server errors, and in the logs:I don’t think I need to provide any more proof that getting a handle on the datastore in app engine is SLOW.