Run containerize app in Google Cloud App Engine

Reading Time: 5 minutes

In this tutorial you will learn to deploy and run containerize application in google cloud app engine flexible environment.

Prerequisites

This would be Handon’s demo to containerize an application and run in Google app engine and you can follow along.

Google cloud free credits are required to learn and explore GCP. If you are new to Google cloud platform and interested to earn free credits worth 400 $ refer here, Google Cloud Free Credits – Google Cloud Tutorials .

Free credits offer free access to 20 + Google cloud services to be spend over 90 days after successful sign up.

What is Google Cloud App Engine?

Google App Engine is fully managed and server less service offered by Google cloud platform to run your application in cloud. This allows developers to focus on code and let google cloud manages hosting infrastructure and scaling.

Supports

  • GO,Java,.NET Node JS, Python, and Ruby using app engine standard environment.
  • Use flexible environment (Containers) and write code in any language of your choice.
  • seamless connectivity with other cloud services (Cloud SQL, Cloud monitoring etc.)

No Usage Charges

App Engine is PAAS (platform as a service) offering, and you don’t have to pay anything upfront for the infrastructure cost. There is no initial payment required for server or memory.

App engine uses Pay for use (Automatically scales depending on app traffic) model.

App Engine Features

  • Automatic load balancing and Auto scaling
  • Managed platform updates and application health monitoring
  • Application versioning
  • Traffic Splitting

Compute Engine VS App Engine

Compute EngineApp Engine
IAASPAAS
More Responsibility to choose hardware, memory and Image Lesser Responsibility, Developers focus only on code. Infrastructure managed by Google
Fine grain access controlsNo fine grain access
Compute Engine VS Google App Engine

App Engine Environments

Standard Environment Flexible Environment
Source code is written in specific versions of the supported programming languages:Source code that is written in a version of any of the supported programming languages:
Python 2.7, Python 3.7, Python 3.8, Python 3.9, Python 3.10, and Python 3.11, PHP 7.2, PHP 7.3, PHP 7.4, PHP 8.1, and PHP 8.2PythonJavaNode.jsGoRubyPHP, or .NET
Java 8, Java 11, and Java 17, Node.js 10, Node.js 12, Node.js 16, Node.js 18, and Node.js 20 (preview)
Ruby 2.5, Ruby 2.6, Ruby 2.7, Ruby 3.0, and Ruby 3.2
Intended to run for free or at very low cost, where you pay only for what you need and when you need it. For example, your application can scale to 0 instances when there is no traffic.Runs in a Docker container that includes a custom runtime or source code written in other programming languages. Uses or depends on frameworks that include native code.
Experiences sudden and extreme spikes of traffic which require immediate scaling.Accesses the resources or services of your Google Cloud project that reside in the Compute Engine network.
Instance startup time in SecondsInstance startup time in Minutes
Background threads: Yes, with restrictionsBackground threads: Yes
SSH debugging: NoSSH debugging: Yes
Scaling:Manual, Basic, AutomaticManual, Automatic
Scale to zero:YesScale to zero:No
Google Cloud App Engine Standard vs Flexible Environments

App Engine Scaling

Automatic – Scale based on Instance load

  • Continuously running workloads

Auto Scale based on

  • CPU Utilization
  • Throughput utilization
  • Concurrent Users

Basic – Instances are created when requests are received

  • Instances are shut down to Zero When there is no traffic
  • Not supported by APP Engine flexible

Manual – configure the number of Instances

Adjust number of instances manually over a period of time.

Application Component Hierarchy

Google Cloud App Engine Component Hierarchy

When an app engine application resource is created it is created under your current google cloud project Each google cloud project can have only one App engine application.

The app engine application is the top-level container.

Each app engine application can have multiple services under it. Each App Engine application includes at least one service, the default service.

App engine services are smaller components of your micro service-based applications. These services can communicate with each other and scale independently.

You can run your whole application as one services(monolith) are choose multiple services based on micro services architecture.

Each service can have multiple versions running in parallel.

This feature is helpful in rollbacks and testing. During the go live or new release of microservice It also allows for application splitting among multiple versions.

The versions within your services run on one or more instances.

Run .NET 6 Microservices in Google App Engine Flexible

Google App engine supports .NET workloads using Flexible Environment. In this article we will first create custom image using Docker and push it to google container Registry.

If you are new to application containerization refer our article here Containerizing An Application In 3 Easy Steps – Google Cloud Tutorials .

In order to run your local custom application image as containers it must be added to Google image registry.

Google cloud platform offers two services to store and work with custom images.

learn more about pushing and pulling custom images from Google container registry here Store Container Images In Google Cloud Artifact Registry – Google Cloud Tutorials

Learn more about pushing and pulling custom images from Google artifact registry here Push Docker Image To Google Container Registry – Google Cloud Tutorials

1.Configure app.yaml file for .NET Project.

env: flex

2. Enable App Engine API and App Engine Admin API

 Note:App engine account must have read access to Google container Registry. Cloud accounts and access can be managed using IAM module.

3.Deploy your image to App Engine by running the following command:

gcloud app deploy --image-url=LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG

LOCATION is the regional or multi-regional location of the repository.

Project-ID is GCP projectid

REPOSITORY is the name of the repository where the image is stored.

IMAGE is the name of the image in the repository.

TAG is the tag of the image version that you want to pull.

gcloud app deploy --image-url=us-east1-docker.pkg.dev/artifactregistry-387909/artifactdemo/artifact-demo:V1

Select for app service deployment.

App Service

Navigate to the Google App engine, and you will see a new default service created,

Get Application URL 

gcloud app browse

Once Application deployment is complete in app engine dashboard we can see new service.

Application is running as container in Google App Engine

Auto scaling, health monitoring can be configured using app.yaml file.

runtime: custom
api_version: '1.0'
env: flexible
threadsafe: true
automatic_scaling:
  cool_down_period: 120s
  min_num_instances: 2
  max_num_instances: 20
  cpu_utilization:
    target_utilization: 0.5
liveness_check:
  initial_delay_sec: '300'
  check_interval_sec: '30'
  timeout_sec: '4'
  failure_threshold: 4
  success_threshold: 2
readiness_check:
  check_interval_sec: '5'
  timeout_sec: '4'
  failure_threshold: 2
  success_threshold: 2
  app_start_timeout_sec: '300'
service_account: [email protected]

FAQ

What is App Engine ?

Service less compute offering by google cloud platform run your applications in cloud.

What are some alternatives to GAE if we want to host our applications?

1.Use Google cloud compute engine services (IAAS) cloud virtual machines.
2.If application is very complex and has multiple services and requires high scalability use GKE. Learn more on GKE here Deploy Microservices On Google Kubernetes Engine (GKE) In 8 Easy Steps – Google Cloud Tutorials

What is cost of running applications in App engine?

Check Google App engine pricing here Google Cloud Pricing Calculator .

Scroll to Top