Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
An App Engine application can consume resources up to certain maximums, or quotas. With quotas, App Engine ensures that your application won't exceed your budget, and that other applications running on App Engine won't impact the performance of your app.
Note: The free quota levels described below will change on May 25th, 2009 (90 days after February 24th, 2009). See Upcoming Changes to the Free Quotas below for more details. If your application requires higher quotas than the "billing-enabled" per-minute values listed below allow, you can request an increase.
Each App Engine resource is measured against one of two kinds of quota: a billable quota or a fixed quota.
Billable quotas are resource maximums set by you, the application's administrator, to prevent the cost of the application from exceeding your budget. Every application gets an amount of each billable quota for free. You can increase billable quotas for your application by enabling billing, setting a daily budget, then allocating the budget to the quotas. You will be charged only for the resources your app actually uses, and only for the amount of resources used above the free quota thresholds.
After you enable billing for your application, you can set your daily budget and adjust quota allocations for your app using the Admin Console. For more information about setting your budget and allocating quotas, see Billing.
Fixed quotas are resource maximums set by App Engine to ensure the integrity of the system. These resources describe the boundaries of the architecture, and all applications are expected to run within the same limits. They ensure that another app that is consuming too many resources will not affect the performance of your app.
When you enable billing for your app, the app's fixed quotas increase. See the Resources section for details.
App Engine records how much of each resource an application uses in a calendar day, and considers the resource depleted when this amount reaches the app's quota for the resource. A calendar day is a period of 24 hours beginning at midnight, Pacific Time. App Engine resets all resource measurements at the beginning of each day, except for Stored Data which always represents the amount of datastore storage in use.
Historical note: The 24-hour replenishment cycle was introduced in December 2008. It replaced a more complicated system of "continuous" replenishment, to make it easier to report and control resource usage.
In addition to the daily quotas described above, App Engine moderates how quickly an app can consume a resource, using per-minute quotas. This protects the app from consuming all of its quota in very short periods of time, and keeps other apps from affecting your app by monopolizing a given resource.
If your application consumes a resource too quickly and depletes one of the per-minute limits, the word "Limited" will appear by the appropriate quota on the Quota Details screen in the Admin Console. Requests for resources that have hit their per-minute maximum will be denied. See When a Resource is Depleted for details.
As with the daily fixed quotas, there are two levels of per-minute quotas, depending on whether billing has been enabled or not. See the quota tables in the Resources section for details.
When an app consumes all of an allocated resource, the resource becomes unavailable until the quota is replenished. This may mean that your app will not work until the quota is replenshed.
For resources that are required to initiate a request, when the resource is depleted, App Engine returns an HTTP 403 Forbidden status code for the request instead of calling a request handler. The following resources have this behavior:
For all other resources, when the resource is depleted, an attempt in the app to consume the resource results in an exception. This exception can be caught by the app and handled, such as by displaying a friendly error message to the user. In the Python API, this exception is apiproxy_errors.OverQuotaError
.
The following example illustrates how to catch the OverQuotaError
, which may be raised by the SendMessage()
method if an email-related quota has been exceeded:
try: mail.SendMessage(to='test@example.com', from='admin@example.com', subject='Test Email', body='Testing') except apiproxy_errors.OverQuotaError, message: # Log the error. logging.error(message) # Display an informative message to the user. self.response.out.write('The email could not be sent. ' 'Please try again later.')
If you're going over your system resource quota unexpectedly, consider profiling your app's performance.
A Python application can determine how much CPU time the current request has taken so far by calling the Quota API. This is useful for profiling CPU-intensive code, and finding places where CPU efficiency can be improved for greater cost savings. You can measure the CPU used for the entire request, or call the API before and after a section of code then subtract to determine the CPU used between those two points.
The google.appengine.api.quota
package provides the get_request_cpu_usage()
function. This function returns the amount of CPU resources that the current request has spent so far, as a number of megacycles. This number is proportional to the "CPU Time" quota measurement, but does not include the CPU speed multiplier. This number does not include CPU used by API calls.
In the development server, this function returns 0.
import logging from google.appengine.api import quota start = quota.get_request_cpu_usage() do_something_expensive() end = quota.get_request_cpu_usage() logging.info("do_something_expensive() cost %d megacycles." % (start - end))
This function is not yet available for Java applications. It may be added in a future release.
An application may use the following resources, subject to quotas. Resources measured against billable quotas are indicated with "(billable)." Resource amounts represent an allocation over a 24 hour period.
The cost of additional billable resources is listed on the Billing page.
The amount of data sent by the app in response to requests.
This includes data sent in response to both secure requests and non-secure requests, data sent in email messages, and data in outgoing HTTP requests sent by the URL fetch service.
The amount of data received by the app from requests.
This includes data received by the app in secure requests and non-secure requests, and data received in response to HTTP requests by the URL fetch service.
The total processing time for handling requests, including time spent running the app and performing datastore operations. This does not include time spent waiting for other services, such as waiting for a URL fetch to return or the image service to transform an image.
CPU time is reported in "seconds," which is equivalent to the number of CPU cycles that can be performed by a 1.2 GHz Intel x86 processor in that amount of time. The actual number of CPU cycles spent varies greatly depending on conditions internal to App Engine, so this number is adjusted for reporting purposes using this processor as a reference measurement.
One tool to assist you in identifying areas in the application which use high amounts of runtime CPU quota is the cProfile
module. For instructions on setting up profiling while debugging your application, see "How do I profile my app's performance?".
You can examine the CPU time used to serve each request by looking at the Logs section of the Admin Console. While profiling will assist in identifying inefficient portions of your Python code, it's also helpful to understand which datastore operations contribute to your CPU usage.
Resource | Free Default Quota | Billing Enabled Quota | ||
---|---|---|---|---|
Daily Limit | Maximum Rate | Daily Limit | Maximum Rate | |
Requests | 1,300,000 requests | 7,400 requests/minute | 43,000,000 requests | 30,000 requests/minute |
Outgoing Bandwidth (billable, includes HTTPS) | 10 gigabytes | 56 megabytes/minute | 10 gigabytes free; 1,046 gigabytes maximum | 740 megabytes/minute |
Incoming Bandwidth (billable, includes HTTPS) | 10 gigabytes | 56 megabytes/minute | 10 gigabytes free; 1,046 gigabytes maximum | 740 megabytes/minute |
CPU Time (billable) | 46 CPU-hours | 15 CPU-minute/minute | 46 CPU-hours free; 1,729 CPU-hours maximum | 72 CPU-minute/minute |
The amount of data stored in entities and corresponding indexes.
It's important to note that data stored in the datastore may incur significant overhead. This overhead depends on the number and types of associated properties, and includes space used by built-in and custom indexes. Each entity stored in the datastore requires the the following metadata:
Resource | Free Default Quota | Billing Enabled Quota | ||
---|---|---|---|---|
Daily Limit | Maximum Rate | Daily Limit | Maximum Rate | |
Datastore API Calls | 10,000,000 calls | 57,000 calls/minute | 140,000,000 calls | 129,000 calls/minute |
Stored Data (billable) | 1 gigabyte | None | 1 gigabytes free; no maximum | None |
Data Sent to API | 12 gigabytes | 68 megabytes/minute | 72 gigabytes | 153 megabytes/minute |
Data Received from API | 115 gigabytes | 659 megabytes/minute | 695 gigabytes | 1,484 megabytes/minute |
Datastore CPU Time | 60 CPU-hours | 20 CPU-minutes/minute | 1,200 CPU-hours | 50 CPU-minutes/minute |
Resource | Free Default Quota | Billing Enabled Quota | ||
---|---|---|---|---|
Daily Limit | Maximum Rate | Daily Limit | Maximum Rate | |
Mail API Calls | 7,000 calls | 32 calls/minute | 1,700,000 calls | 4,900 calls/minute |
Recipients Emailed (billable) | 2,000 recipients | 8 recipients/minute | 2,000 recipients free; 7,400,000 recipients maximum | 5,100 recipients/minute |
Admins Emailed | 5,000 mails | 24 mails/minute | 3,000,000 mails | 9,700 mails/minute |
Message Body Data Sent | 60 megabytes | 340 kilobytes/minute | 29 gigabytes | 84 megabytes/minute |
Attachments Sent | 2,000 attachments | 8 attachments/minute | 2,900,000 attachments | 8,100 attachments/minute |
Attachment Data Sent | 100 megabytes | 560 kilobytes/minute | 100 gigabytes | 300 megabytes/minute |
Resource | Free Default Quota | Billing Enabled Quota | ||
---|---|---|---|---|
Daily Limit | Maximum Rate | Daily Limit | Maximum Rate | |
UrlFetch API Calls | 657,000 calls | 3,000 calls/minute | 46,000,000 calls | 32,000 calls/minute |
UrlFetch Data Sent | 4 gigabytes | 22 megabytes/minute | 1,046 gigabytes | 740 megabytes/minute |
UrlFetch Data Received | 4 gigabytes | 22 megabytes/minute | 1,046 gigabytes | 740 megabytes/minute |
Resource | Free Default Quota | Billing Enabled Quota | ||
---|---|---|---|---|
Daily Limit | Maximum Rate | Daily Limit | Maximum Rate | |
Image Manipulation API Calls | 864,000 calls | 4,800 calls/minute | 45,000,000 calls | 31,000 calls/minute |
Data Sent to API | 1 gigabytes | 5 megabytes/minute | 560 gigabytes | 400 megabytes/minute |
Data Received from API | 5 gigabytes | 28 megabytes/minute | 427 gigabytes | 300 megabytes/minute |
Transformations executed | 2,500,000 transforms | 14,000 transforms/minute | 47,000,000 transforms | 32,000 transforms/minute |
Resource | Free Default Quota | Billing Enabled Quota | ||
---|---|---|---|---|
Daily Limit | Maximum Rate | Daily Limit | Maximum Rate | |
Memcache API Calls | 8,600,000 | 48,000 calls/minute | 96,000,000 | 108,000 calls/minute |
Data Sent to API | 10 gigabytes | 56 megabytes/minute | 60 gigabytes | 128 megabytes/minute |
Data Received from API | 50 gigabytes | 284 megabytes/minute | 315 gigabytes | 640 megabytes/minute |
On May 25th, 2009, along with many performance improvements, we will be reducing the free quota levels for the billable quotas. App Engine will always remain free to get started. We believe these new levels will continue to serve a reasonably efficient application around 5 million page views per month, completely free.
The new free quota levels to take effect on May 25th will be as follows:
Several fixed quotas may also change on May 25th for applications without billing enabled. Fixed quotas for applications with billing enabled will not be affected.