在CosmosDb中使用/id作为分区键的含义 [英] Implications of using /id for the partition key in CosmosDb

查看:190
本文介绍了在CosmosDb中使用/id作为分区键的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在每分钟有1000个条目(唯一键)输入波斯菊的情况下,将/id用作分区键是否安全?

In the scenario where we have 1000 entries (unique keys) entering cosmos per minute, is it safe to use /id as the partition key?

尤其是逻辑分区的概念 https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data 这里的图形使我有些害怕,表明逻辑分区是实际的实体(例如,"city":"London").如果我有一个8小时的TTL和每分钟1000个条目,那么我并不一定需要cosmos需要管理的480,000个逻辑分区.

In particular, there is the concept of Logical Partitions https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data The graphic here scares me a little bit, showing that the logical partitions are actual entities (Ex. "city": "London"). If I have an 8 hour TTL and 1000 entries per minute, I don't necessarily want 480,000 logical partitions that cosmos needs to manage.

我想像的是,分区键的值只是简单地经过哈希处理,并与物理分区的数量(例如,模数)取模. https://docs.microsoft.com/en -us/azure/cosmos-db/partitioning-overview#choose-partitionkey 表示在逻辑分区管理"部分中,这是正确的.此外,选择分区密钥"部分建议(但实际上并未声明)/id将是一个很棒的分区密钥,因为它不必担心10GB的限制,吞吐量限制,没有热点,范围广(值范围),并且由于应用程序不需要对除id以外的任何内容进行过滤,因此跨分区查询对于该用例而言不会成为问题.

What I imagine happens is that the value of the partition key is simply hashed and modulo with the number of physical partitions, ex. https://docs.microsoft.com/en-us/azure/cosmos-db/partitioning-overview#choose-partitionkey indicates that this is true in the "Logical Partition Mangement" section. Furthermore, the "Choosing a Partition Key" section suggests (but does not actually state) that /id would be a fantastic partition key, as it doesn't have to worry about the 10GB limit, throughput limit, no hot spots, wide (huge) range of values, and since the application doesnt need to filter on anything except the id, cross partition queries wont be an issue for this use case.

总而言之,我是否需要担心成千上万个分区键值(逻辑分区)的内存/CPU/等开销?文档表明分区键的值越多越好,但是不要说是否有太多的值.

In summary, do I need to worry about the memory/CPU/etc overhead of hundreds of thousands of partition key values (logical partitions)? The docs indicate the more values of the partition key is better, but don't say if its possible to have too many values.

推荐答案

我来自Cosmos DB工程团队.

I am from the Cosmos DB engineering team.

您不必担心在Cosmos DB集合/容器上创建的逻辑分区键的数量.只要分区键是你写一个合适的选择(需10GB的每个逻辑分区键帽)和查询,你应该是不错的.

You don't have to worry about the number of logical partition keys that are created on a Cosmos DB collection/container. As long as the partition key is an appropriate choice for your writes (subject to a per-logical partition key cap of 10GB) and queries, you should be good.

这篇关于在CosmosDb中使用/id作为分区键的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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