Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / cloud

Google Cloud Datastore - Sign Up

0.00/5 (No votes)
1 Dec 2014CC (Attr 3U)8 min read 7.8K  
This page describes how to activate the Google Cloud Datastore API, the quotas associated with this API, and how to enable billing. The activation process varies based on your existing setup and environment.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

This is a Preview release of the Cloud Datastore HTTP API. As a result, the API is subject to change and the service itself is currently not covered by any SLA or deprecation policy. These characteristics will be evaluated as the API and service moves towards General Availability, but developers should take this into consideration when using the Preview release of Cloud Datastore HTTP API.

  1. Limitations
  2. Accessing the Datastore API from a Compute Engine instance
  3. Accessing the Datastore API from another platform
  4. Accessing an existing App Engine Datastore from a Compute Engine instance
  5. Accessing an existing App Engine Datastore from another platform
  6. Quotas and billing
    1. Quotas
    2. Billing

This page describes how to activate the Google Cloud Datastore API, the quotas associated with this API, and how to enable billing. The activation process varies based on your existing setup and environment.

Note: During the activation process, you will create a Cloud Project ID for your project. This ID value is used as the Dataset ID. The Dataset ID identifies the Cloud Datastore storage used for your project.

Limitations

Cloud Datastore does not work with projects created with the older Google APIs console. So, if you have an existing API project, you will need to create a new one in the Google Developers Console in order to use the Cloud Datastore API.

When you activate the Cloud Datastore API on a brand new Google Developers Console project, a special built-in version is deployed that becomes the default version. If you subsequently deploy an App Engine app to that project, the Cloud Datastore built-in continues to be the default version, so requests to your app will instead be sent to the Cloud Datastore built-in. You can use the Admin Console to manually set your app as the default version.

Accessing the Datastore API from a Compute Engine instance

This section shows how to activate and access the Google Cloud Datastore API from a Compute Engine VM instance in a new or existing Cloud project.

  1. Use the Enable Datastore API Wizard to activate the Datastore API. The wizard allows you to activate the API for an existing project, or create a new project and activate it for that.
  2. Use the Enable Google Compute Engine Wizard to activate the Google Compute Engine API for the project you selected or created in the previous step.
  3. Enable billing for the project under My Project > Billing & settings.
  4. If you haven't already done this, install the gcloud compute and authenticate it to Google Compute Engine.
  5. Add a Google Compute Engine instance and start it, following the instructions for starting an instance in the Google Compute Engine documentation. In addition to the project ID and the instance name, you must also specify both the datastore and userinfo.email scopes as shown here:

    $ PROJECT_ID=<project-id>        # replace <project-id> with the Project ID you created previously.
    $ INSTANCE_NAME=<instance-name>  # replace <instance-name> with the name you want to use for your instance.
    $ gcloud compute instances create $INSTANCE_NAME --project $PROJECT_ID --scopes datastore userinfo-email
  6. Confirm that your instance is running.

  7. To use this new Compute Engine instance, connect to it using ssh.

At this point all services and authorizations are configured for your project and you can start writing code or exploring the API.

Accessing the Datastore API from another platform

This section shows how to activate and access the Google Cloud Datastore API from an external application running on a platform outside of Google Cloud.

  1. Use the Enable Datastore API Wizard to activate the Datastore API. The wizard allows you to activate the API for an existing project, or create a new project and activate it for that.
  2. In the left sidebar, under APIs & auth, select Credentials.
  3. Click on Create new Client ID.
  4. Select Service account and then click Create Client ID. Your browser will download the private key.
  5. Your Service Account is the Email address displayed under the Service Account section.
  6. Your Private Key is the file you just downloaded.
  7. Your Dataset ID is your new or existing Cloud Project ID.

At this point all services and authorizations are configured for your project and you can start writing code or exploring the API.

Accessing an existing App Engine Datastore from a Compute Engine instance

This section shows how to activate and access an existing App Engine Datastore from an Compute Engine instance. This scenario is focused on users who want to share data between an existing App Engine application and a Compute Engine instance.

  1. Visit the App Engine Admin Console.
  2. Select the Application ID for which the Google Cloud Datastore API should be enabled.
  3. In the left sidebar, click the Application Settings.
  4. In the Basics section, find the Google APIs Console Project Number and click it to go to the dashboard of the project containing the App Engine application.

    Note: New App Engine applications are automatically created with a Cloud project, which is required if your App Engine app needs to work with other Cloud products or use other Google APIs. However, older legacy App Engine applications were not created with a Cloud project. If your application does not have an associated project, create one (and populate the Google APIs Console Project Number field) by following the instructions How do I create a Cloud project for App Engine.

  5. Use the Enable Datastore API Wizard to activate the Datastore API for the project that contains the App Engine application.

  6. Use the Enable Google Compute Engine Wizard to activate the Google Compute Engine API for the project.
  7. Check that billing is enabled for the project under My Project > Billing & settings.
  8. If you haven't already done this, install the gcloud compute and authenticate it to Google Compute Engine.
  9. Add a Google Compute Engine instance and start it, following the instructions for starting an instance in the Google Compute Engine documentation. In addition to the project ID and the instance name, you must also specify both the datastore and userinfo.email scopes as shown here:

    $ PROJECT_ID=<project-id>        # replace <project-id> with the Project ID you created previously.
    $ INSTANCE_NAME=<instance-name>  # replace <instance-name> with the name you want to use for your instance.
    $ gcloud compute instances create $INSTANCE_NAME --project $PROJECT_ID --scopes datastore userinfo-email
  10. Confirm that your instance is running.

  11. To use this new Compute Engine instance, connect to it using ssh.
  12. Your Dataset ID is the same identifier as your App Engine Application ID.

At this point all services and authorizations are configured for your project and you can start writing code or exploring the API.

Accessing an existing App Engine Datastore from another platform

This section shows how to activate and access an existing App Engine Datastore from an external application running on a platform outside of Google Cloud.

  1. Visit the App Engine Admin Console.
  2. Select the Application ID for which the Google Cloud Datastore API should be enabled.
  3. In the left sidebar, click the Application Settings.
  4. In the Basics section, find the Google APIs Console Project Number and click it to go to the dashboard of the project containing the App Engine application.

    Note: New App Engine applications are automatically created with a Cloud project, which is required if your App Engine app needs to work with other Cloud products or use other Google APIs. However, older legacy App Engine applications were not created with a Cloud project. If your application does not have an associated project, create one (and populate the Google APIs Console Project Number field) by following the instructions How do I create a Cloud project for App Engine.

  5. Use the Enable Datastore API Wizard to activate the Datastore API for the project that contains the App Engine application.

  6. Check that billing is enabled for the project under My Project > Billing & settings.
  7. In the left sidebar, under APIs & auth, select Credentials.
  8. Click on Create new Client ID.
  9. Select Service account and then click Create Client ID. Your browser will download the private key.
  10. Your Service Account is the Email address displayed under the Service Account section.
  11. Your Private Key is the file you just downloaded.
  12. Your Dataset ID is your App Engine Application ID.

At this point all services and authorizations are configured for your project and you can start writing code or exploring the API.

Quotas and billing

Quotas

The Cloud Datastore offers free quota that allows developers to get started at no cost. The resources and free quota amounts are listed below. When more quota is needed, developers will need to enable billing. Quotas are applied daily and reset around midnight Pacific time.

Total limit

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 following metadata:

  • The entity key, including the kind, the ID or key name, and the keys of the entity's ancestors.
  • The name and value of each property. Since the datastore is schemaless, the name of each property must be stored with the property value for any given entity.
  • Any built-in and custom index rows that refer to this entity. Each row contains the entity kind, any number of property values depending on the index definition, and the entity key.

See How Entities and Indexes are Stored for a complete breakdown of the metadata required to store entities and indexes at the Bigtable level and How Index Building Works for a detailed explanation of how datastore indexes are managed.

Resource Free Default Daily Limit Billing Enabled Default Limit
Stored Data (billable) 1 GB* 1 GB free; no maximum
Number of Indexes 200* 200
Write Operations 50,000 10 million per day**
Read Operations 50,000 10 million per day**
Small Operations 50,000 10 million per day**
*Not a daily limit but a total limit.
**The billing enabled limits are for Preview only. If you expect to exceed these limits while the service is in Preview please request a quota increase.

Billing

In order to take advantage of higher quotas, you will need to enable billing. To do so:

  • Navigate to Google Developers Console.
  • Select the project for which billing should be enabled
  • Select Cloud Datastore and follow the instructions in the lower left corner.

Google Cloud Datastore usage and billing is currently part of the App Engine billing system. This setup is for Preview only. Going forward, Google Cloud Datastore will be billed with its own SKU and separately of App Engine.

Except as otherwise noted, the code samples of this page is licensed under the Apache 2.0 License.

License

This article, along with any associated source code and files, is licensed under The Creative Commons Attribution 3.0 Unported License