azure-cosmosdb - 减少 CosmosDB 的预置吞吐量
问题描述
我有一个 cosmosDB,它在数据库级别配置了 4 个容器和 400RU。我添加了 2 个容器,并且在没有警告的情况下,预配的 RU 增加到了 600。
下面的文档解释了为什么会发生这种情况。4 号以上的每个容器至少需要额外的 100RU。我有严格的预算限制,所以我删除了 2 个容器,但我找不到降低最低预配吞吐量的方法,因为预配吞吐量的下拉菜单只允许增加。有没有办法降低吞吐量?
https://docs.microsoft.com/en-us/azure/cosmos-db/set-throughput
解决方案
如文档中所述,您可以使用 cosmos db sdk 降低吞吐量设置。例如,我测试 java sdk 以降低我的容器吞吐量设置。请参考以下代码:
import com.microsoft.azure.documentdb.*;
import java.util.Iterator;
public class ChangeRUTest {
static private String YOUR_COSMOS_DB_ENDPOINT = "https://***.documents.azure.com:443/";
static private String YOUR_COSMOS_DB_MASTER_KEY="***";
public static void main(String[] args) throws DocumentClientException {
DocumentClient client = new DocumentClient(
YOUR_COSMOS_DB_ENDPOINT,
YOUR_COSMOS_DB_MASTER_KEY,
new ConnectionPolicy(),
ConsistencyLevel.Session);
String collectionLink = "dbs/test/colls/one";
String collectionResourceId = client.readCollection(collectionLink, null).getResource().getResourceId();
// find offer associated with this collection
Iterator<Offer> it = client.queryOffers(
String.format("SELECT * FROM r where r.offerResourceId = '%s'", collectionResourceId), null).getQueryIterator();
Offer offer = it.next();
System.out.println(offer.getContent().getInt("offerThroughput"));
// update the offer
int newThroughput = 400;
offer.getContent().put("offerThroughput", newThroughput);
client.replaceOffer(offer);
}
}
推荐阅读
- php - PHP 函数:比预期更多的参数
- python - 文本相似性。余弦相似度。指定结果
- c# - 使用 MCV 将结果从网格分散到多个页面
- app-store-connect - 我所有 iOS 应用程序的删除率突然增加
- sql-server - 当 SQL Server 中的子级可用时阻止父级删除
- mongodb - 如何计算所有选定数据集的平均时间值?
- memory - 用 Arduino 返回字节数组
- c# - 使用 C# HttpClient 下载的 Skype Emoticon 与使用浏览器下载的字节流不同
- python - Pandas - 为每个实例选择最大值
- javascript - 通过'this'在javascript中列出()php