2
votes

Per Google's documentation, it seems like I have two main options for connecting to Datastore using Python: App Engine's NDB Datastore library, and the Google Cloud Datastore API for Python.

I'm currently on App Engine (Standard), but I'd like to structure my app such that it can grow beyond if required, likely via a move to Compute Engine. With that in mind, which library should I use? App engine's documentation states that NDB can be used, but it doesn't seem to be very actively developed anymore. At time of writing the last commit was over 6 months ago, though it seems they may have previously been planning some expansion. Will everything eventually switch to use the Google Cloud Datastore API instead? If NDB is being phased out, I really don't want to develop a dependency on it.

I haven't given it a shot yet, but it seems that using the full Google Cloud Datastore API in App Engine may come with its own issues.

If anyone has experience with using the Google Cloud Datastore API on App Engine - Standard, I'd be happy to hear your thoughts.

Edit - 2016-11-30 - Uniqueness

This question was flagged as being similar to this one. While there is some similarity, I specifically mentioned wanting to choose a solution that would allow for easy growth beyond App Engine. At this point I'm assuming that the NDB library only works on App Engine, so it wouldn't work if I move beyond App Engine. However, I recognise that there may still be advantages to using NDB while on App Engine and then swapping to Cloud Datastore API if I move beyond. Some relevant, more specific questions I have include:

  • Are NDB and the Cloud Datastore API similar enough that moving from one to the other later on wouldn't be that problematic? Perhaps someone has done this and may have an opinion.
  • Are there specific reasons that NDB really shines on App Engine? Performance?
  • Since NDB uses the Cloud Datastore, should I be concerned that it will eventually discontinued? Google has brought App Engine closer and closer to the rest of the cloud computing lineup recently, and the fact that the NDB repo hasn't seen a lot of updating recently concerns me. Google does discontinue things from time to time.

Thanks.

1
My personal experience is that NDB have all the features you need and is very mature. I also used the CGD Api only for access other app datastore, and I found that library too "Low Level"... You loose all the ndb.Model class functionalities, the entities "schema" defined in the class, etc. If you make a query you will recibe the raw data of the info stored in Datastore and you have to manually extract properties, make conversions (i.e. from Pickle to JSON), etc.Rene Marty

1 Answers

7
votes

Following some more reading, I'm going to go ahead and answer my own questions, hopefully for the benefit of others.

After reading the discussion on google-cloud-python in full, many of my questions can be answered with some degree of confidence.

First, it seems that the opinion of the developers on the project is that Google Cloud Datastore API should work on App Engine, but that the performance will be worse than NDB. This is certainly a reason to use NDB over the Datastore API on App Engine.

Second, it sounds like the developers consider NDB to be both complex and quite mature, and seem to unanimously support its eventual inclusion in the Cloud Datastore python library. Thus, it doesn't seem likely that NDB will be discontinued. Most likely, it may just eventually need to be included from the broader gcloud set of libraries.

Third, the devs are indicating that NDB support beyond App Engine is being actively developed, so if my project moves beyond App Engine, NDB may already be available on further environments by then, so no switch to the Cloud Datastore API will be required. Besides, the next step beyond standard App Engine is the Flexible Environment, which seems to already support NDB nicely.

All this to say that I should be clear to move ahead with NDB, benefiting from its better performance and ORM capabilities on App Engine, and unless Google's opinions/directions on the matter change in the future, I'll most likely have the option to continue using NDB in other environments on the Google Cloud. I'm going to use NDB and look forward to its eventual inclusion into google-cloud-python.

If anyone has any additional experience with the matter, I'd love to hear your thoughts.