【问题标题】:Reducing Provisioned Throughput for CosmosDB减少 CosmosDB 的预置吞吐量
【发布时间】:2019-04-15 22:31:11
【问题描述】:

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

以下文档解释了发生这种情况的原因。 4 号以上的每个容器都需要至少额外的 100RU。我有严格的预算限制,所以我删除了 2 个容器,但我找不到降低最低预配吞吐量的方法,因为预配吞吐量的下拉菜单只允许增加。有没有办法降低吞吐量?

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

【问题讨论】:

    标签: azure-cosmosdb


    【解决方案1】:

    document 中所述,您可以通过使用 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);
    
        }
    }
    

    【讨论】:

    • 你知道 Cosmos DB 和 MongoDB Api 的方法吗?
    • @HamishAnderson 试图为你找到。
    • 有没有办法获得范围吞吐量?
    猜你喜欢
    • 2020-08-22
    • 1970-01-01
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多