Processing Request Units Per Second (RUs / s) Spikes in DocumentDB

One of the most difficult things in DocumentDB is determining the number of queries per second (RU / s) needed to run your application daily, as well as while using bursts. When you do this wrong, the DocumentDB client will throw exceptions, which is a terrible usage model.

If my application has a specific time of day when it will use more request units per second (RUs / s), then how to do it in DocumentDB? I do not want to set really high RUs / s all day, because I would get paid accordingly. I also do not want to have to log into the Azure portal every time.

+3
source share
1 answer

You can create an Azure job that scales the bandwidth of your collections only when you need it, and then shrink down.

If you are targeting DocumentDB with .NET, this Azure article contains sample code that shows how to change throughput using the .NET SDK.

The specific (C # .NET) code provided in the article is as follows:

//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);

I assume that the DocumentDB SDK for other languages โ€‹โ€‹will have the same function.

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

$ResourceGroupName = "resourceGroupName"

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

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

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

Source: https://habr.com/ru/post/1017209/


All Articles