The doc of the standard environment mentions that max_concurrent_requests can be set. But this setting is not documented in the doc of the flex environment? I just deployed an app in the flex env with this option in the app.yaml and did not get an error. So can I assume it is also supported in the flex env?
And when doing websockets, with max_concurrent_requests=10, will having more than 10 simultaneous websocket connections result in an extra instance?
The short answer is unfortunately no, max_concurrent_requests in App Engine Flexible is not supported. In order for it to properly function, it has to be used along with target_throughput_utilization, however, you will get an error as soon as you specify it in the app.yaml of the application.
The way of controlling as to "when" the application will scale in App Engine Flexible is by specifying a target CPU utilization with cpu_utilization and target_utilization.
Google introduced target_concurrent_requests to App Engine Flexiable
https://cloud.google.com/appengine/docs/flexible/custom-runtimes/configuring-your-app-with-app-yaml#automatic_scaling
Related
I'm using Google App Engine flexible environment on PHP 7.2 application and we are using auto_scaling.
We occasionally get traffic spikes, but App engine will always keep 4 instances running.
What settings to add to app.yaml to force App Engine to always keep only one idle instance.
Thank you.
Since you are using App Engine Flex with auto scaling, you can't use the flag "max_idle_instances" in the app.yaml since this would give you an error; however, I would advice you to set a "max_num_instances" in order to prevent you from starting too many instances during one of your spikes.
I would also advice you to check out this video and this other one, as they explain very well how to set up your app.yaml to optimize your scaling.
Hope you find this helpful!
Is it possible to implement a custom health-check for instances in App Engine Standard? I tried to configure liveness-check and readiness-check, but these seem to be supported only in flex environment.
The reason I would like to do this is that recently we ran into following issue several times: because of a bug, one of the instances stopped responding successfully to requests, always returning HTTP status 500. This instance has been then kept alive and accessible for hours, leading to intermittent failures for our customers.
There is a very similar question (or even the same) in Google Groups, you can check it in this link.
I quote the response:
You cannot implement custom health checks in Google App Engine (GAE) Standard Environment. Our public documentation shows that adding legacy and updated health checks you are referring to is possible in Custom Runtime apps (i.e. GAE Flex apps) by configuring the app.yaml file [ 1]. This is an advantage of switching to GAE Flex.
For App Engine Standard, which doesn't afford you that flexibility, hardware and software failures that cause early termination or frequent restarts can occur without prior warning. This sometimes manifests as a non-responsive instance, returning HTTP status 500. We advised that you construct your GAE Standard apps to be able to handle this [2]. And you can reference this documentation for configuring your app.yaml file for your GAE app's app.yaml.
[ 1] https://cloud.google.com/appengine/docs/flexible/custom-runtimes/configuring-your-app-with-app-yaml
[2] https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#instance_uptime
[3] https://cloud.google.com/appengine/docs/standard/python/config/appref
I have a GAE flex application that uses sqlalchemy/mysql. I also have a Google CloadSQL mysql instance First Generation. Is it possible to connect a GAE flex environment to a First Generation CloudSQL instance without connecting as an external app (and thus needing to whitelist the world). The Google documentation states to use /cloudsql/<INSTANCE_CONNECTION_NAME> as the connection string. I've tried many different flavors, but I'm still unsuccessful.
Examples:
mysql+pymysql://user:password#/cloudsql/<INSTANCE_CONNECTION_NAME>
mysql+pymysql:///cloudsql/<INSTANCE_CONNECTION_NAME>
Is there a different driver that's needed?
Thanks
You are correct, it is not possible to connect GAE flex to CloudSQL 1st generation.
The alternatives are:
a. Use App Engine Standard App instead.
b. Migrate the First Generation instance to a Second Generation one
After searching the various Google documents, IRC channels and Slack forums, i've come to the conclusion that CloudSQL Gen 1 isn't support on GAE:flex :(
I am writing a web service (java servlet) in the flexible environment of Google App Engine and I would like to be able to retrieve the GCP project ID that I am running in at runtime programatically. How?
There is a SystemProperty which contains such thins as project id, app version, etc:
SystemProperty.applicationId.get()
Javadoc is here: https://cloud.google.com/appengine/docs/java/javadoc/com/google/appengine/api/utils/SystemProperty
SystemProperty is a part of com.google.appengine.api which is not available on App Engine Flex environment.
On Flex your project name is available as environment variable.
So you simply can use just this:
System.getenv("GCLOUD_PROJECT");
Please see Migrating Services from the Standard Environment to the Flexible Environment for more details.
Also please note that on local development server running Jetty this environment variable might not be set. If so the above code will return null on your development machine.
You might want to set it explicitly though for your local development server needs. For example if you use Bash you can do:
export GCLOUD_PROJECT=myproject
Also you can add it to your development server startup script or to your ~/.bashrc script, whatever works better for your needs.
When I open the admin panel of Google App Engine I see that I have running backend. I didn't intend to have one and I don't have backends.yaml file in my config.
I doubt it is because in the app.yaml I have this line manual_scaling in order to be able to make longer operatiotns:
manual_scaling:
instances: 1
Probably I should consider using modules. But first I want to clear this issue.
Manual scaling only works with "B"-type instances, which used to be known as "backend instances":
https://developers.google.com/appengine/docs/python/modules/#Python_Instance_scaling_and_class