App Engine 上 Cloud Datastore 的客户端库 - NDB 或 google-cloud-datastore [英] Client Library for Cloud Datastore on App Engine - NDB or google-cloud-datastore

查看:27
本文介绍了App Engine 上 Cloud Datastore 的客户端库 - NDB 或 google-cloud-datastore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Google 的文档,我似乎有两个使用 Python 连接到 Datastore 的主要选项:App Engine 的 NDB Datastore 库和适用于 Python 的 Google Cloud Datastore API.

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.

我目前使用的是 App Engine(标准版),但我想构建我的应用,使其在需要时可以扩展,可能是通过迁移到 Compute Engine.考虑到这一点,我应该使用哪个库?App 引擎的文档说明可以使用 NDB,但它似乎不再被非常积极地开发.在撰写本文时,最后一次提交是在 6 个月前,尽管它们似乎以前是 计划一些扩展.一切最终都会转而使用 Google Cloud Datastore API 吗?如果 NDB 被淘汰,我真的不想依赖它.

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.

我还没有试过,但似乎在 App Engine 中使用完整的 Google Cloud Datastore API 可能有其自身的问题.

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.

如果有人有在 App Engine - Standard 上使用 Google Cloud Datastore API 的经验,我很乐意听到您的想法.

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

编辑 - 2016-11-30 - 唯一性

这个问题被标记为类似于这个问题.虽然存在一些相似之处,但我特别提到想要选择一种解决方案,以便在 App Engine 之外轻松实现增长.在这一点上,我假设 NDB 库仅适用于 App Engine,因此如果我超越 App Engine,它将无法工作.但是,我认识到在 App Engine 上使用 NDB 可能仍然有优势,如果我超越,然后切换到 Cloud Datastore API.我的一些相关的、更具体的问题包括:

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:

  • NDB 和 Cloud Datastore API 是否足够相似,以便以后从一个移动到另一个不会有那么大的问题?也许有人已经这样做了并且可能有意见.
  • NDB 真正在 App Engine 上大放异彩的具体原因是什么?性能?
  • 由于 NDB 使用 Cloud Datastore,我是否应该担心它最终会停止使用?谷歌最近让 App Engine 越来越接近云计算产品线的其他部分,而 NDB 存储库最近没有看到很多更新的事实让我感到担忧.Google 会不时停止提供服务.

谢谢.

推荐答案

在阅读更多内容后,我将继续回答我自己的问题,希望对他人有所帮助.

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

完整阅读关于 google-cloud-python 的讨论后,我的许多问题都可以得到一定程度的自信回答.

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

首先,似乎开发者对该项目的看法是Google Cloud Datastore API 应该可以在 App Engine 上运行,但性能将是 比 NDB 更糟糕.这当然是在 App Engine 上通过 Datastore API 使用 NDB 的原因.

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.

其次,听起来开发者认为 NDB 既复杂又相当成熟,并且似乎一致支持 它最终包含在 Cloud Datastore python 库中.因此,似乎不太可能终止 NDB.最有可能的是,它最终可能需要从更广泛的 gcloud 库集中包含在内.

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.

第三,开发人员表示 App Engine 以外的 NDB 支持正在积极开发,因此如果我的项目超越 App Engine,届时 NDB 可能已经在更多环境中可用,因此无需切换到 Cloud Datastore API.此外,标准 App Engine 之外的下一步是柔性环境,其中似乎已经很好地支持 NDB.

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.

所有这些都是说我应该清楚地继续使用 NDB,受益于它在 App Engine 上更好的性能和 ORM 功能,除非 Google 对此事的意见/方向在未来发生变化,否则我很可能会在 GCP 上的其他环境中继续使用 NDB 的选项.我将使用 NDB,并期待它最终包含在 google-cloud-python 中.

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.

这篇关于App Engine 上 Cloud Datastore 的客户端库 - NDB 或 google-cloud-datastore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆