How can I prevent a free App Engine instance from idle?

1,836 views
Skip to first unread message

Aldo Suarez

unread,
Jan 22, 2016, 3:17:29 AM1/22/16
to Google App Engine

I've read several posts about this (ex., How are frontend instance hours calculated on app engine?) and I'm still wondering about it.

I haven't got too much traffic, so my instance gets spin down and up, consuming 15 minutes of front-end hours on each start up.

I'm grateful with Google Cloud services, however I'd like to take full advantage of my App Engine free quota. Should I ping my instance every 5 minutes? should I change my app.yaml settings? should I make a cronjob?

Nicholas (Google Cloud Support)

unread,
Jan 22, 2016, 1:10:49 PM1/22/16
to Google App Engine
I would suggest you use manual scaling to accomplish your goal of a (mostly) indefinitely running instance. This article about 'Instance uptime' states the following:
App Engine attempts to keep manual and basic scaling instances running indefinitely.

The 'Scaling and instance types' article reveals how to configure your App Engine application to use manual scaling. If you have a single instance running indefinitely, it should only consume ~24 instance hours thereby running all day each day barring required shut downs and start ups.

Aldo Suarez

unread,
Jan 22, 2016, 3:59:37 PM1/22/16
to Google App Engine
Manual scaling provides 8 frontend hours per day, not 28.
I also read that the instance shuts down after 15 minutes of inactivity, is it true/false?

Alex Martelli

unread,
Jan 24, 2016, 7:08:21 PM1/24/16
to google-a...@googlegroups.com
On Fri, Jan 22, 2016 at 12:59 PM, Aldo Suarez <elmonot...@gmail.com> wrote:
Manual scaling provides 8 frontend hours per day, not 28.

Yep, that's the total for manual plus basic scaling (in addition to the autoscaling 28 instance hours -- there is no such thing as "frontend hours").
 
I also read that the instance shuts down after 15 minutes of inactivity, is it true/false?

Absolutely not for manual and basic scaling modules: *those* instances, idle or not, only go away when explicitly requested to (with the Modules API, e.g https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.modules.modules , possibly mediated via the appcfg command-line tool).

For autoscaling modules, idle instances normally go away (a little bit earlier than after 15 minutes of idle time, in general; you're charged for 15 minutes as an approximation of the costs of provisioning and recycling instances); but you can control that -- in particular, you can force one idle instance to remain at all times by setting the min_idle_instances value to 1. Of course that one idle instance will then idly consume 24 hours per day (if it's the smallest instance class), leaving only 4 hours per day for NON-idle instance time within the free quota.


Alex



El viernes, 22 de enero de 2016, 15:10:49 (UTC-3), Nicholas (Google Cloud Support) escribió:
I would suggest you use manual scaling to accomplish your goal of a (mostly) indefinitely running instance. This article about 'Instance uptime' states the following:
App Engine attempts to keep manual and basic scaling instances running indefinitely.

The 'Scaling and instance types' article reveals how to configure your App Engine application to use manual scaling. If you have a single instance running indefinitely, it should only consume ~24 instance hours thereby running all day each day barring required shut downs and start ups.

On Friday, January 22, 2016 at 3:17:29 AM UTC-5, Aldo Suarez wrote:

I've read several posts about this (ex., How are frontend instance hours calculated on app engine?) and I'm still wondering about it.

I haven't got too much traffic, so my instance gets spin down and up, consuming 15 minutes of front-end hours on each start up.

I'm grateful with Google Cloud services, however I'd like to take full advantage of my App Engine free quota. Should I ping my instance every 5 minutes? should I change my app.yaml settings? should I make a cronjob?


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/57165362-024e-45c4-a902-1dfa14e655c6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Aldo Suarez

unread,
Jan 25, 2016, 3:11:46 PM1/25/16
to Google App Engine
So, I can set min_idle_instances in app.yaml instead of ping the instance every 5 mins. Is it right?

I actually made a test. I hit my instance every second. My daily quota ends in 8 hours, and I've consumed 16,29 of 28 instance hours in 47.165 requests. It's worth to say that I'm only returning a "hello world" message, nothing heavy. 


Alex Martelli

unread,
Jan 25, 2016, 3:53:29 PM1/25/16
to google-a...@googlegroups.com
On Mon, Jan 25, 2016 at 12:11 PM, Aldo Suarez <elmonot...@gmail.com> wrote:
So, I can set min_idle_instances in app.yaml instead of ping the instance every 5 mins. Is it right?

Yes, but a new to-be-idle instance will get started each time the previously idle one becomes non-idle, to drive you back to your desired min idle instances (1) from 0. So it's unlikely to achieve your purpose.
 

I actually made a test. I hit my instance every second. My daily quota ends in 8 hours, and I've consumed 16,29 of 28 instance hours in 47.165 requests. It's worth to say that I'm only returning a "hello world" message, nothing heavy. 

Can you show the relevant sections of your app.yaml and cron.yaml?  47k requests, 1 per second, maps to 13 hours -- which matches neither the 8 nor the 16.29 hours you report.

Alex

Aldo Suarez

unread,
Jan 25, 2016, 6:41:36 PM1/25/16
to Google App Engine
Ok, it was approx. 1 second.

I made an script to hit the instance within a random of 1 second.

My app.yaml contains the default settings.

application: ip-engine
version: 1
runtime: python27
api_version: 1
threadsafe: yes

# Handlers define how to route requests to your application.
handlers:
- url: .*  # This regex directs all routes to main.app
  script: main.app


My question is: if my test show that it handles far more than 47k request (at ~1 per second), should I ping my instance to work like that? 
Instead of letting it spin down, where I have the risk of reaching the quota with only ~186 requests 15 minutes between each (considering those limits)

Aldo Suarez

unread,
Jan 25, 2016, 6:44:03 PM1/25/16
to Google App Engine
Errata:

not ~186, but ~112 requests.

(28 hours) / (15 minutes)
Reply all
Reply to author
Forward
0 new messages