Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

Configuration Files

Each version of a service is defined in a.yaml file, which gives the name ofthe service and version. The YAML file usually takes the same name as theservice it defines, but this is not required. If you are deploying severalversions of a service, you can create multiple yaml files in the same directory,one for each version.

Typically, you create a directory for each service, which contains the service'sYAML files and associated source code. Optional application-level configurationfiles (dispatch.yaml,cron.yaml,index.yaml, andqueue.yaml) areincluded in the top level app directory. The example below shows three services.Inservice1 andservice2, the source files are at the same level as the YAMLfile. Inservice3, there are YAML files for two versions.

Hierarchy graph of YAML services

For small, simple projects, all the app's files can live in one directory:

Hierarchy graph of small YAML services

Every YAML file must include a version parameter. To define the default service,you can explicitly include the parameterservice: default or leave the serviceparameter out of the file.

Each service's configuration file defines the scaling type and instance classfor a specific service/version. Different scaling parameters are used dependingon which type of scaling you specify. If you do not specify scaling, automaticscaling is the default. The scaling and instance class settings are described intheapp.yamlreferencesection.

For each service you can also specify settings that map URL requests to specificscripts and identify static files for better server efficiency. These settingsare also included in the yaml file and are described in theapp.yaml referencesection.

The default service

Every application has a single default service. You can define the defaultservice in theapp.yaml with the settingservice: default, but it isn't necessary to do this. All configurationparameters relevant to services can apply to the default service.

Optional configuration files

These configuration files control optional features that apply to all theservices in an app:

  • dispatch.yamloverrides routing default rules by sending incoming requests to a specificservice based on the path or hostname in the URL.
  • queue.yamlconfigures both push queues and pull queues.
  • index.yamlspecifies which indexes your app needs if using Datastore queries.
  • cron.yamlconfigures regularly scheduled tasks that operate at defined times or regularintervals.

To deploy updates of these configuration files to App Engine, run thefollowing command from the directory where they are located:

gcloudappdeploy[CONFIG_FILE]

An example

Here is an example of how you would configure YAML files for an application thathas three services: a default service that handles web requests, plus two moreservices that handle mobile requests and backend processing.

Start by defining a configuration file namedapp.yaml that will handle allweb-related requests:

runtime:python27api_version:1threadsafe:true

If the Google Cloud console project ID for this app issimple-sample thenthis configuration would create a default service with automatic scaling and apublic address ofhttps://simple-sample.uc.r.appspot.com.

Next, assume that you want to create a service to handle mobile web requests.For the sake of the mobile users (in this example) the max pending latency willbe just a second and we'll always have at least two instances idle. To configurethis you would create amobile-frontend.yaml configuration file. with thefollowing contents:

service:mobile-frontendruntime:python27api_version:1threadsafe:trueautomatic_scaling:min_idle_instances:2max_pending_latency:1s

The service this file creates would then be reachable athttps://mobile-frontend-dot-simple-sample.uc.r.appspot.com.

Finally, add a service, calledmy-service for handling static backend work.This could be a continuous job that exports data from Datastore to BigQuery. Theamount of work is relatively fixed, therefore you simply need 1 resident serviceat any given time. Also, these jobs will need to handle a large amount ofin-memory processing, thus you'll want services with an increased memoryconfiguration. To configure this you would create amy-service.yamlconfiguration file with the following contents.

service:my-serviceruntime:python27api_version:1threadsafe:trueinstance_class:B8manual_scaling:instances:1

The service this file creates would then be reachable athttps://my-service-dot-simple-sample.uc.r.appspot.com.

Notice themanual_scaling: setting. Theinstances: parameter tells AppEngine how many instances to create for this service.

You might also want to download thisPython demo app and take a look.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.