减少CosmosDB的预配置吞吐量 [英] Reducing Provisioned Throughput for CosmosDB

查看:77
本文介绍了减少CosmosDB的预配置吞吐量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cosmosDB,它在数据库级别提供了4个容器和400RU.我添加了2个容器,并且在没有警告的情况下,预配置的RU增加到600.

I have a cosmosDB that had 4 containers and 400RUs provisioned at the database level. I added 2 containers and without warning the provisioned RUs was increased to 600.

以下文档说明了这种情况的发生原因.高于第4个的每个容器至少需要额外的100RU.我的预算限制很严格,因此我删除了2个容器,但找不到降低最低预配置吞吐量的方法,因为预配置吞吐量的下拉列表仅允许增加.有没有办法降低吞吐量?

The document below explains why this happened. Each container above the 4th requires a minimum extra 100RUs. I have tight budget restrictions so I deleted 2 containers but I could not find a way to reduce the minimum provisioned throughput as the dropdown for provisioning throughput only allows increases. Is there a way to reduce throughput?

https://docs.microsoft.com/en -us/azure/cosmos-db/set-throughput

推荐答案

文档,您可以使用cosmos db sdk减少吞吐量设置.例如,我测试java sdk以减少容器吞吐量设置.请参考以下代码:

As mentioned in the document,you could reduce throughput settings by using cosmos db sdk. For example, i test java sdk to reduce my container throughput setting. Please refer to below code:

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

    }
}

这篇关于减少CosmosDB的预配置吞吐量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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