PHP 5 has reached end of support and will be deprecated
on January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after their deprecation date
. We recommend that
you migrate to the latest supported version of PHP
.
Managing App Resources
Stay organized with collections
Save and categorize content based on your preferences.
App Engine generates usage reports about your application's
performance and resources utilization. Listed below are potential strategies
for managing your resources more efficiently. For more information,
see the pricing
page.
Viewing usage reports
When evaluating application performance, you should check the
number of instances the application is running, and how the application
consumes resources.
View the dashboard usage reports
View the Instances page
The following sections suggest some strategies for managing resources.
Managing dynamic instance scaling
Decreasing latency
Application latency impacts the number of instances that are required to handle your
traffic. By decreasing latency, you can reduce the number of instances used to
serve your application. Cloud Trace
is a useful tool to view
data about latency and understand potential changes to decrease it.
After using Cloud Trace to view your latency, try some of the following
strategies to reduce latency:
- Increase caching of frequently accessed shared data- That's another way
of saying - use App Engine Memcache. Also, setting your application's
cache-control headers can have a significant impact on how efficiently your data is
cached by servers and browsers. Even caching things for a few seconds can
have an impact on how efficiently your application serves traffic.
- Use App Engine Memcache more efficiently- Use batch calls for get,
set, delete, etc instead of a series of individual calls.
- Use tasks for non-request bound functionality- If your application
performs work that can be done beyond the scope of a user-facing request,
put it in a task! Sending this work to Task Queue
instead of waiting for
it to complete before returning a response can significantly reduce
user-facing latency. Task Queue can then give you much more control over
execution rates and help smooth out your load.
- Use Firestore in Datastore mode (Datastore) more efficiently- See below for more detail.
- Execute multiple URL Fetch calls in parallel:
- Batch together multiple URL Fetch calls instead of handling them
individually inside individual user-facing requests, and handle them in
an offline task in parallel via async URL Fetch.
- For HTTP sessions, write asynchronously.
The app.yaml
configuration file contains several settings you can use to
adjust the trade-off between performance and resource load for a specific version
of your app.
For a list of the available auto-scaling settings, see scaling elements
.
Watch the App Engine New Scheduler Settings
video to see the effects of these settings.
Configuring Task Queue settings
The default settings for Task Queue are tuned for performance. With these
defaults, when you put several tasks into a queue simultaneously, they will
likely cause new Frontend Instances to start. Here are some suggestions for
how to tune Task Queue to conserve Instance Hours:
- Set the X-AppEngine-FailFast header on tasks that are not latency sensitive.
This header instructs the scheduler to immediately fail the request if an
existing instance is not available. Task Queue will retry and back-off
until an existing instance becomes available to service the request.
However, it is important to note that when requests with
X-AppEngine-FailFast set occupy existing instances, requests without that
header set may still cause new instances to be started.
Serve static content where possible
Static content serving
is handled by specialized App Engine infrastructure, which does not consume
Instance Hours.
Managing application storage
App Engine calculates storage costs based on the size of entities in the
Datastore, the size of Datastore indexes, the size
of tasks in the task queue, and the amount of data stored in Blobstore. Here are
some things you can do to make sure you don't store more data than necessary:
- Delete any entities or blobs your application no longer needs.
- Remove any unnecessary indexes, as discussed in the Managing Datastore
Usage
section below, to reduce index storage costs.
Managing Datastore usage
App Engine accounts for the number of operations performed in
Datastore. Here are a few strategies that can result in reduced
Datastore resource consumption, as well as lower latency for
requests to Datastore:
- The Google Cloud console dataviewer displays the number of write ops
that were required to create every entity in your local Datastore.
You can use this information to understand the cost of writing each entity.
See Understanding Write Costs
for information on how to interpret this data.
- Remove any unnecessary indexes, which will reduce storage and entity write
costs.
You can see what indexes are currently serving for your application in the Google Cloud console Search page
.
- When designing your data model, you might be able to write your queries in
such a way so as to avoid custom indexes altogether. Read Queries and Indexes
documentation for more information on how App Engine generates
indexes.
- Whenever possible, replace indexed properties (which are the default) with
unindexed properties (
),
which reduces the number of Datastore write operations when
you put an entity. Caution, if you later decide that you do need to be able
to query on the unindexed property, you will need to not only modify your
code to again use indexed properties, but you will have to run a map reduce
over all entities to reput them.
- Due to Datastore query planner improvements in
App Engine 1.5.2 and 1.5.3 releases, your queries may now require
fewer indexes than they did previously. While you may still choose to keep
certain custom indexes for performance reasons, you may be able to delete
others, reducing storage and entity write costs.
- Use keys-only queries instead of entity queries when possible.
- To decrease latency, replace multiple entity
get()
s with a batch get()
.
- Use Datastore cursors for pagination rather than offset.
Note:Small Datastore operations include calls to allocate
Datastore ids or keys-only queries. See the pricing
page for more information on costs.
Managing other resources
It's always a good idea to make
sure you are checking your error rates and looking out for any invalid calls
you might be making. In some cases it might be possible to catch those calls
early.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eApp Engine provides usage reports to help understand application performance and resource utilization, and you can view these reports through the provided dashboard and instances page links.\u003c/p\u003e\n"],["\u003cp\u003eReducing application latency, primarily through strategies like increasing caching, optimizing Memcache usage, and using tasks for non-request-bound work, can significantly decrease the number of instances required to serve traffic.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring Task Queue settings, including using the X-AppEngine-FailFast header for non-latency-sensitive tasks, can help conserve instance hours by managing when new instances are started.\u003c/p\u003e\n"],["\u003cp\u003eOptimizing Datastore usage by removing unnecessary indexes, using keys-only queries, and employing batch \u003ccode\u003eget()\u003c/code\u003e calls can lower resource consumption and reduce latency.\u003c/p\u003e\n"],["\u003cp\u003eServing static content directly via App Engine's specialized infrastructure, rather than through dynamic instances, helps minimize the consumption of instance hours.\u003c/p\u003e\n"]]],[],null,["# Managing App Resources\n\nApp Engine generates usage reports about your application's\nperformance and resources utilization. Listed below are potential strategies\nfor managing your resources more efficiently. For more information,\nsee the [pricing](/appengine/pricing) page.\n\nViewing usage reports\n---------------------\n\nWhen evaluating application performance, you should check the\nnumber of instances the application is running, and how the application\nconsumes resources.\n\n[View the dashboard usage reports](https://console.cloud.google.com/appengine)\n\n[View the Instances page](https://console.cloud.google.com/appengine/instances)\n\nThe following sections suggest some strategies for managing resources.\n\nManaging dynamic instance scaling\n---------------------------------\n\n### Decreasing latency\n\nApplication latency impacts the number of instances that are required to handle your\ntraffic. By decreasing latency, you can reduce the number of instances used to\nserve your application. [Cloud Trace](/trace) is a useful tool to view\ndata about latency and understand potential changes to decrease it.\n\nAfter using Cloud Trace to view your latency, try some of the following\nstrategies to reduce latency:\n\n- **Increase caching of frequently accessed shared data** - That's another way of saying - use App Engine Memcache. Also, setting your application's cache-control headers can have a significant impact on how efficiently your data is cached by servers and browsers. Even caching things for a few seconds can have an impact on how efficiently your application serves traffic.\n- **Use App Engine Memcache more efficiently** - Use batch calls for get, set, delete, etc instead of a series of individual calls.\n- **Use tasks for non-request bound functionality** - If your application performs work that can be done beyond the scope of a user-facing request, put it in a task! Sending this work to [Task Queue](/appengine/docs/legacy/standard/php/taskqueue) instead of waiting for it to complete before returning a response can significantly reduce user-facing latency. Task Queue can then give you much more control over execution rates and help smooth out your load.\n- **Use Firestore in Datastore mode (Datastore) more efficiently** - See below for more detail.\n- **Execute multiple URL Fetch calls in parallel** :\n - Batch together multiple URL Fetch calls instead of handling them individually inside individual user-facing requests, and handle them in an offline task in parallel via async URL Fetch.\n- **For HTTP sessions, write asynchronously**.\n\n### Change auto-scaling performance settings\n\nThe `app.yaml`\nconfiguration file contains several settings you can use to\nadjust the trade-off between performance and resource load for a specific version\nof your app.\nFor a list of the available auto-scaling settings, see\n[scaling elements](/appengine/docs/legacy/standard/php/config/appref#scaling_elements).\nWatch the App Engine [New Scheduler Settings](https://www.youtube.com/watch?v=eUXUY7QFfAI)\nvideo to see the effects of these settings.\n\n### Configuring Task Queue settings\n\nThe default settings for Task Queue are tuned for performance. With these\ndefaults, when you put several tasks into a queue simultaneously, they will\nlikely cause new Frontend Instances to start. Here are some suggestions for\nhow to tune Task Queue to conserve Instance Hours:\n\n- Set the X-AppEngine-FailFast header on tasks that are not latency sensitive. This header instructs the scheduler to immediately fail the request if an existing instance is not available. Task Queue will retry and back-off until an existing instance becomes available to service the request. However, it is important to note that when requests with X-AppEngine-FailFast set occupy existing instances, requests without that header set may still cause new instances to be started.\n\n### Serve static content where possible\n\nStatic content serving\n\n\nis handled by specialized App Engine infrastructure, which does not consume\nInstance Hours.\n\n\nManaging application storage\n----------------------------\n\nApp Engine calculates storage costs based on the size of entities in the\nDatastore, the size of Datastore indexes, the size\nof tasks in the task queue, and the amount of data stored in Blobstore. Here are\nsome things you can do to make sure you don't store more data than necessary:\n\n- Delete any entities or blobs your application no longer needs.\n- Remove any unnecessary indexes, as discussed in the *Managing Datastore\n Usage* section below, to reduce index storage costs.\n\nManaging Datastore usage\n------------------------\n\nApp Engine accounts for the number of operations performed in\nDatastore. Here are a few strategies that can result in reduced\nDatastore resource consumption, as well as lower latency for\nrequests to Datastore:\n\n- The Google Cloud console dataviewer displays the number of write ops that were required to create every entity in your local Datastore. You can use this information to understand the cost of writing each entity. See [Understanding Write Costs](/appengine/docs/legacy/standard/java/datastore/entities#Understanding_Write_Costs) for information on how to interpret this data.\n- Remove any unnecessary indexes, which will reduce storage and entity write costs. You can see what indexes are currently serving for your application in the [Google Cloud console Search page](https://console.cloud.google.com/project/_/appengine/search).\n- When designing your data model, you might be able to write your queries in such a way so as to avoid custom indexes altogether. Read [Queries and Indexes](/appengine/docs/legacy/standard/python/datastore/queries) documentation for more information on how App Engine generates indexes.\n- Whenever possible, replace indexed properties (which are the default) with unindexed properties ( ), which reduces the number of Datastore write operations when you put an entity. Caution, if you later decide that you do need to be able to query on the unindexed property, you will need to not only modify your code to again use indexed properties, but you will have to run a [map reduce](https://github.com/googlecloudplatform/appengine-mapreduce) over all entities to reput them.\n- Due to Datastore query planner improvements in App Engine 1.5.2 and 1.5.3 releases, your queries may now require fewer indexes than they did previously. While you may still choose to keep certain custom indexes for performance reasons, you may be able to delete others, reducing storage and entity write costs.\n- Use keys-only queries instead of entity queries when possible.\n- To decrease latency, replace multiple entity `get()`s with a batch `get()`.\n- Use Datastore cursors for pagination rather than offset.\n\n**Note:** Small Datastore operations include calls to allocate\nDatastore ids or keys-only queries. See the\n[pricing](/appengine/pricing#cost_resource) page for more information on costs.\n\nManaging other resources\n------------------------\n\nIt's always a good idea to make sure you are checking your error rates and looking out for any invalid calls you might be making. In some cases it might be possible to catch those calls early.\n\n\u003cbr /\u003e"]]