App Engine( Road to GCP Associate Cloud Architect Certification 2020)

Emanuele Pecorari
5 min readMar 7, 2021

--

App Engine is one of the managed services offered by GCO: you can focus on the code of your application and let the service manages machines, scaling and availability. You don’t have to worry about provisioning the servers or how they will react to the changes of traffic and charge.

It’s a service well suited to expose easily APIs and create microservices.

Some of the important topics for the certification exam are:

  • the differences and use case between Standard and Flexible environments;
  • the concepts and the usage of versions and services;
  • the scaling options;
  • useful roles for App Engine management.

Standard and Flexible environments

There are 2 environments available for App Engine:

  • standard
  • flexible

Below a useful table to understand the difference between the 2 types:

Another useful use case for the Flexible environment is when you need App Engine application combined with Cloud VPN to allow access to it from premise application: in this case you can define the network configuration in the app.yaml.

Deployment

An App Engine application can be deployed specifying the parameters in a file app.yaml.

One important limit that need to be remembered can be only one App Engine application per service.

As usual, it’s possible using the --project flag from command line to specify a specific project otherwise the default one will be used. The project needs to exist anyway otherwise you get an error.

Versions and services

These 2 concepts are important and they need to be well understood.

A single AppEngine application can contains multiple services (at least one default service) and multiple versions of the same services.

For example, an app that handles your customer requests might include separate services each one handling a different task, such as:

  • API requests from mobile devices
  • Internal, administration-type requests
  • Backend processing such as billing pipelines and data analysis

Having multiple versions of your app within each service allows you to quickly switch between different versions of that app for rollbacks, testing, or other temporary events. You can route traffic to one or more specific versions of your app by migrating or splitting traffic.

You have a way to target a specific version of the service through the URL:

https://VERSION_ID-dot-SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com

  • Specifying a URL without a version ID will split the traffic across all the available versions.
  • A URL without service id identifies instead the default service

You can choose to deploy a new version of the app without sending traffic to it (that is without promoting to prod) using the flag — no-promote. So when there is a question asking how it is possible to test an application before putting to production, you can use the — no-promote response.

An important aspect to remember between the 2 environments of App Engine is that gradual traffic migration is not supported in the flexible environment while it is in the standard one.

If you immediately migrate traffic to a new version without any running instances then your app will have a spike in latency while instances are being created. You can avoid a spike in latency by using the App Engine Admin API to provision sufficient instances of the new app’s version before you migrate traffic to it.

Set minTotalInstances for the new version to the number needed to handle expected traffic. After migration is complete, you can reset this field so that autoscaling occurs if traffic drops.

Scaling options

App Engine supports 3 types of scaling:

  • Manual: it specifies the number of instance running at any moment. This allows tasks like complex initialization and applications that rely on the state of the memory over time
  • Basic: it creates instances based on requests. The instances are shutted-down when they become idle. Useful for intermittent work or driven by user activity.
  • Automatic: it scales based on request rate, response latency, and other metrics. It’s possible to setup threshold for those metrics and the minimum number of instances to keep running

Max instances and idle timeout are the two parameters you configure with basic scaling.

  • Max instances indicates the maximum number of instances that could be created
  • Idle timeout indicates that if an instance has been idle (for example it has not received a request) for more than idle-timeout , then the instance is shut down

Focus on roles

The following are some roles for which it can be useful remember the capabilities.

appengine.appAdmin

Read/Write/Modify access to all application configuration and settings.

To deploy new versions, you must also grant the Service Account User (roles/iam.serviceAccountUser) role.

appengine.serviceAdmin

Access to all the settings and configuration of the application

Write access to version level and module level settings

Can’t deploy a new version

appengine.deployer

Read-only access to all application configuration and settings.

To deploy new versions, you must also grant the Service Account User (roles/iam.serviceAccountUser) role.

Cannot modify existing versions other than deleting versions that are not receiving traffic.

Limits and quotas

Logs

AppEngine is natively connected to Stackdriver and send to it both requests log and application log

Focus on CLI commands

Some command useful for the certification:

Deployment

gcloud app deploy app.yaml index.yaml

Traffic splitting

gcloud app services set-traffic [MY_SERVICE] --splits [MY_VERSION1]=[VERSION1_WEIGHT],[MY_VERSION2]=[VERSION2_WEIGHT] --split-by [IP_OR_COOKIE]

If you need to split by cookie, take in to account that the cookie for traffic splitting is GOOGAPPUID

migrate parameter: this parameter is used in combination with — splits in order to gradually migrate the traffic.

gcloud app services set-traffic[MY_SERVICE] --splits [MY_VERSION]=1 --migrate

To migrate trafic immediately:

gcloud app services set-traffic[MY_SERVICE] --splits[MY_VERSION]=1

List of all versions getting traffic

The command to show all the App Engine versions receiving traffic

gcloud app versions list --hide-no-traffic

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Emanuele Pecorari
Emanuele Pecorari

Written by Emanuele Pecorari

Cloud Architect and Tech Product Owner. Soccer player and coach in the free time.

No responses yet

Write a response