您的位置:首页 > 其它

了解Azure Cosmos DB自动缩放

2020-08-21 13:53 459 查看

Three years ago, when I first started working on Cosmos DB, I was really impressed by the included features such as globally distributed, multi-model DB with low latency, and high availability. However, one of the challenges we had was, keeping the cost down.

三年前,当我第一次开始使用Cosmos DB时,所包含的功能给我留下了深刻的印象,例如具有低延迟和高可用性的全球分布的多模型DB。 但是,我们面临的挑战之一是降低成本。

需要 … (The Need …)

Being a retail company, most of our workloads run during business hours and are significantly less during non-business hours. So, we were basically allocating capacity for that “spike”, even though we really didn’t need it all the time.

作为一家零售公司,我们的大部分工作负载在工作时间运行,而在非工作时间则要少得多。 因此,我们基本上是在为“峰值”分配容量,即使我们并不是一直都需要它。

Container Workload — Provisioned RU/s vs Unused RU/s 容器工作量-预置RU / s与未使用RU / s

On the contrary, to keep costs down and utilize RU/s efficiently, we wrote scripts to scale RU/s based on the time schedule. We even wrote an app to monitor workload and scale the RU/s but it had its limitation.

相反,为了降低成本并有效利用RU / s,我们编写了脚本以根据时间表缩放RU / s。 我们甚至编写了一个应用程序来监视工作量和扩展RU / s,但是它有其局限性。

Azure Cosmos DB自动缩放 (Azure Cosmos DB Autoscale)

Azure Cosmos DB’s Autoscale option gave us the flexibility we needed to scale RU/s based on the usage. Users can turn on Autoscale at the database or individual container level and provide the Max RU/s to scale to.

Azure Cosmos DB的“自动缩放”选项为我们提供了根据使用量缩放RU / s所需的灵活性。 用户可以在数据库或单个容器级别启用“自动缩放”,并提供要缩放至的最大RU / s。

Azure Cosmos DB Autoscale Option — Database vs Container Azure Cosmos DB自动缩放选项-数据库与容器

Autoscale provisions the RU/s based on the workload between the range of 10% of Max RU/s to Max RU’s. For example, if you set Max RU as 20,000 RU/s, Autoscale will scale between the range of 2,000 RU/s (min) to 20,000 RU/s (max).

Autoscale根据最大RU / s的10%到最大RU的工作量配置RU / s。 例如,如果将最大RU设置为20,000 RU / s,则自动缩放将在2,000 RU / s(最小)至20,000 RU / s(最大)之间缩放。

Cosmos Autoscale — Provisioned RU/s varies based on workload Cosmos Autoscale —预配置的RU / s因工作负载而异

成本差异是多少 (What’s the cost difference)

Cosmos billing is done on a per-hour basis (i.e for the highest RU/s the system consumed within that hour), but with Autoscale is enabled, the cost is 50% (8760/5840) more when compared to standard throughput.

Cosmos计费是按小时计费的(即,对于该小时内系统消耗的最高RU / s),但是启用了自动缩放功能后,与标准吞吐量相比,成本要高出50%(8760/5840)。

https://azure.microsoft.com/en-us/pricing/calculator/?service=cosmos-dbhttps://azure.microsoft.com/zh-cn/pricing/calculator/?service=cosmos-db

我应该何时开启自动缩放 (When should I turn on Autoscale)

Since the cost of Autoscale is 50% more than the standard throughput, we will only see savings when the average % utilization is below 66.66666%.

由于Autoscale的成本比标准吞吐率高出50%,因此只有在平均利用率百分比低于66.66666%时,我们才会看到节省。

Cosmos Autoscale Pricing for 100,000 RU/s with 66.66666% utilization Cosmos Autoscale定价为100,000 RU / s,利用率为66.66666%

Before turning on Autoscale, it is important to understand the database/container workload. To pull the workload, go to “Resource Group > Metrics > Select Scope = Your Cosmos DB account, Metric = Normalized RU Consumption & Aggregation = Average”. Filter the collection you want to study and provide a range of 7 days or beyond with time granularity set to 1 hour.

乙 EFORE开启自动量程,了解数据库/容器的工作量是非常重要的。 要提取工作负载,请转到“资源组>度量标准>选择范围= 您的Cosmos DB帐户 ,度量标准= 标准化RU消耗和聚合= 平均值” 。 过滤要研究的馆藏,并提供7天或更长的时间范围(时间粒度设置为1小时)。

Cosmos Container — Normalized RU Consumption < 66% Cosmos Container —标准化RU消耗<66%

Here is a container, with a minimum of around 2–5% of provisioned RU/s and a maximum of around 75% of provisioned RU/s. We can assume the average % utilization is anywhere between 30% — 35% but definitely below 66%. When you provide 35% as Average % utilization in the pricing calculator, you can save about 47% (1–3066/5840) with Autoscale option.

这是一个容器,至少占预配置RU / s的2–5%,最大约占预配置RU / s的75%。 我们可以假设平均利用率为30%到35%之间,但绝对低于66%。 当您在价格计算器中提供35%的平均利用率时,使用自动缩放选项可以节省大约47%(1–3066 / 5840)。

Cosmos Autoscale Pricing for 100,000 RU/s with 35% utilization Cosmos Autoscale定价为100,000 RU / s,利用率为35%

Below is another example where the container workload is close to 100% most of the time with occasional dips. The average % utilization is definitely > 66% and wouldn’t qualify for Autoscale.

下面是另一个示例,其中在大多数情况下,容器的工作量大部分时间接近100%,并且偶尔会出现下降。 平均利用率百分比肯定大于66%,不符合自动缩放标准。

Cosmos Container — Normalized RU Consumption > 66% Cosmos容器—标准化RU消耗> 66%

Azure Cosmos DB Autoscale is a very powerful feature that makes Cosmos DB truly a “pay per use” model that provides rapid elasticity to scale. However, it is also important to understand your workload and determine whether Autoscale should be turned on or not. Otherwise, it will end up costing more than the standard throughput.

一个 ZURE宇宙DB自动量程是一个非常强大的功能,使宇宙DB真正实现了“按使用付费”的模式,可提供快速弹性的规模。 但是,了解您的工作量并确定是否应启用自动缩放也很重要。 否则,最终成本将超过标准吞吐量。

翻译自: https://medium.com/walmartglobaltech/understanding-azure-cosmos-db-autoscale-30935aa35477

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: