The Namespaces API in Google App Engine makes it easy to compartmentalize your Google App Engine data. This API is implemented via the
appengine.Namespace
function
, and is incorporated in certain
namespace-enabled APIs
.
appengine.Context
returned by
appengine.Namespace
, supported API calls use that namespace automatically. Any App Engine request can access any namespace, leaving the application to enforce an access control policy across namespaces.
You can use the Namespaces API to build a wide range of applications. One of the most compelling uses of this API is for multitenant applications, as described below.
- About multitenancy
- Building a multitenant application with the Namespaces API
- App Engine APIs that use namespaces
- Other Uses for the Namespaces API
About multitenancy
Multitenancy is the name given to a software architecture in which one instance of an application, running on a remote server, serves many client organizations (also known as tenants ).
Using a multitenant architecture simplifies administration and provisioning of tenants. You can provide a more streamlined, customized user experience, and also aggregate different silos of data under a single database schema. As a result, your applications become more scalable as well as more cost-effective as you scale. Data becomes easier to segregate and analyze across tenants because all tenants share the same database schema. Different user groups see custom content wrapped within a more efficient application.
Building a multitenant application with the Namespaces API
Using the Namespaces API, you can easily partition data across tenants simply by specifying a unique namespace string for each tenant. You simply set the namespace for each tenant using
appengine.Namespace
. The
namespace-enabled APIs
will use this namespace automatically.
The Namespaces API is integrated with Google Apps, allowing you to use your Google Apps domain as the current namespace. Because Google Apps lets you deploy your app to any domain that you own, you can easily set unique namespaces for all domains linked to your Google Apps account.
When designing multitenant applications, you need to prevent data from leaking across namespaces. For more information, please see Avoiding Data Leaks .
App Engine APIs that use namespaces
App Engine currently supports namespaces in the following APIs: