Idle instances not working

92 views
Skip to first unread message

Pete

unread,
Jul 11, 2014, 3:11:50 PM7/11/14
to google-a...@googlegroups.com
Hello!  I have a python app running on Google App Engine. Since it isn't regulary trafficked, every time a new user visits the site 15 minutes after the last instance was started up (or however long they stay active since the last request), it takes a long time (4-5 seconds) for a new instance to start up and serve the site. Subsequent page requests while the instance is active is around 30ms.

From what I understand, setting a minimum number of idle instances can alleviate this startup time. So I set the minimum idle instances to 1 in the App Engine dashboard, as well as added

inboud_services:
- warmup 

to my app.yaml file.   However, there is still a 4-5 second startup time when a new visitor accesses the site.

When I checked the "Instances" page on the App Engine dashboard, it showed the resident instance as well as a dynamic instance, but all the requests were going through the dynamic instance.  Once I shutdown the dynamic instance, all new requests went through the resident instance, as I expected.  BUT, when someone accessed the site after 15 minutes of inactivity (the time it takes for a dynamic instance to shutdown and need to be restarted), the next request went through a new dynamic instance which was spun up, again taking 4-5 seconds, instead of using the resident instance which was already running.

I tend to think that this isn't what's supposed to happen.  Is there something that I'm doing incorrectly?  I really appreciate the help.  Thanks!

Vinny P

unread,
Jul 13, 2014, 3:35:21 AM7/13/14
to google-a...@googlegroups.com
On Fri, Jul 11, 2014 at 2:11 PM, Pete <petestr...@gmail.com> wrote:
When I checked the "Instances" page on the App Engine dashboard, it showed the resident instance as well as a dynamic instance, but all the requests were going through the dynamic instance.  Once I shutdown the dynamic instance, all new requests went through the resident instance, as I expected.  BUT, when someone accessed the site after 15 minutes of inactivity (the time it takes for a dynamic instance to shutdown and need to be restarted), the next request went through a new dynamic instance which was spun up, again taking 4-5 seconds, instead of using the resident instance which was already running.
I tend to think that this isn't what's supposed to happen.  Is there something that I'm doing incorrectly?  I really appreciate the help. 



No, you're seeing the correct behavior. Dynamic instances are intended to carry the majority of the traffic load, while resident instances are intended to carry spike traffic (handle requests while dynamic instances spool up). Of course, occasionally you'll see a request wait for a dynamic instance to open (it's called a loading request, and you'll see an entry in your logs when that happens) even when a resident instance is doing nothing - that happens when the scheduler believes there's enough traffic to warrant opening a dynamic.

The major problem here, IMO, is that your traffic level is too low and isn't giving the scheduler enough data to properly allocate instances. What I would do is configure a cron job to periodically hit your application and execute some fake load/activity. For instance, configure a cron to execute a script every 5 minutes and have the script sleep for 15 seconds and print out some text into logging. If your app needs a periodic cleanup task handled, you can insert that into this script as well. 

 
 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Pete

unread,
Jul 16, 2014, 11:54:39 PM7/16/14
to google-a...@googlegroups.com
Hi Vinny,

Brilliant!  That is now behaving exactly as I hoped.  Thank you!

Vinny P

unread,
Jul 18, 2014, 1:11:28 AM7/18/14
to google-a...@googlegroups.com
On Wed, Jul 16, 2014 at 10:54 PM, Pete <petestr...@gmail.com> wrote:
Hi Vinny,
Brilliant!  That is now behaving exactly as I hoped.  Thank you!


Great to hear! Remember to remove the fake load script once your site gets a consistent amount of traffic, you won't need it then.
Reply all
Reply to author
Forward
0 new messages