0

In my AppEngine application, the servlet takes a long time to initialize. This is not a big problem with a usual Tomcat deployment, as the initialization happens only once. However, in AppEngine, I noticed that many service requests cause AppEngine to launch a new process and do the initialization, and thus, these sevrice requests take a long time.

Is it possible to disconnect the initialization from the service request? Somehow tell AppEngine to do the initialization in the background, so that when a user asks for a page, he won't have to wait so long?

Erel Segal-Halevi
  • 26,318
  • 26
  • 92
  • 153
  • For reference, here is the message I get in my logs every several requests: "This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application." – Erel Segal-Halevi Jun 14 '12 at 17:15
  • 1
    This should answer your questions: http://stackoverflow.com/questions/9577457/gae-go-this-request-caused-a-new-process-to-be-started-for-your-application – Vishal Biyani Jun 14 '12 at 17:32
  • @vishal.biyani that is far from answering his question. It is even a different platform. – Mark Finch Jun 14 '12 at 19:52
  • @MarkFinch I thought the new instance is getting created because the instance goes idle and hence startups from scratch. Irrespective of platform, hitting a page in GAE app will help in keeping the instance always alive. Or have I completely misunderstood? – Vishal Biyani Jun 14 '12 at 20:25
  • 1
    @vishal.biyani it isn't that simple in my experience. I have tried cron and just manually loading page at different intervals. What I have found is that new instances will seemingly randomly spin up on requests regardless of the time between requests. I quite often have 2 instances going for 1 user in testing. I have searched and not found any useful way to control the instance spinup. That unfortunately doesn't answer his question of how to make the spinup faster. Because no matter how well you can keep an instance loaded it will eventually spin up another. – Mark Finch Jun 14 '12 at 21:03

1 Answers1

2

You can setup Idle instances or Warmup Requests a the Application Settings at the Applications Settings section of the App Engine console of your app. That should avoid getting those slow initialization times, as your app would be preloaded and ready to go.

  • 1
    Thanks! I didn't know about these options. Setting a minimum for Idle Instances is not available for me because my app is free, but warmup requests is available even for free apps: https://developers.google.com/appengine/docs/java/config/appconfig#Warmup_Requests – Erel Segal-Halevi Jun 15 '12 at 08:30