The Backend API is deprecated as of March 13, 2014. Although Google will
continue to support the Backend API in accordance with our
terms of service, it is strongly recommended that all new applications
use the Modules API instead.
For information on converting existing apps using the Backend API to the Modules API, see Converting Apps to Modules
You can add backends to your application in a configuration file called
backends.xml, which declares the name and desired properties of each backend server. The
backends.xml file is stored in the application's
- About backends.xml
- Uploading Backends
- Types of Backends
- Request Handling
- Defining Handlers
- Instance Classes
- Backends Definitions
Backends have several unique and important differences from default App Engine instances; for more information about how backends work, see the Backends documentation. The following code sample shows a sample
backends.xml file. This configuration file defines three separate backends:
- A backend named
memdb. This backend has five instances of the instance class B8.
- A backend named
workerusing the default class with one instance, and configured with failfast to disable pending queue behavior.
- A backend named
cmdline, used to execute long-running commands issued by admins of the application.
<backends> <backend name="memdb"> <class>B8</class> <instances>5</instances> </backend> <backend name="worker"> <options> <fail-fast>true</fail-fast> </options> </backend> <backend name="cmdline"> <options> <dynamic>true</dynamic> </options> </backend> </backends>
You use the same tool (
appcfg) to upload your backend that you use to upload your application:
appcfg backends <dir> update backend_name
Types of Backends
App Engine supports two backend types: resident and dynamic. Resident backends are the default type of backend; they use resident instances, which remain in memory, even when idle, and are restarted automatically. This allows you to perform larger tasks or tasks requiring continuous processing. By default, a backend is configured with one instance, but you can add more in the configuration file.
The following table compares the major features of resident and dynamic backends:
|Resident Backends||Dynamic Backends||Other Notes|
Both resident and dynamic backends have one instance by default. You can configure the number of instances using the optional instances element.
Upon receipt of an HTTP request
After sitting idle for a few minutes.
Other factors can affect shutdown. See Shutdown for more information.
Preserved until manually shut down, or until an unexpected shutdown event takes place. See Shutdown for more details on shutdown events.
Erased when the backend is shutdown after sitting idle for a few minutes.
|Type of Processing||
Continuous or driven by requests
Driven by requests
Relatively more, because resident backends run continuously.
Relatively less, because dynamic backends terminate when idle.
|Billed by the hour, even if idle|
|Uses||Any work that requires continuous processing or preserved state, such as:
Any request-based work, such as:
Both resident and dynamic backends allow you to address tasks to a specific instance of a backend. You can obtain the instance and backend names programmatically; the endpoint takes the form
|Load Balancing||Requests are evenly balanced across all instances of the backend.||Requests are concentrated on the lowest-numbered instances first, and are served by additional instances as traffic increases.|
Resident and dynamic backends both use pending queues to handle incoming traffic. Requests to a backend that is busy handling other requests wait in a pending queue for a short period of time (10 seconds) before being aborted.
You can disable the backend's pending queue using the failfast feature. You can configure failfast either on a per-request basis or on an entire backend (though the backend option is currently experimental). To use failfast for a single request, add the following header to the task request:
To make an entire backend failfast, add the
<fail-fast> option to the backend definition in
Backends share the set of servlets defined in
web.xml with your main application version. It is not possible at the moment to configure a separate set of servlets for each backend. If you use YAML configuration, you can mark any handlers that you wish to restrict to admins with
login: admin. This login declaration blocks external requests, while allowing internal requests (for example, from another instance of your application, or a task queue) to have access without additional configuration.
App Engine provides four different classes of backend instances, each with different memory and CPU limits. These classes allow you to configure your backend with the processing capacity you need to perform your work. Each class has a specific hourly billing rate. See Pricing for more information.
The default class for backends is
B2, which gives you 256MB of memory and 1200MHz of CPU capacity.
You can change the class of a backend using the
<class> directive in
<backends> <backend name="cmdline"> <class>B4</class> </backend> </backends>
<class> directive has the following values:
|Class configuration||Memory limit||CPU limit||Cost per hour*|
backends.xml file has a single list element called
backends. Each element in the list represents a backend for the application. Backends are subject to Billing, Quotas, and Limits.
<backends> element can contain the following elements and attributes:
The server name, composed of letters, digits, and hyphens. The name "default" is reserved and cannot be used. You also cannot use a name that is already used as an application version. This name is also referred to as the
Determines the backend's instance class, which determines the memory and CPU limits for each instance. The default class is
An integer between
20indicating the number of instances to assign to the given backend. Defaults to
1if unspecified. The instance number is also referred to as the
Applications can handle multiple requests if they are marked as threadsafe in
appengine-web.xml. You can also configure the maximum number of concurrent requests. This feature is experimental. Backends have pending queues; requests to a busy instance retry for 10 seconds before aborting.
Specifies the maximum number of requests that an instance can handle simultaneously. If unset, App Engine determines the concurrent request limit dynamically.
A list of boolean settings, which can include one or more of the following options. Defaults to resident instances. Backends can be configured to always remain in memory, so state is preserved across requests. This means that the backends are configured to always remain in memory, as described in the Types of Backends section above. A resident server is only restarted when the underlying appserver restarts.
Defaults to resident instances. This option sets the backend to use dynamic instances rather than resident instances.
fail-fastoption is experimental. It disables queues, so that an instance that is busy returns an HTTP 503 error immediately when it receives a new request. You can achieve this same behavior by adding an
X-AppEngine-FailFastheader to requests, and the header is not experimental.
Sets backend access to
public. Public backends can serve external HTTP requests from the web. See Public and Private Backends for more information.