AppEngine Plugin
  1. AppEngine Plugin
  2. GPAPPENGINE-67

app engine: slow grails initialization causes DeadlineExceededExceptions very frequently

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      grails 1.1.2 app-engine-0.8.5 gorm-jpa-0.6

      Description

      The issue is outlined here by Google:

      http://googleappengine.blogspot.com/2009/12/request-performance-in-java.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+GoogleAppEngineBlog+%28Google+App+Engine+Blog%29&utm_content=Google+Reader

      If an app is idle app engine removes it and will spin up a new server when a request comes in for it. This causes DeadlineExceededExceptions almost all the time. The grails app must start up in under 30 seconds or app engine will throw a big ugly exception. I'm not sure what can be done. Maybe lazy loading things when needed instead of loading them upfront at startup?

      This is a show stopper for using grails on appEngine in a production environment.

      Maybe I am missing some "precompile" or "startupFaster" flag?

      If anybody has any suggestions I'd love to hear them? (grails + appengine == so much goodness)

        Activity

        Hide
        Pelle Poluha added a comment -

        Wouldn't the easiest way be to define a cron job in AppEngine? Like this:

        <cronentries>
        <cron>
        <url>/</url>
        <description>Ping the sajt to keep it alive</description>
        <schedule>every 1 minutes</schedule>
        </cron>
        </cronentries>

        But perhaps Google won't like it?

        Show
        Pelle Poluha added a comment - Wouldn't the easiest way be to define a cron job in AppEngine? Like this: <cronentries> <cron> <url>/</url> <description>Ping the sajt to keep it alive</description> <schedule>every 1 minutes</schedule> </cron> </cronentries> But perhaps Google won't like it?
        Hide
        Felipe Rodrigues added a comment - - edited

        Pelle,

        That could work too, but didn't work for me. The problem is a cron job smaller schedule is every minute. Turns out that 1 minute is enough idle time to google put the JVM to sleep.
        The code on gist ping the app every 30s and it is much better, but you can try the cron job and let us know if it works for you.

        PS: I know I mentioned 1 minute before, so I just edited my previous comment.

        Show
        Felipe Rodrigues added a comment - - edited Pelle, That could work too, but didn't work for me. The problem is a cron job smaller schedule is every minute. Turns out that 1 minute is enough idle time to google put the JVM to sleep. The code on gist ping the app every 30s and it is much better, but you can try the cron job and let us know if it works for you. PS: I know I mentioned 1 minute before, so I just edited my previous comment.
        Hide
        Graeme Rocher added a comment -

        I've put several optimizations into Grails 1.3 for startup time improvements and on Tomcat I'm seeing Grails startup in 7-10 seconds. Unfortunately this doesn't translate to GAE as on app engine I am still seeing the hard limit exceeded exceptions. We're in touch with Google over the problem, and hope to have a solution at some point

        Show
        Graeme Rocher added a comment - I've put several optimizations into Grails 1.3 for startup time improvements and on Tomcat I'm seeing Grails startup in 7-10 seconds. Unfortunately this doesn't translate to GAE as on app engine I am still seeing the hard limit exceeded exceptions. We're in touch with Google over the problem, and hope to have a solution at some point
        Hide
        Gavin Aiken added a comment -

        Thanks for looking into this Graeme, I really appreciate all your hard work. Grails + GAE will make web dev so much easier but for the time being my lovely app is only available @ localhost.

        Show
        Gavin Aiken added a comment - Thanks for looking into this Graeme, I really appreciate all your hard work. Grails + GAE will make web dev so much easier but for the time being my lovely app is only available @ localhost.
        Hide
        Pascal Voitot added a comment -

        Hello guys,
        I have exactly the same problem as anyone and here is my experience and questions.
        I have performed some tests with Grails+GAE:

        • I create a raw grails project (the simpliest possible project with nothing in it) and I install it in GAE and I try to access it. Result:
          • 1st connection : 500 Error: Server Error
          • 2nd connection : I can access the site and it works
          • Wait a few minutes and I have to begin again from 0
        • I add 1Domain/1Controller/1Service and one plugin such as CookiePlugin.
          • 1st connection : 500 Error: the famous DeadLineExceededException
          • 2nd connection or 3rd sometimes : I can access the site and it works
          • Wait a few minutes and I have to begin again from 0

        If I add more plugins or classes, it won't start at all even if I insist a lot!

        Ok, this is what everyone can see...

        Graeme, I would like to ask 2things:

        • Could you give some clue concerning your optimizations in grails startup to make it start quicker?
          I've been looking at the code and everything (appContext->beans+classloaders+classes+artefacts->listeners+filters+servlets) need to be initialized before being able to treat any webrequest and it's quite long to do that for sure. I thought about something such as Spring Lazy loading to make everything load when it's required and not before so that GAE startup is not monolithic. It could allow loading and instantiating things downstream but there are so many inter-dependent artefacts requiring beforehand initialization that I'm not sure it could help anyway!
        • What kind of optimizations Google envisions? Will it be a "structural" evolution that makes Java framework in appengine viable (because I know our problems are reported by other people using Java in GAE)? Or will it be an evolution in Grails to make it GAE-compliant? And will it appear in days, weeks, years?

        If there are some tracks to follow immediately, I could help a bit because I feel like in jail due to this ignominious limitation

        Show
        Pascal Voitot added a comment - Hello guys, I have exactly the same problem as anyone and here is my experience and questions. I have performed some tests with Grails+GAE: I create a raw grails project (the simpliest possible project with nothing in it) and I install it in GAE and I try to access it. Result: 1st connection : 500 Error: Server Error 2nd connection : I can access the site and it works Wait a few minutes and I have to begin again from 0 I add 1Domain/1Controller/1Service and one plugin such as CookiePlugin. 1st connection : 500 Error: the famous DeadLineExceededException 2nd connection or 3rd sometimes : I can access the site and it works Wait a few minutes and I have to begin again from 0 If I add more plugins or classes, it won't start at all even if I insist a lot! Ok, this is what everyone can see... Graeme, I would like to ask 2things: Could you give some clue concerning your optimizations in grails startup to make it start quicker? I've been looking at the code and everything (appContext->beans+classloaders+classes+artefacts->listeners+filters+servlets) need to be initialized before being able to treat any webrequest and it's quite long to do that for sure. I thought about something such as Spring Lazy loading to make everything load when it's required and not before so that GAE startup is not monolithic. It could allow loading and instantiating things downstream but there are so many inter-dependent artefacts requiring beforehand initialization that I'm not sure it could help anyway! What kind of optimizations Google envisions? Will it be a "structural" evolution that makes Java framework in appengine viable (because I know our problems are reported by other people using Java in GAE)? Or will it be an evolution in Grails to make it GAE-compliant? And will it appear in days, weeks, years? If there are some tracks to follow immediately, I could help a bit because I feel like in jail due to this ignominious limitation

          People

          • Assignee:
            Unassigned
            Reporter:
            justin friedl
          • Votes:
            25 Vote for this issue
            Watchers:
            28 Start watching this issue

            Dates

            • Created:
              Updated: