The Python 3 runtime is the software stack responsible for installing your web service's code and its dependencies and running your service.
The Python 3 runtime for App Engine in the standard environment is
declared in the
Python 3 versions
The Python 3 runtime supports Python 3.7 and Python 3.8 (beta), and uses the latest stable release of the version you choose. App Engine automatically updates to new release versions upon app deployment, but will not automatically update the minor version.
For example, your application might be deployed at Python 3.7.0 and later automatically updated to Python 3.7.1, but it will not be automatically updated to Python 3.8.0.
During deployment, App Engine uses the Python package manager
pip to install dependencies
defined in the
metadata file located in your project's root directory. You do not need to
upload dependencies as App Engine performs a fresh install.
Dependency specification using the
Pipfile.lock standard is
currently not supported and your project must not have these files present.
The runtime starts your application by using the contents of the optional
entrypoint field in your
app.yaml file. For example:
runtime: python37 entrypoint: gunicorn -b :$PORT main:app
For your app to receive HTTP requests, your entrypoint should start a web server
that listens on the port specified by the PORT environment variable. The
use of an entrypoint is optional; if your app meets the following conditions,
App Engine will use
gunicorn as the web
server and add the package automatically to your
The root of your app directory contains a
main.pyfile with a WSGI-compatible object called
app.yamldoes not contain the entrypoint field.
Your app does not contain
runtime: python37 entrypoint: uwsgi --http-socket :8080 --wsgi-file main.py --callable app --master --processes 1 --threads 2
Your app will run using this pre-configured web server when there is a HTTP request.
Entrypoint best practices
Do not include
gunicorn in your
requirements.txt file unless you are
specifying the entrypoint.
For the best performance, the entrypoint should be lightweight because it runs whenever a new instance of your application is created.
You can use the entrypoint field to tune the performance of your app. For
example, if you use
gunicorn as your web server, you can use the
in the entrypoint field to configure the number of workers serving your app.
The number of workers you specify should match the instance class of your App Engine app:
This guidance serves as a starting point for selecting the
number of workers. You may need to use a different number of workers depending
on your app's performance characteristics. The example below shows an
App Engine deployment that uses two
gunicorn workers for serving apps:
runtime: python37 entrypoint: gunicorn -b :8080 -w 2 main:app
The following environment variables are set by the runtime:
||The ID of your App Engine application. This ID is prefixed with 'region code~' such as 'e~' for applications deployed in Europe.|
||The ID of the current deployment.|
||The App Engine environment. Set to
||The ID of the instance on which your service is currently running.|
||The amount of memory available to the application process, in MB.|
||The runtime specified in your
||The service name specified in your
||The current version label of your service.|
||The Cloud project ID associated with your application.|
||The port that receives HTTP requests.|
define additional environment variables in your
but the above values cannot be overridden, except for
HTTPS and forwarding proxies
App Engine terminates HTTPS connections at the load balancer and
forwards requests to your application. Some applications need to determine
the original request IP and protocol. The user's IP address is available in
X-Forwarded-For header. Applications that require this
information should configure their web framework to trust the proxy.
The runtime includes a full filesystem. The filesystem is read-only except for
/tmp, which is a virtual disk storing data in your
App Engine instance's RAM.
Each instance of your application can use the App Engine metadata server to query information about the instance and your project.
You can access the metadata server through the following endpoints:
The following table lists the endpoints where you can make HTTP requests for specific metadata:
||The project number assigned to your project.|
||The project ID assigned to your project.|
||The zone the instance is running in.|
||The default service account email assigned to your project.|
||Lists all the default service accounts for your project.|
||Lists all the supported scopes for the default service accounts.|
||Returns the auth token that can be used to authenticate your application to other Google Cloud APIs.|
For example, to retrieve your project ID, send a request to