我有一个 cosmos DB,它在数据库级别配置了 4 个容器和 400 个 RU。我添加了 2 个容器,并且在没有警告的情况下,配置的 RU 增加到了 600 个。
下面的文档解释了为什么会发生这种情况。第 4 个以上的每个容器至少需要额外 100RU。我的预算限制很严格,所以我删除了 2 个容器,但我找不到减少最小预配置吞吐量的方法,因为预配置吞吐量的下拉列表只允许增加。有没有办法降低吞吐量?
https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput
正如在document https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput#update-throughput-on-a-database-or-a-container,您可以通过使用 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);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)