I have a deployed a Golang app to Google Cloud Platform's App Engine Standard environment.
My app.yaml included the following lines:
automatic_scaling:
min_idle_instances: 0
max_idle_instances: 0
min_pending_latency: automatic
max_pending_latency: automatic
min_instances: 0
max_instances: 2
My intention was that the app should scale down to 0 instances when idle and spawn up to 2 instances to handle incoming requests.
After calling the service I noticed that it never scales down to 0 instances.
I opened the service configuration in the web console and found the following:
runtime: go
api_version: go1
env: standard
threadsafe: true
instance_class: F1
handlers:
- url: /penguin
script: _go_app
automatic_scaling:
min_idle_instances: automatic
max_idle_instances: automatic
min_pending_latency: automatic
max_pending_latency: automatic
max_instances: 2
Is it possible to scale App Engine Standard services down to 0 instances? What should that look like in the yaml?
App Engine standard environment scales down to 0 instance by default so you shouldn't have to specify it in your app.yaml. You only need to specify the values you want to change in the automatic scaling. Refer to the documentation for a list of default scaling values under automatic_scaling.
After deploying, you should only have at most 1 instances showing up, but you will be billed for usage which is 0.
(Also note that this does not apply to a App Engine Flexible environment)
Related
I have created an Node application running on Google App engine. It is successfully working but I cannot see how many instances are running it is showing 0 instances are up but the webpage is served successfully. I tried to increase the load so that via apache2 benchmark but still it is showing '0 instances are up'. I am using this via my GCP trial account
here is my yaml file contents.
runtime: nodejs14
instance_class: F2
env_variables:
BUCKET_NAME: "your-ng-app-bucket"
handlers:
- url: /
static_files: dist/sample/index.html
upload: dist/sample/index.html
- url: /
static_dir: dist/sample
automatic_scaling:
min_instances: 0
max_instances: 3
target_cpu_utilization: 0.6
screenshot of autoscaling in appengine
I wanted to know why i am unable to view the instances i just wanted to know how many instances are running during normal usage. It is always 0
I have been exploring the App Engine settings for a small data science web application for 2 weeks. Since it is a personal project that bills my own wallet, I tried a few different parameters in app.yaml to reduce the "frontend instances" cost. Several changes in, I got unexpected ~10x cost surge!!! It was painful!!! In order to not waste it, I decided to learn something here to understand the behaviour :)... Don't worry, I had temporarily shut down my app ;)
Version 1 app.yaml:
service: my-app
runtime: python37
instance_class: F4
env: standard
automatic_scaling:
min_idle_instances: 1
max_idle_instances: 1
default_expiration: "1m"
inbound_services:
- warmup
entrypoint: gunicorn -b 0.0.0.0:8080 main:server
Version 1, billing result (usage.amount_in_pricing_units exported from billing account): ~100hr/day, the same as Front end Instance Hours shown from App Engine billing status.
This is understandable, because I had a F4 instance constantly runing idle that would translate into 24*4=96 frontend instance hours. Adding the instance usage from actual requests (from me only), ~100hr/day seems reasonable.
Version 2, where I intended to lower the instance class and number of instances and also made longer the default_expiration and hoping it would help the app to start quicker and some other stuff that I thought wouldn't affect much....
service: my-app
runtime: python37
instance_class: F2
env: standard
automatic_scaling:
min_instances: 1
max_instances: 1
target_cpu_utilization: 0.85
max_concurrent_requests: 80
max_pending_latency: 6s
default_expiration: "3h"
inbound_services:
- warmup
entrypoint: gunicorn -b 0.0.0.0:8080 main:server
Version 2, billing result (usage.amount_in_pricing_units exported from billing account): ~800hr+/day, ouch!!! In contrast, the Front end Instance Hours from App Engine dashboard billing status is less than 60hr/day as expected. This is where I got lost:
Why the usage from billing is so much larger than the App Engine Dashboard where do those usage come from?
Where to find and track indicators of those unaccounted usage in App Engine Dashboard etc?
2020-01-16 Solution for issue #1.
While I was waiting for Google Billing Support to come back to me, I found this:
Pricing of Google App Engine Flexible env, a $500 lesson
Namely, the past deployed versions of the app also eating frontend instance hours, which needed real world confirmation. (To my surprise, this has nothing to do with app.yaml file!!) So I deleted all the past versions of the app and let it run for two days while observing instance hours and billing records with the following app.yaml file.
service: my-app
runtime: python37
instance_class: F2
env: standard
automatic_scaling:
min_instances: 1
max_instances: 2
max_idle_instances: 1
target_cpu_utilization: 0.85
max_concurrent_requests: 80
max_pending_latency: 6s
default_expiration: "1m"
inbound_services:
- warmup
entrypoint: gunicorn -b 0.0.0.0:8080 main:server
This should have always one F2 instance running and goes up to maximum 2 instances. This time both app engine and exported billing usage hours agreed on 50 hours frontend instance hours. Yes!!! The daily cost is cut down to 1/16.
This solves the cost question #1, but #2 remains to be answered. It is very problematic that app engine dashboard is not showing all the billed usage of frontend instances. Yesterday I heard from Google Billing Support Team, the answer is not helpful (mainly talking about instance numbers in app.yaml, which doesn't help), they seem oblivious about this issue, I will have to let them know.
2020-01-31 Followup on issue #2.
Google Billing Support Team responded swiftly, acknowledged the discrepency between App Engine Dashboard vs Billing Export and agreed to ajust the billing for me. Effectively, the bills during the spiky days were refunded as a result. Kudos to them!
I'm using GAE standard with nodejs10.
I redeployed a new version of the app approx 9 hours ago with this conf (as shown in the UI under App Engine > Versions):
runtime: nodejs10
env: standard
instance_class: F1
handlers:
- url: '.*'
script: auto
- url: '.*'
script: auto
automatic_scaling:
min_idle_instances: automatic
max_idle_instances: automatic
min_pending_latency: automatic
max_pending_latency: automatic
min_instances: 1
max_instances: 3
And yet I noticed that the instances count dropped to 0:
Any idea why GAE doesn't keep 1 instance running?
GAE standard is autoscaled to zero instance by default. Whenever a url is matched by handlers according to the conf, an instance will be initiated and will continue to be live until there is no more url request for a period of time, so it will automatically rescale to zero if there is no more traffic for a period. Here is the instance state for my test:
automatic_scaling:
min_instances: 2
And here is the traffic:
We are deploying ASP.NET Core application on Appengine Flex and in Instances Summary on Dashboard page appears strange 1.9.54 appengine release as well as Flex release. What that might be?
Our app.yaml:
env: flex
runtime: aspnetcore
resources:
cpu: 8
memory_gb: 14.4
automatic_scaling:
min_num_instances: 8
max_num_instances: 20
cool_down_period_sec: 180
cpu_utilization:
target_utilization: 0.5
Your app's dashboard summary indicates your app has both:
standard env GAE instances (1.9.54 being the version of the GAE sandbox/infra running those instances), possibly from older service version(s) not yet deleted
flexible env GAE instances
You can play with the Service and/or Version selection boxes above the summary to identify which service/version those instances correspond to.
When trying to deploy my app engine using flexible environment then i am getting error.
ERROR: (gcloud.preview.app.deploy) INVALID_ARGUMENT:
The beta setting machine_type cannot be set in an App Engine Flexible Environment deployment.
My app.yaml is given below
runtime: nodejs
#vm: true
env: flex
# [END runtime]
network:
instance_tag: app-tag
name: network-tag
instance_class: F1
automatic_scaling:
min_num_instances: 1
max_num_instances: 2
cool_down_period_sec: 60
beta_settings:
machine_type: f1-micro
handlers:
- url: /.*
script: IGNORED
secure: always
# Temporary setting to keep gcloud from uploading node_modules
skip_files:
- ^node_modules$
Also can anyone please tell me what is the difference between vm: true and env: flex because both set app engine environment to flexible ??
When changing from vm: true to env: flex you're actually switching to the latest infra version, see Upgrading to the Latest App Engine Flexible Environment Beta Release.
The machine type is no longer configured that way. Instead you'd configure a custom instance shape via its resources:
Resource settings
These settings control the computing resources. App Engine assigns a
machine type based on the amount of CPU and memory you've
specified. The machine is guaranteed to have at least the level of
resources you've specified, it might have more.
You can specify up to eight volumes of tmpfs in the resource settings.
You can then enable workloads that require shared memory via tmpfs and
can improve file system I/O.
For example:
resources:
cpu: 2
memory_gb: 1.3
disk_size_gb: 10
volumes:
- name: ramdisk1
volume_type: tmpfs
size_gb: 0.5