Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Namespaces Java API

Python | Java | PHP | Go

The Namespaces API in Google App Engine makes it easy to compartmentalize your Google App Engine data. This API is implemented via a new package called the namespace manager , and is incorporated in certain namespace-enabled APIs .

When you set a namespace in the namespace manager, these APIs get the current namespace and use it globally. You can explicitly declare a namespace locally, but you need to exercise caution when explicitly declaring namespaces, because you could inadvertently create data leaks and other bugs. 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.

  1. About multitenancy
  2. Building a multitenant application with the Namespaces API
  3. App Engine APIs that use namespaces
  4. Sample projects using namespaces
  5. 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 globally using the namespace manager (as opposed to setting it explicitly for a specific request). The namespace-enabled APIs always use this current namespace by default.

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:

Sample projects using namespaces

Two sample guestbook applications using namespaces are provided:

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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.