处理 DocumentDB 中每秒请求单位 (RU/s) 的峰值

2024-05-04

使用 DocumentDB 最困难的事情之一是计算出每天以及在使用高峰期间运行应用程序所需的每秒请求单位数 (RU/s)。当你犯这个错误时,DocumentDB客户端将抛出异常,这是一个糟糕的使用模型。

如果我的应用程序在一天中的特定时间会使用更高数量的每秒请求单位 (RU/s),那么我该如何在 DocumentDB 中处理这个问题?我不想全天设置非常高的 RU/s,因为我会相应地付费。我也不想每次都登录 Azure 门户。


您可以在 Azure 上创建一个作业,仅在一天中需要时扩大集合的吞吐量,然后再缩小。

如果您的目标是来自 .NET 的 DocumentDB,这篇 Azure 文章 https://azure.microsoft.com/en-us/documentation/articles/documentdb-performance-levels/有示例代码演示如何使用 .NET SDK 更改吞吐量。

中引用的具体(C# .NET)代码article https://azure.microsoft.com/en-us/documentation/articles/documentdb-performance-levels/看起来像这样:

//Fetch the resource to be updated
Offer offer = client.CreateOfferQuery()
              .Where(r => r.ResourceLink == collection.SelfLink)    
              .AsEnumerable()
              .SingleOrDefault();

// Set the throughput to 5000 request units per second
offer = new OfferV2(offer, 5000);

//Now persist these changes to the database by replacing the original resource
await client.ReplaceOfferAsync(offer);

// Set the throughput to S2
offer = new Offer(offer);
offer.OfferType = "S2";

//Now persist these changes to the database by replacing the original resource
await client.ReplaceOfferAsync(offer);

我假设其他语言的 DocumentDB SDK 也具有相同的功能。

另外,从一个Azure 文章在这里找到 https://azure.microsoft.com/en-us/documentation/articles/sql-database-scale-up-powershell/您可以使用 PowerShell 更改服务级别。

$ResourceGroupName = "resourceGroupName"

$ServerName = "serverName"
$DatabaseName = "databaseName"

$NewEdition = "Standard"
$NewPricingTier = "S2"

$ScaleRequest = Set-AzureRmSqlDatabase -DatabaseName $DatabaseName -   ServerName $ServerName -ResourceGroupName $ResourceGroupName -Edition     $NewEdition -RequestedServiceObjectiveName $NewPricingTier
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

处理 DocumentDB 中每秒请求单位 (RU/s) 的峰值 的相关文章

随机推荐