views:

536

answers:

3
  1. App Engine allows you 30 seconds to load your application
  2. My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.
  3. If the app is idle (does not receive a request for a while), it needs to be re-loaded.

So, to avoid the app needing to be reloaded, I want to simulate user activity by pinging the app every so often.

But there's a catch . . .

If I ping the app and it has already been unloaded by App Engine, my web request will be the first request to the app and the app will try to reload. This could take longer than 30 seconds and exceed the loading time limit.

So my idea is to ping the app but not wait for the response. I have simulated this manually by going to the site from a browser, making the request and immediately closing the browser - it seems to keep the app alive.

Any suggestions for a good way to do this in a Python or Java web cron (I'm assuming a Python solution will be simpler)?

A: 

I think what you want is just:

import httplib
hcon = httplib.HTTPConnection("foo.appspot.com")
hcon.request("GET", "/someURL")
hcon.close()
Matthew Flaschen
httplib on App Engine is implemented in terms of the urlfetch API - this snippet won't do what you expect.
Nick Johnson
Nick, it was my understanding he was planning to run this ping code on a computer /outside/ App Engine.
Matthew Flaschen
A: 

the simplest Java http pinger:

URLConnection hcon = new URL("http://www.google.com").openConnection();
hcon.connect();
hcon.getInputStream().read();
dfa
+1  A: 

It would probably be easier use the cron built in to App Engine to keep your application alive.

Dave Webb