The Namespaces API in Google App Engine makes it easy to compartmentalize your Google App Engine data. This API is implemented via the
appengine.Namespacefunction, and is incorporated in certain namespace-enabled APIs. When you use the
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
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 APIUsing 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:
Other uses for the Namespace API
While the Namespaces API enables multitenancy on App Engine, it has a number of other uses, including:
- Compartmentalizing user information
- Separating admin data from application data
- Creating separate datastore instances for testing and production
- Running multiple apps on a single app engine instance