【问题标题】:Handling Request Units per Second (RUs/s) Spikes in DocumentDB在 DocumentDB 中处理每秒请求单位 (RUs/s) 峰值
【发布时间】:2016-04-19 09:41:52
【问题描述】:

DocumentDB 最困难的事情之一是确定每天运行应用程序以及在使用高峰期间需要多少每秒请求单位 (RUs/s)。当你弄错了,DocumentDB 客户端会抛出异常,这是一种糟糕的使用模式。

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

【问题讨论】:

    标签: azure azure-cosmosdb request-unit


    【解决方案1】:

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

    如果您从 .NET 定位 DocumentDB,this Azure article 的示例代码展示了如何使用 .NET SDK 更改吞吐量。

    article 中引用的特定 (C# .NET) 代码如下所示:

    //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 article found here 使用 PowerShell 更改服务级别。

    $ResourceGroupName = "resourceGroupName"
    
    $ServerName = "serverName"
    $DatabaseName = "databaseName"
    
    $NewEdition = "Standard"
    $NewPricingTier = "S2"
    
    $ScaleRequest = Set-AzureRmSqlDatabase -DatabaseName $DatabaseName -   ServerName $ServerName -ResourceGroupName $ResourceGroupName -Edition     $NewEdition -RequestedServiceObjectiveName $NewPricingTier
    

    【讨论】:

    • DocumentDB 损坏的定价模型迫使您编写额外的代码来解决它。我真的觉得这不应该发生。我们已经必须添加重试逻辑来绕过速率限制。我们应该可以说,这是一些钱,不要限制我,直到它用完,只收取我使用的费用,这就是 Azure 方式!
    • @MuhammadRehanSaeed 是的,我也不喜欢它。我希望看到某种自动缩放,您可以在其中设置阈值并在需要时让它缩放。
    猜你喜欢
    • 2013-10-02
    • 2012-02-25
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多