Keeping your AppEngine projects loaded in memory

After creating a new google app-engine project you might notice a delay when accessing your site. What gives?! You thought this was Google right? Stuff deployed on the app-engine should be fast...?! Right...? Am I Right?!!

Well, yes and no. To keep this simple, Google does not keep every application loaded in memory. Whenever you site has not been accessed for 5 seconds, it will be dropped. Thus, when you first go to your website it will need to loaded back in order to handle your request. This causes a unfortunate and noticeable delay. It makes showing your site to friends and colleagues a pain if it's not being constantly hammered by thousands of users. People will just assume that you code inefficiently!

  • "Your website is SLOW!"
  • "I think your queries must suck or something?"
  • "Maybe you have too much JavaScript?"
  • "Have you thought of a CDN?"

To avoid silly questions like this, you can do something. 1) Market and make your website insanely popular or 2) HAMMER IT!

Here's a super simple python script that will ping your website forever, thus keeping it loaded by Google. You should be able to run this on a computer 24/7:

import time, httplib

urls = (

for u in urls:
c = httplib.HTTPConnection(u)
c.request("HEAD", "/")
res = c.getresponse()
print "touched %s, %s %s" % (u, res.status, res.reason)
print "could not touch %s" % u

To make this work for you, change the urls to your own domain. I suggest making HEAD requests to keep the bandwidth minimal.

  1. gravatar

    # by Alexander Fairley - August 14, 2009 at 4:38 AM

    Has google commented on this practice at all? It isn't prohibited in the terms of service to my recollection, but manipulating their cache doesn't really seem like the sort of thing they'd consider kosher.

  2. gravatar

    # by Donnie Demuth - August 17, 2009 at 9:32 PM

    Actually, they'd probably prefer the extra traffic. Once you pass a certain threshold you have to fork over the cash!