Migrating an Existing App Engine App

Migrating an application written for the App Engine standard environment to the flexible environment is straightforward.

Configuration changes

The runtime and vm keys are required in your app.yaml file:

runtime: go
vm: true

Structural changes

Your app must use package main. The appengine.Main function should be called from the main function. By default, this starts a server on port 8080 using the standard net/http package.

package main

import "google.golang.org/appengine"

func main() {
	// ...

// ...

Deployment command

The deployment command is different. Use the aedeploy command:

go get google.golang.org/appengine/cmd/aedeploy
aedeploy gcloud app deploy

instead of

goapp deploy

App Engine APIs

To use the App Engine APIs, import the appengine package:

import "google.golang.org/appengine"

It supports the App Engine APIs, including:

If you are using the old appengine/... import paths, rather than the newer google.golang.org/appengine/..., follow the upgrade guide.

As you become more familiar with the flexible runtime, consider using the client libraries for portability and flexibility. The articles in the Developer Guides section explain many of these techniques.

Other differences

You must also take into account these differences when migrating an existing app:

  • The flexible runtime supports manual and automatic scaling. If your app uses basic scaling, you'll need to change that in your configuration file.
  • Apps in the flexible environment are not assigned instance classes. Instead, you specify resources in the app.yaml file.

Running in the flexible environment

The App Engine standard environment runs your application in instances rather than Virtual Machines. The standard environment imposes certain restrictions such as inability to write to disk.

In contrast, the flexible environment is based on running Docker containers in Google Compute Engine virtual machines. The flexible environment provides more CPU and memory options as well as full customizability of the runtime.

You can choose the App Engine environment (standard or flexible) separately for each service in your application. This means an application can contain a mix of services that use different environments. For example, you might use the standard environment for your client-facing frontend, and use a service running in a flexible environment for backend processing.

The following table summarizes the differences between the two App Engine hosting enviroments:

Feature App Engine standard environment App Engine flexible environment
Instance startup time Milliseconds Minutes
Maximum request timeout 60 seconds 60 minutes
Background threads Yes, with restrictions Yes
Background processes No Yes
SSH debugging No Yes
Scaling Manual, Basic, Automatic Manual, Automatic
Writing to local disk No Yes, ephemeral (disk initialized on each VM startup)
Customizable serving stack No Yes (built by customizing a Dockerfile)
Automatic in-place security patches Yes Yes
Network access Only via App Engine services (includes outbound sockets) Yes
Supports installing third party binaries No Yes
Location United States or European Union While in Beta, United States only.
Pricing Based on Instance hours While in Beta, based on Compute Engine Pricing for each VM. Pricing may change in the future.

Also, note that flexible environment differ from Compute Engine VMs in the following ways:

  • The VMs in the flexible environment are restarted on a weekly basis. During restarts Google’s management services will apply any necessary OS and security updates. (Weekly restarts are disabled if you switch a VM to debug mode.)
  • Users always have root access to Compute Engine VMs. SSH access to the VMs is disabled by default. If you choose, you can enable root access to the VMs; see Connecting to an Instance with SSH.
  • The VMs in the flexible environment are automatically located by geographical region according to the settings in your project. Google's management services will ensure that all the VMs for a project are co-located for optimal performance.

Send feedback about...

App Engine flexible environment for Go