Menyediakan Throughput Standar (Manual) Pada Kontainer Azure Cosmos DB - API untuk NoSQL

Artikel ini menjelaskan cara menyediakan throughput standar (manual) pada kontainer di Azure Cosmos DB untuk NoSQL. Anda dapat menyediakan throughput pada satu kontainer, atau menyediakan throughput pada database dan membagikannya di antara kontainer dalam database. Anda dapat menyediakan throughput pada kontainer menggunakan portal Microsoft Azure, Azure CLI, atau Azure Cosmos DB SDK.

Jika Anda menggunakan API yang berbeda, lihat artikel API untuk MongoDB, API untuk Cassandra, API untuk Gremlin untuk menyediakan throughput.

portal Azure

  1. Masuk ke portal Azure.

  2. Buat akun Azure Cosmos DB baru, atau pilih akun Azure Cosmos DB yang sudah ada.

  3. Buka panel Azure Data Explorer, dan pilih Kontainer Baru. Selanjutnya, harap berikan detail berikut:

    • Tunjukkan apakah Anda membuat database baru atau menggunakan database yang sudah ada.
    • Masukkan ID Kontainer.
    • Masukkan nilai kunci Partisi (misalnya, /ItemID).
    • Pilih throughput Autoscale atau Manual dan masukkan throughput Kontainer yang diperlukan (misalnya, 1000 RU/dtk). Masukkan throughput yang ingin Anda provisikan (misalnya, 1000 RU).
    • Pilih OK.

    Cuplikan layar Data Explorer, dengan Koleksi baru disorot

Azure CLI atau PowerShell

Untuk membuat kontainer dengan throughput khusus, berikut caranya:

.NET SDK

Nota

Gunakan SDK Azure Cosmos DB untuk API untuk NoSQL untuk menyediakan throughput untuk semua API Azure Cosmos DB, kecuali Cassandra dan API untuk MongoDB.

// Create a container with a partition key and provision throughput of 400 RU/s
DocumentCollection myCollection = new DocumentCollection();
myCollection.Id = "myContainerName";
myCollection.PartitionKey.Paths.Add("/myPartitionKey");

await client.CreateDocumentCollectionAsync(
    UriFactory.CreateDatabaseUri("myDatabaseName"),
    myCollection,
    new RequestOptions { OfferThroughput = 400 });

JavaScript SDK

// Create a new Client
const client = new CosmosClient({ endpoint, key });

// Create a database
const { database } = await client.databases.createIfNotExists({ id: "databaseId" });

// Create a container with the specified throughput
const { resource } = await database.containers.createIfNotExists({
id: "containerId",
throughput: 1000
});

// To update an existing container or databases throughput, you need to user the offers API
// Get all the offers
const { resources: offers } = await client.offers.readAll().fetchAll();

// Find the offer associated with your container or the database
const offer = offers.find((_offer) => _offer.offerResourceId === resource._rid);

// Change the throughput value
offer.content.offerThroughput = 2000;

// Replace the offer.
await client.offer(offer.id).replace(offer);

Langkah berikutnya

Lihat artikel berikut untuk mempelajari penyediaan throughput di Azure Cosmos DB: