跨帐户对 DocumentDB 进行分区的最佳做法是什么?

What are best practices for partitioning DocumentDB across accounts?

我正在开发一个使用 DocumentDB 来存储客户数据的应用程序。其中一项要求是我们按地理区域隔离客户数据,以便美国客户的数据存储在美国境内,欧洲客户的数据存储在欧洲。

我计划实现此目的的方法是拥有两个 DocumentDB 帐户,因为一个帐户与一个数据相关联 centre/region。然后每个帐户都会有一个数据库,以及该数据库中的一个集合。

我查看了有关客户端和服务器端分区的 DocumentDB 文档(例如 1, 2),但在我看来,内置分区支持将无法处理多个区域.尽管 IPartitionResolver 的实现可以想象 return 任意集合自身 link,分区映射与 DocumentClient 相关联,因此绑定到特定帐户。

因此看来我需要创建自己的分区逻辑并维护两个单独的 DocumentClient 实例 - 一个用于美国账户,一个用于欧洲账户。还有其他方法可以达到这个要求吗?

Azure 的 best practices on data partitioning 说:

All databases are created in the context of a DocumentDB account. A single DocumentDB account can contain several databases, and it specifies in which region the databases are created. Each DocumentDB account also enforces its own access control. You can use DocumentDB accounts to geo-locate shards (collections within databases) close to the users who need to access them, and enforce restrictions so that only those users can connect to them.

因此,如果您打算让数据靠近用户(而不仅仅是将它们分开存储),您唯一的选择是创建不同的帐户。幸运的是,计费不是基于每个帐户而是基于每个集合。

DocumentDB 的 resource model 给人的印象是您不能(至少开箱即用)混合使用 DocumentDB 帐户。看起来分区键也没有任何用处,因为分区也只能在同一帐户内发生。

sample可能会对您有所帮助或提供一些提示。