DocumentDB中的每秒处理请求单位(RUs/s)峰值 [英] Handling Request Units per Second (RUs/s) Spikes in DocumentDB

查看:120
本文介绍了DocumentDB中的每秒处理请求单位(RUs/s)峰值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用DocumentDB时,最困难的事情之一是确定每天运行应用程序所需的每秒请求单位数(RU/s),以及在使用高峰期间.当您发现此错误时,DocumentDB客户端将引发异常,这是一个糟糕的使用模型.

One of the most difficult things with DocumentDB is figuring out how many Request Units per Second (RUs/s) you need to run your application day to day but also during usage spikes. When you get this wrong, the DocumentDB client will throw exceptions, which is a terrible usage model.

如果我的应用程序在一天中的特定时间会使用每秒更多的请求单位(RUs/s),那么我该如何在DocumentDB中处理呢?我不想一整天都设置很高的RU/s,因为我会相应收取费用.我也不想每次都必须登录到Azure门户.

If my application has particular times of the day where it would use a higher number of Request Units per Second (RUs/s), then how do I handle this in DocumentDB? I don't want to set a really high RUs/s all day because I would get charged accordingly. I also don't want to have to log into the Azure portal each time.

推荐答案

您可以在Azure上创建一个作业,该作业仅在需要时才按比例增加集合的吞吐量,然后再按比例缩小.

You could create a job on Azure that scales up the throughput of your collections only at the time of day that you need it and then scale down afterward.

如果要从.NET定位DocumentDB,请此Azure文章中有示例代码,展示了如何使用.NET SDK更改吞吐量.

If you are targeting DocumentDB from .NET, this Azure article has example code that shows how to change the throughput using the .NET SDK.

文章看起来像这样:

//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将具有相同的功能.

I assume that the DocumentDB SDK for other languages would have the same feature.

此外,还从找到了天蓝色的文章在此处,您可以使用PowerShell更改服务级别.

Additionally, from an Azure article found here you can use PowerShell to change the service level.

$ResourceGroupName = "resourceGroupName"

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

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

$ScaleRequest = Set-AzureRmSqlDatabase -DatabaseName $DatabaseName -   ServerName $ServerName -ResourceGroupName $ResourceGroupName -Edition     $NewEdition -RequestedServiceObjectiveName $NewPricingTier

这篇关于DocumentDB中的每秒处理请求单位(RUs/s)峰值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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