Let us know about App Engine


Hi, today I will be talking about App engine and the commands used to access AppEngine.

What is App Engine?

App Engine is one of the most important services in GCP. It was first released by GCP in 2008. App Engine is a serverless Platform As A Service. It is the simplest way to deploy your applications in GCP.

It provides end-to-end application management. It supports Go, Java, .NET, Node.js, PHP, Python, Ruby using pre-configured runtimes. You can also use custom runtime and write code in any language. It also connects to variety of GCP storage products(Cloud SQL etc). There are no usage charges and you are only supposed to pay for the resources provisioned.


1. Automatic load balancing and Auto scaling

2. Managed platform updates and Application health monitoring

3. Application versioning

4. Traffic splitting

There are two types of environments that App Engine provides:

1. Standard:

1. Applications run in language specific sandboxes.

2. V1- Java, Python, Go (Old Versions). For Python and PHP runtimes, only white-listed extensions and libraries are allowed.

3. V2- Java, Python, PHP, Node.js, Ruby, Go (Newer versions)

4. Priced based on instance hours.

5. Manual, basic and automatic scaling possible.

6. Can scale down to zero.

2. Flexible:

1. Application instances run within Docker containers.

2. Makes use of compute engine virtual machines.

3. Support ANY runtime(with built-in support for Python, Java, Node.js, Go, Ruby, PHP, .NET).

4. Provides access to background processes and local disks.

5. Priced based on configuration(vCPU used, memory, persistent disks).

6. Manual and automatic scaling possible.

7. Minimum of 1 instance will run all time.

Few commands used in App Engine:

Open you editor in App Engine:

You can open Cloud Shell Editor and open your project folder in the cloud shell.

cd folder-name

1. Moving on to commands, if you want to list out the projects configured then you can type:

gcloud config list

2. Let's start with configuring the project by entering your project name in the command,

gcloud config set project project-name

3. Now let's deploy the app:

gcloud app deploy

After running this command, you can see the source of the project in the 'descriptor'. It also shows the target project and target service. An application contains multiple services, one of those services is called as default service. Since we did not specify any service name, that's why it made use of default service.

Your application has been deployed successfully.

Now, if you will go and check your App Engine dashboard, you can see some data that has come up. You can see your billing status, cost and current load on that specific application. You can also see if there are any application error, server error or client error.

4. To list out the services and versions, type following command respectively in your terminal,

gcloud app services list

gcloud app versions list

5. You can even list out the instances which have been configured by typing,

gcloud app instances list

6. If you want to deploy a different version of your application, you can type:

gcloud app deploy --version v2

So as soon as your application is deployed, the traffic will switch to version v2. You can confirm this by clicking on the target URL provided.

7. If you want the link of the active version, you can type:

gcloud app browse

8. If you want the link of the specific version, you can type:

gcloud app browse --version versionID

This is how you can retrieve the link of your old version. This means your old version is still running, but it is not serving any traffic.

9. If you want to create a new version but does not want to shift full traffic to that version then you can type the following command.

gcloud app deploy --no-promote

gcloud app browse --version v3

'no-promote' signifies that this version is not live. If you want to make this version live and transfer all the traffic, then you can type this command by writing '--promote' instead.

10. You can even split the traffic between your versions according to your need and test the new version. This way you can test your new version and then shift full traffic whenever the time is right.

gcloud app services set-traffic --splits=v3=0.5,v2=0.5

By default, it say 'splitting service by IP' which means, depending on the IP from where request is coming, it will split the traffic. You can even change the percentage of traffic according to your needs.

11. To see the response in terminal, you can type:

watch curl target-URL

'Watch' will send the get request to the URL every 2 seconds.

12. You can even split the traffic randomly by typing,

gcloud app services set-traffic --splits=v3=0.5,v2=0.5 --split-by=random

You can even perform the above steps through the console, by going to versions and clicking on 'split the traffic' on the top toolbar,

13. You can even get the link for the console to manage a particular service. By clicking on the URL, it will redirect you to the console of that particular service.

gcloud app open-console --version v2

14. You can also list out the regions where app engine is supported,

gcloud app regions list

15. If you want to list only the active versions that are configured to receive traffic, then you can type:

gcloud app versions list --hide-no-traffic

Few important things to remember:

1. App Engine is Regional(services are deployed across zones). We cannot change application's region.

2. Good option for simple micro-services.

3. At least one container is always running when using 'Flexible'. Use 'Standard' if you want to scale down the number of instances to zero when there is no load.

4. Use a combination of resident and dynamic instances. Resident instances- Run continuously Dynamic instances- Added based on load

5. Use dynamic instances if you are cost sensitive or else use resident instances.

You can now go ahead and start experimenting with App Engine but be careful about the billing ;)

I hope you enjoyed reading this blog.

Happy Learning :)