Target micro instance in Flexible AppEngine - google-app-engine

Is it possible to target a custom runtime to use a micro instance?
I tried with:
resources:
cpu: 0.5
memory_gb: 0.6
disk_size_gb: 10
But a small instance is started.

Add following to your app.yaml:
beta_settings:
machine_type: f1-micro

In App Engine, the instance type cannot be specified for the flex environment (unlike the standard environment in Python, Java and Go).
In the flex environment, the instance types are derived from the resource settings specified in your app.yaml file.
App Engine Resource Settings

It appears, that for some reason the pricing calculator lets you enter small values so the instance appears similar to a F1-micro (I was looking for around $5/month to run it) but then alas when it comes to specifying it in app.yaml it defaults to something that costs a whole lot more than an f1-micro, and you can't set the values to anything lower than what OP shows.
example very small flex instance in pricing calculator

Related

GCP App Engine: Migrate services from the flexible environment to the standard environment

There is documentation on migrating GCP App Engine services from standard to flexible, though none on going the other direction. It seems flexible is more stringent, and so less work is required going from flex to standard, but I'm not certain, as a simple change in the app.yaml is breaking the app.
Any insight out there on smoothly changing from GCP App Engine flex env to standard?
thank you-
The vast majority of the time, code written for Flex will work on Standard (unchanged). What you do need to do is make sure to make all the necessary changes in your app.yaml (it's not as simple as just removing env: flex).
One option to do this is pull up the Flex app.yaml reference side-by-side with the Standard app.yaml reference and make sure you:
Use valid settings for Standard (e.g. runtime: python39 instead of using the runtime_config field)
Remove any settings that are not applicable for Standard (e.g., Healthchecks)
In particular, pay attention to the Scaling settings, as they are similar, but have some easily-missed differences (e.g. min_num_instances for Flex, min_instances for Standard).
Also, if you are using Cloud SQL, there are some differences in how you configure the connection.

How to move Java 8 App Engine Flexible to App Engine Standard?

I have made a basic App Engine Flexible Rest API that uses Cloud endpoints for authentication and uses Spring for the MVC framework.
Does anyone have any recommendations on how to switch this over to App Engine Standard?
I thought to change the app.yaml file would work but I am a bit lost.
Thanks
Modifying your app.yaml is the primary method of changing from flexible to standard environment, or vice versa. Barring any other special configuration for your particular project, this could be all you need to do.
To deploy to standard environment, instead of flexible:
Try simply commenting out the env property in your app.yaml:
#env: flex
By default, you'd deploy to the standard environment if env is not defined (is what my experience has been).
Beyond this, you'd have to look at individual properties in your app.yaml, as perhaps some of them may only apply to a specific deployment type. For example, instance_class is not a property used in flexible environment, whereas you can define that in standard environment. In theory, I would remove or comment-out instance_class if deploying to flexible environment, or just maintain a second app.yaml (e.g. named app_standard.yaml).
On a side note, one thing I did stumble upon recently (for Go, anyways):
For a flexible deployment, this failed...
# This failed for flexible deployment, but it's what Google docs states to use (no period in the number)
runtime: go111
Meanwhile, I had to define the period for flexible deployment...
# This worked on a flexible deployment (had to include the period in the number)
runtime: go1.11
However, for the exact same app, with no code changes, simply going to standard environment, I defined runtime version WITHOUT A PERIOD, as Google's docs say to do, and it worked:
# This worked for standard environment (no period in the number)
runtime: go112
Just illustrating how fine details in the app.yaml matter.

App Engine Standard Nodejs8 ignore memory_gb in resources

I'm trying to deploy a Nodejs8, memory intense app on Google App Engine Standard.
This is my app.yaml:
runtime: nodejs8
resources:
cpu: 1
memory_gb: 6
disk_size_gb: 10
This is my deploy command:
gcloud app deploy --project=my-project --version=0-0-12
This is the error I get when I try to access the relevant endpoint of the app:
Exceeded soft memory limit of 128 MB with 182 MB after servicing 0 requests total. Consider setting a larger instance class in app.yaml.
How come the memory_gb param is ignored? What do I need to do in order to enlarge the memory of the instances?
You're attempting to use flexible environment Resource settings into a standard environment app.yaml file, which won't work. Note that in most cases the invalid settings will be silently ignored, so you need to be careful.
For the standard environment you can't explicitly pick individual resources, you can only use the instance_class option in Runtime and app elements:
instance_class
Optional. The instance class for this service.
The following values are available depending on your service's
scaling:
Automatic scaling
F1, F2, F4, F4_1G
Default: F1 is assigned if you do not specify an instance class along with the automatic_scaling element.
Basic and manual scaling
B1, B2, B4, B4_1G, B8
Default: B2 is assigned if you do not specify an instance class along with the basic_scaling element or the
manual_scaling element.
Note: If instance_class is set to F2 or higher, you can optimize your instances by setting max_concurrent_requests to a
value higher than 10, which is the default. To find the optimal value,
gradually increase it and monitor the performance of your application.
The max amount of memory available in the currently supported standard environment instance classes is 1G, if you actually need 6G you'll have to migrate to the flexible environment.
Side note: potentially useful: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

Is it possible to specify a machine type (e.g small/micro) when deploying to Managed VM?

I'm migrating some simple web apps (Node based static pages with some questionnaires and a very small amount of back end processing) to App Engine. I have them working well. Impressed with how easy it was!
However, I have a couple of questions that baffle me.
1) Why does GCE always deploy 2 machines? Is there a way of specifying to only run 1? I really don't need loads of redundancy, and our traffic is expected to be light.
2) I have tried to specify the machine type in app.yaml to be 'micro'. Call me cheap, but we really don't need much capacity. I have tried various perameters e.g.
resources:
cpu: .5
memory_gb: .2
disk_size_gb: 10
but it always seems to deploy 'small' machines. Is there a log somewhere that would tell me that the commmand was valid, but it chose to ingore it?
Thanks in advance.
Ah ha! Sorry, with a bit more googling around I found an answer to Q2
Setting f1-micro resource limits in app.yaml for google cloud compute node.js app without vm_settings
As Jeff and Greg both replied, "Google adds a little overhead on the
VM before picking a machine type. This is around 400mb of ram. So they
told me if you want an f1-micro try requesting .2 or lower as Greg
mentioned."
I had to drop to .18 to get it to deploy as f1-micro, but the general
idea that google is adding overhead is solid.
Dropping down the memory_gb to 0.18 did the trick.
Simply adding
resources:
cpu: .5
memory_gb: .18
disk_size_gb: 10
and deploying with the command
gcloud preview app deploy --stop-previous-version --force --promote
to make damn sure it was made #1 seemed to work - no loss in performance so far.
You can also specify machine type, not just required resources. By adding into app.yaml:
beta_settings:
machine_type: f1-micro
Also, if you want to always use 1 instance add this:
manual_scaling:
instances: 1

GAE automatic scaling

I have problem with automatic scaling at GAE.
One of my application module have instance class F4 and folowing automatic scaling settings.
<automatic-scaling>
<min-idle-instances>2</min-idle-instances>
<max-idle-instances>5</max-idle-instances>
<min-pending-latency>automatic</min-pending-latency>
<max-pending-latency>30ms</max-pending-latency>
<max-concurrent-requests>100</max-concurrent-requests>
</automatic-scaling>
I set maximum instances as 5 but when we run some jmeter tests with 300 users running instance number is increased to more than 40.
So it's looks that GAE don't handle this parameter correctly.
Does anybody have experience with this problem?
If you REALLY wanted to use the max instances cap, you have to use the app engine Application Settings UI at appengine.google.com. You can't set the max instances in app.yaml (yet).

Resources