Reducing Provisioned Throughput for CosmosDB

十年热恋 提交于 2019-12-11 00:15:15

问题


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.

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


回答1:


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

    }
}


来源:https://stackoverflow.com/questions/55698081/reducing-provisioned-throughput-for-cosmosdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!