You can run your applications in App Engine using the flexible environment or standard environment. You can also choose to simultaneously use both environments for your application and allow your services to take advantage of each environment's individual benefits.
Choosing your App Engine environment
Structuring your applications by using a microservice architecture aligns best with App Engine, especially if you decide to utilize both environments. There are several factors to consider when determining which environment is better suited to your application and its services. Use the following sections to learn and understand which environment best meets your application's needs.
When to choose the flexible environment
Using the App Engine flexible environment means that your application instances run within Docker containers on Google Compute Engine virtual machines (VMs).
Generally, good candidates for the flexible environment are applications that receive consistent traffic, experience regular traffic fluctuations, or meet the parameters for scaling up and down gradually.
The flexible environment is optimal for applications with the following characteristics:
Source code that is written in a version of any of the supported
Python, Java, Node.js, Go, Ruby, PHP, or .NET
- Runs in a Docker container that includes a custom runtime or source code written in other programming languages.
- Depends on other software, including operating system packages such as imagemagick, ffmpeg, libgit2, or others through apt-get.
- Uses or depends on frameworks that include native code.
- Accesses the resources or services of your Cloud Platform project that reside in the Compute Engine network.
When to choose the standard environment
Using the App Engine standard environment means that your application instances run in a sandbox, using the runtime environment of a supported language listed below.
Generally, building an application to run in the standard environment is more constrained and involved, but your applications will have faster scale up times.
The standard environment is optimal for applications with the following characteristics:
Source code is written in specific versions of the supported
- Python 2.7
- Java 8, Java 7
- PHP 5.5
- Go 1.6, 1.8, and 1.9 (beta)
- 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.
- Experiences sudden and extreme spikes of traffic which require immediate scaling.
Comparing high-level features
The following table summarizes the differences between the two environments:
|Feature||Flexible environment||Standard environment|
|Instance startup time||Minutes||Seconds|
|Maximum request timeout||60 minutes||60 seconds|
|Background threads||Yes||Yes, with restrictions|
|Scaling||Manual, Automatic||Manual, Basic, Automatic|
|Writing to local disk||Yes, ephemeral (disk initialized on each VM startup)||No|
|Modifying the runtime||Yes (through Dockerfile)||No|
|Automatic in-place security patches||Yes (excludes container image runtime)||Yes|
|Network access||Yes||Only via App Engine services (includes outbound sockets), and only for billing-enabled Python, Go, and PHP applications.|
|Supports installing third-party binaries||Yes||No|
|Location||North America, Asia Pacific, or Europe||North America, Asia Pacific, or Europe|
|Pricing||Based on usage of vCPU, memory, and persistent disks||Based on instance hours|
Comparing the flexible environment to Compute Engine
While the flexible environment runs services in instances on Compute Engine VMs, the flexible environment differs from Compute Engine in the following ways:
The VM instances used in the flexible environment are restarted on a weekly basis. During restarts, Google's management services apply any necessary operating system and security updates.
You always have root access to Compute Engine VM instances. By default, SSH access to the VM instances in the flexible environment is disabled. If you choose, you can enable root access to your app's VM instances.
The geographical region of the VM instances used in the flexible environment is determined by the location that you specify for the App Engine application of your GCP project. Google's management services ensures that the VM instances are co-located for optimal performance.