When your app on Google app engine needs a pretty long time to load and you don't have much traffic, your GAE instance may be put offline by GAE automatically.

This would cause your website to be slow since it has to load all resources needed. For the current blog you're reading, it takes 5 seconds to load for the first time. In order to increase page speed for users, you need your GAE instance alive. In other words, you need traffic before GAE decides to put the serving instance offline (to save cost). 

So if you don't have that much traffic, you need to do it yourself. Of course, you don't want to do it manually.

You can set up a cron job as follows. 

  • create a file cron.yaml in the home directory of your GAE app.
  • add
- description: five minute run
  url: /refresh
  schedule: every 5 minutes

Note: just remember that only let the '.refresh' handler do the minimal work for warming-up (like just import all resources needs). 

More about cron task on GAE, refer to https://developers.google.com/appengine/docs/python/config/cron

Google talks about warmup requests and how they can be used to offset the loading request time, but honestly I find this service not working in this case since it's not for the first GAE instance

Other ways

App Engine also offers resident instances, which remain running all the time. Resident instances allow you to improve application performance, and, if your application uses backends, allow you to perform longer-running, larger tasks. You can enable resident instances on a backend, or by setting minimum idle instances.

Tags: GAE instance.

Posted in Google App English |

Leave a Reply