DEV Community

Giuliano Ribeiro
Giuliano Ribeiro

Posted on • Updated on

App Engine and WebApp with Golang

Now is time to App Engine! My favorite GCP's service.


App Engine is the oldest service on GCP. It was born before GCP even exists. It's from 2007 and started as an internal Platform created to provide an easy and scalable way to Googlers deploy and serve their projects.

App Engine is a Platform as a Service product where you can deploy your app written in some runtimes, like:

  • Python
  • Java
  • PHP
  • Golang
  • Ruby
  • Node

Before you hear about containers, App Engine already has been using this concept since 2007! It's also true about serverless concept, as you don't need to take care of the underlining infrastructure. You only need to care about your code and the App Engine descriptor file (where you include the information about your necessities).


App Engine offers to you 2 "flavors", the Standard Environment, and the Flexible environment.

Standard environment

The Standard env is a cloud-native option, you don't need to care about the infra and they have a really fast spin-up engine to create the instances for your traffic in manner of milliseconds.
But in some old runtimes (Python 2.7, Java 8) you may have some issues with some frameworks as the behavior is not the same as you are used. But it's going away (finally!) with the new runtimes (Java 11, Python 3.7 and Go 1.12+), as they are Gvisor-based and the behavior is the same as you are used to.
On Standard env, you pay only for the usage, and its scales to zero. Which means, when there's no traffic, your app "sleep" and you don't pay :) When the traffic come, App Engine spinup your app as fast as possible. In Golang, for example, it takes no more then 1s to "wake up".

Flexible environment

Although the Flexible env is a bit different because is a container-based environment, and relays on Compute Engine VMs. You can use any kind of runtime to run, the important point is: your app should respond in the 8080 port. So Google doesn't care about your runtime but takes care of scalability based on container usage(Memory and CPU).
As this flavor is based on Compute Engine, you should take care about the sizing of theses VMs.

More about App Engine, take a look at the official page: Google Cloud App Engine

IMHO, the Standard is the best option! You have so many great services and features than the Flex. And, of course, the scalability in an easy way (if you need it).

Free tier

A nice "feature" we have on App Engine is the free tier (only for Standard Env). It means you can run your app paying nothing! :)

It is not a special thing on App Engine, you can use some other services on GCP for free too, check this out: GCP Free tier

For App Engine you can use those resources:
App Engine free tier features

Web App

Deploying your app on App Engine you get a URL with https for FREE. This URL is based on App Engine domain, so you are going to have something like this:

For this post, I choose the Golang runtime, even I'm a Java dev for a long time, in my last years I've been working with Golang instead.

Simple Go App
As you can see I'm using the web framework Gin-Gonic.

The unique difference between an ordinary Go web app and this one for App Engine is the file app.yaml. This is the App Engine descriptor, where you need to inform you runtime, and some other options:
Alt Text
Check this page out, for more available options: appm.yaml Configurations

After doing what you want, you only need to deploy your app using the Google Cloud SDK

gcloud app deploy .

Enter fullscreen mode Exit fullscreen mode

Deploy the app

It's done, your app is deployed and you can access by the URL provided in the end of the process.

You can have all this Golang code on my Github:

GitHub logo giulianobr / simple-go-app

A simple Go app to serve a static site


A simple Go app to serve a static site

Run the app

go run main.go

To deploy

Install and setup your Google Cloud SDK.


gcloud app deploy .


I hope this post helps you understand, at least, a bit of App Engine and how to use these wonderful services provided by GCP.
As a Platform as a Service, you have the power to focus on your code/app and leave the issues of infrastructure management to Google's team. A really good way to do MVPs, PoCs and to test an idea without the need to create an infrastructure for that.

As usual, please, give feedbacks! :)

Top comments (0)