11
votes

Google Cloud Firestore is going to replace the legacy Google Cloud Datastore soon. One then has the choice between using Cloud Firestore in "native mode" or in "datastore mode". The former allows access to Firestore through the usual Firestore SDK while the latter allows usage of the old Cloud Datastore SDK (which has no Web/Mobile APIs).

I am not yet familiar with Firestore. My question is: Apart from porting things to a new API, are there actually any things that can not be done with Firestore in "native mode" which could be done with the old Cloud Datastore (or its replacement: Firestore in "datastore mode")? Or any other advantage of using "datastore mode" (like costs, for example)?

If not, then it seems there is actually no advantage of using Firestore in "datastore mode" other than compatibility for older code using the old Cloud Datastore.

Am I right in my assumption that Firestore "datastore mode" has absolutely no advantage besides being able to use the legacy Datastore API (at the cost of not being able to use the newer and probably more feature-rich Firestore APIs, including mobile and web APIs)?

3

3 Answers

15
votes

Cost.

Firestore in Datastore mode supports key-only and projection queries just like the original datastore. That means that the result set of those queries counts towards "Cloud Firestore Small Operations" which are free. We accumulate billions of those small operations per day and not having projection queries would effectively 10-fold our datastore cost which would be unbearable.

As this feature is not available in Firestore native mode - and also with the strong consistency added in - we expected it to be less performant then in the original datastore, but in our tests this was not the case. Firestore in datastore mode consistently performed about twice as fast for our application across all types of operations.

14
votes

There are advantages of using "datastore mode", even for a new project.

I am evaluating the two modes of firestore "Datastore mode" and "Native mode" for a migration project from MySQL.

On one hand, I consider using the "Datastore mode" for one back-end global repository because:

  1. Server side only
  2. Strong performance expectation on search queries across all entities
  3. Query and sort on several properties altogether
  4. Structured data model with one root kind and few second level kinds
  5. A lot of write with limited transaction requirement, a huge number of read with projection within an entity group

On the other hand, the "Native mode" seems to fit some requirements for a user facing specific application because:

  1. Web, iOS, Android, API interface with bi-directional sync
  2. Several occasionally connected use cases
  3. Few large polymorphic objects to sync and to persist
  4. Mostly simple query on one properties (parent object)

Though, there is one reason which advocate for Datastore mode for the second project

  1. Multi-tenancy with namespace

There are also common needs fulfilled by both mode, which support the decision to migration to NoSQL technologies

  1. Scalability
  2. No admin
  3. Availability
  4. Speed of development

The items 2 to 5 and 10 are based on features specific for the Datastore Mode, not possible in Native Mode. The items 6 to 9 are specific to Native Mode.

Update : March, 21st 2019

Six months after the evaluation described in my first answer, my team is using both Firestore (native) mode and Datastore mode.

  • 2 projects based on Firestore. We are using a lot the concepts of collection, sub-collection and documents and the undelying segregation of data. We also have implemented listeners in iOS and Android apps for sub-collections selected accordung to strong business and security rules, which is not possible with Datastore.

  • 9 projects based on Datastore. For three 3 of them, we are are using a lot the concepts of namespace and kind. We also use the global indexing of kind's properties and the projection of properties server-side, which is not possible with Firestore.

PS: we are considering to open-source our python library for fast development of a common API running either on Firestore and on Datastore.

3
votes

According to official documentation, although Cloud Firestore is backwards compatible with Cloud Datastore, the new data model, real-time updates, and mobile and web client library features are not.

Cloud Firestore in Datastore mode uses Cloud Datastore system behavior but accesses Cloud Firestore's storage layer, removing the following Cloud Datastore limitations:

  • Eventual consistency, all Cloud Datastore queries become strongly consistent.
  • Transactions are no longer limited to 25 entity groups.
  • Writes to an entity group are no longer limited to 1 per second.

Datastore mode disables Cloud Firestore features that are not compatible with Cloud Datastore:

  • The project will accept Cloud Datastore API requests and deny Cloud Firestore API requests.
  • The project will use Cloud Datastore indexes instead of Cloud Firestore indexes.
  • You can use Cloud Datastore client libraries with this project but not Cloud Firestore client libraries.
  • Cloud Firestore real-time capabilities will not be available.
  • In the GCP console, the database will use the Cloud Datastore viewer.